I'm building m8c for Android downstream, with a hope of upstreaming it at some point if there is interest. Unrooted Androids do not seem to have direct access to serial ports, instead you get the USB device you want to use in Java side (dealing with permissions etc.),open a connection, claim the CDC/ACM interfaces and pass the file descriptor to the native code where you can communicate with the device.
Since libserialport doesn't deal with file descriptors, something like libusb needs to be used instead.
So my proposal is to:
Move dependencies to libserialport.h to one file
Create more abstract functions to deal with serial init, read and write. Something that doesn't have dependencies on libserialport.h
Use something like #ifdef LIBSERIALPORT in the .c files to turn libserialport dependency on and off.
I'm not a C developer in any capacity so ideas are welcome.
This is something I'm going to do anyway so it's not a request for somebody else to do it, more like a check to see if I should attempt to upstream it as well.
Not a bad idea I think, it improves portability and could possibly make the codebase a bit more clear anyway. Feel free to submit a PR if you want to do one :)
I'm building m8c for Android downstream, with a hope of upstreaming it at some point if there is interest. Unrooted Androids do not seem to have direct access to serial ports, instead you get the USB device you want to use in Java side (dealing with permissions etc.),open a connection, claim the CDC/ACM interfaces and pass the file descriptor to the native code where you can communicate with the device. Since libserialport doesn't deal with file descriptors, something like libusb needs to be used instead.
So my proposal is to:
#ifdef LIBSERIALPORT
in the .c files to turn libserialport dependency on and off.I'm not a C developer in any capacity so ideas are welcome.
This is something I'm going to do anyway so it's not a request for somebody else to do it, more like a check to see if I should attempt to upstream it as well.