aboutsummaryrefslogtreecommitdiff
path: root/rpc_serial.c
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2016-07-01 19:24:12 -0400
committerRob Austein <sra@hactrn.net>2016-07-01 19:24:12 -0400
commit7bae0000584e4b704c75cfdf7e97a80db412e08e (patch)
treeb8cde9c3f3d4a2c869fc67925d60a7e5bc3c87a1 /rpc_serial.c
parent904361120ef5eed8b0bb06da8ec90e4b7f1ef81a (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.c18
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;
}