From 160f1bf92cdf74cdea1453f774ff18c1d63e721a Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 11 Dec 2022 19:50:32 +0100 Subject: src: add support for non-standard baud rates on MacOS @deepcoder reported in issue #14 that MacOS doesn't support non-standard baud rates. A similar issue was already addressed by avrdude here by using the IOSSIOSPEED ioctl: https://github.com/avrdudes/avrdude/issues/771 This patch attempts the same method here. --- src/bt.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/bt.c b/src/bt.c index 7055818..3194f21 100644 --- a/src/bt.c +++ b/src/bt.c @@ -48,6 +48,9 @@ #if defined(__FreeBSD__) #include #endif +#if defined(__APPLE__) +#include +#endif #define MAXPORTS 100 #define BUFSIZE 2048 @@ -551,6 +554,13 @@ int set_port(int fd, int baud) if (cfsetispeed(&tio, baud_flag) == -1) return -1; } +#ifdef __APPLE__ + /* try to set a non-standard baud rate */ + else if (ioctl(fd, IOSSIOSPEED, &baud) >= 0) { + /* finally succeeded */ + baud_flag = 0; + } +#endif if (baud_flag == ~0) { /* baud rate not found */ errno = EINVAL; -- 2.17.5