scanse / sweep-sdk

Sweep SDK
MIT License
90 stars 85 forks source link

Fixed badly set bitrate causing sweep object creation to hang on Linux #117

Closed Vrong closed 7 years ago

Vrong commented 7 years ago

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.

dcyoung commented 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!!

Vrong commented 7 years ago

Done

dcyoung commented 7 years ago

I'll do one more final check on mac and get this merged! Thanks so much.

daniel-j-h commented 7 years ago

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 😅).

Vrong commented 7 years ago

The first fix I made was actually including a condition testing the bitrate before setting a constant, but this one was not merged.