Sry @PerryBebbington, just a bit of humor and/or sarcasm, and a gentle suggestion to the OP.
Who has been advised to share what he has so far in terms of a sketch for his target that shows his claim to be able "make the correct serial connection".
I don't know Python, but it looks like from there (having established a serial connection with the parameters that seem obvious in the Python) the rest of the Python just builds up a sequence of bytes and ships it out.
This in C would just (just!) be a character array. OP, if you don't know C, that is where to start learning more. If you know Python, C is easily understood from like the first chapter or two of whatever book you learnt Python from. It is a tiny language, and you should probably know it as well as it can be known anyway.
Draw out what the Python lands up with in its byte or text or character object. It should be downhill from there.
Now.
Thinking more seriously about google translate for computer languages I ask why not? And when?
Since mostly we are talking about regular computers all of which can only do certain things, it seems that any algorithm can be translated into any language. I am leaving off quantum architectures and neural nets and all that kinda stuff, just your old Turing complete machinery doing the kind of thing that, after all, most computing machines do all the time every day all over the place.
But that leaves out the hardware. I think of and use C as a low level language, the first step up from assembly or machine code. All just syntactic sugar that allows rapid readable expressive access to the metal. Many C programs are quite opaque if one is not at least somewhat dimly aware of how hardware world works.
Many times I see things expressed in Python, but they use all kinds of whizzy built-in stuff that makes direct understanding (or translation/exploitation) of the underlying algorithm(s) nearly impossible. That does not appear to be the case with the OP's snippet.
There is a reason that algorithm books use regular old languages or so-called pseudo-code, the kind of power that these days is briskly covered in two chapters of a book about a modern high-level language. So we can see and understand the step-by-step operation.
Haven't looked lately, for all I know a modern algorithms book would be full of magical features of the language used, and go far deeper into territory I would argue is not really algorithms as such.
I suspect many never fully grasp all and what can be done with just old C and a microprocessor. Or are srsly in trouble once they realize that not everything is going to pop out of some library perfect ready to go for every circumstance.
Some languages are not that modern but would present a translation challenge, like APL or LISP. Nevertheless, since they ultimately run on the same hardware, it seems within grasp.
Modern languages and fashions would be harder, but equally not impossible. The real trick would be ending up with idoimatic expressions in the target language - if you've ever de-compiled object code you know what I mean. Google translate is very good, even so there are some amusing results. But usually better than translations of foreign languages found in literature accompanying cheap foreign products.
I think google translate uses an in-between language so that translation is a two step dance. It seems a similar approach would be possible with computer languages. Again, the hardware would be the stumbling block.
In the meantime (I'll probably not live to see this glorious future) there will be ways for people who get it at the point of intersection between software and hardware to be heroes and haul down the big bucks.
a7