[Cryptech-Commits] [sw/libhal] 02/02: Apparently the magic Mac OS X ioctl(IOSSIOSPEED) must come AFTER the tcsetattr().

git at cryptech.is git at cryptech.is
Fri Jul 1 23:33:09 UTC 2016


This is an automated email from the git hooks/post-receive script.

sra at hactrn.net pushed a commit to branch macosx
in repository sw/libhal.

commit 7bae0000584e4b704c75cfdf7e97a80db412e08e
Author: Rob Austein <sra at hactrn.net>
AuthorDate: Fri Jul 1 19:24:12 2016 -0400

    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;
 }
 



More information about the Commits mailing list