radarsat1 / liblo

liblo is an implementation of the Open Sound Control protocol for POSIX systems
GNU Lesser General Public License v2.1
192 stars 60 forks source link

Serial port support #77

Open radarsat1 opened 5 years ago

radarsat1 commented 5 years ago

It should be possible to leverage the stream support to add serial port support on all supported operating system, avoiding the need to use an external library or custom code for this common scenario of using OSC to interact with devices.

radarsat1 commented 5 years ago

I should say that this seemingly is unneeded with respect to #76, as the user could use an external serial library, but since serial port APIs are quite stable on supported operating systems it would be really cool for liblo to just support it directly.

7890 commented 5 years ago

I have thought about that too - for talking to serial devices like a breeze with liblo. The serial part on linux seems simple enough. This is a fully working serial program (tiny, around 150 LOC w/out comments): https://raw.githubusercontent.com/7890/csnip/master/com/com.c It just needs some ringbuffers at the right places to connect with liblo. As you mentioned, maybe serial will be one instance of a broader design towards streaming to/from all kinds of transports.

7890 commented 5 years ago

@radarsat1 I might try this out. What would be the preferred place to hook it into the API?

I thought of using the message handler callbacks that would be attached to a serial connection. A common sequence would be: -setup serial, get connection -add message callback handler to serial connection (similar to lo_server_add_method()) -use the available message handlers I'm unsure if raw messages with or without boundaries or SLIP makes more sense for the raw data. Let me know if you already have an idea on how and where it would integrate with the low-level API.