This is cool but I think it’s a lot more complex than what you need – this is standing up a whole OSC server you could then connect other stuff to. If I understand right then the SLIP wrapper is basically just doing framing – that is, it is marking where one OSC packet ends and the next begins, since a raw serial port just works with bytes and doesn’t have any notion of a packet. So what you need is basically a program that breaks up the byte stream from the serial port into packets by finding the SLIP framing bytes (that’s what this code does) and then puts on the right header to create a UDP packet with the right destination IP + port, wrapping the OSC content unchanged. Once you’ve decoded the SLIP encoding into packets you could also do this part pretty easily with Python’s built in socket library.
Oh this is cool but also seems to be solving a different problem, where the serial traffic is not already OSC, but the serial data is in some fixed format and you want some code to generate OSC from that known format.
This article makes a good point that any kind of serial <-> UDP translation program is going to introduce latency and jitter, though it’s probably less than the latency and jitter inherent to WiFi.