From 7bae0000584e4b704c75cfdf7e97a80db412e08e Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Fri, 1 Jul 2016 19:24:12 -0400 Subject: 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. --- rpc_serial.c | 18 ++++++++++-------- 1 file 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; } -- cgit v1.2.3