diff options
author | Rob Austein <sra@hactrn.net> | 2016-07-01 19:24:12 -0400 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2016-07-01 19:24:12 -0400 |
commit | 7bae0000584e4b704c75cfdf7e97a80db412e08e (patch) | |
tree | b8cde9c3f3d4a2c869fc67925d60a7e5bc3c87a1 /rpc_serial.c | |
parent | 904361120ef5eed8b0bb06da8ec90e4b7f1ef81a (diff) |
Apparently the magic Mac OS X ioctl(IOSSIOSPEED) must come AFTER the tcsetattr().
With this change, we appear to have working libhal client code on Mac OS X.
Diffstat (limited to 'rpc_serial.c')
-rw-r--r-- | rpc_serial.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/rpc_serial.c b/rpc_serial.c index 98a1d20..5dc659e 100644 --- a/rpc_serial.c +++ b/rpc_serial.c @@ -75,14 +75,7 @@ hal_error_t hal_serial_init(const char * const device, const uint32_t speed) if (tcgetattr (fd, &tty) != 0) return perror("tcgetattr"), HAL_ERROR_RPC_TRANSPORT; -#if HAL_RPC_SERIAL_USE_MACOSX_IOCTL - - termios_speed = speed; - - if (ioctl(fd, IOSSIOSPEED, &speed) < 0) - return perror("ioctl()"), HAL_ERROR_RPC_TRANSPORT; - -#else +#if !HAL_RPC_SERIAL_USE_MACOSX_IOCTL switch (speed) { case 115200: @@ -114,6 +107,15 @@ hal_error_t hal_serial_init(const char * const device, const uint32_t speed) if (tcsetattr (fd, TCSANOW, &tty) != 0) return perror("tcsetattr"), HAL_ERROR_RPC_TRANSPORT; +#if HAL_RPC_SERIAL_USE_MACOSX_IOCTL + + termios_speed = speed; + + if (ioctl(fd, IOSSIOSPEED, &speed) < 0) + return perror("ioctl(IOSSIOSPEED)"), HAL_ERROR_RPC_TRANSPORT; + +#endif + return HAL_OK; } |