Closed Vrong closed 7 years ago
Thanks for this second PR. Even if a more robust and elegant portability fix can't be resolved just yet, the library is currently broken.... so I'd like to get this merged ASAP!!
Done
I'll do one more final check on mac and get this merged! Thanks so much.
Urgh thanks for the deep dive here and fixing the bug.
I think we hit this last week when playing with Haskell bindings in https://github.com/scanse/sweep-sdk/pull/115 but didn't look further (since struggling with Haskell was already enough for the evening 😅).
The first fix I made was actually including a condition testing the bitrate before setting a constant, but this one was not merged.
This bug was causing sweep object creation to hang when trying to read the returned value from serial port. ==> Issue #72
Bitrate of the serial communication was badly set during the creation of the sweep object when using the libsweep library on Linux.
cfsetispeed(...) and cfsetospeed(...) both take a termios bitrate constant and not the bitrate directly. So should the get_baud(115200) call return the B115200 value defined in termios.h.
The fix seems to have a limitation when compiling on some MAC OS X computers. Termios constants like B115200 doesn't seem to be always defined. That's why the code uses a #ifdef as a workaround for MAC.
Thanks.