From 5f70b75e9053c2651525f0b8dd43c6bbc84ff1a3 Mon Sep 17 00:00:00 2001 From: Martin Lund Date: Mon, 1 Jul 2024 23:11:58 +0200 Subject: [PATCH] Fix listing of serial devices on macOS --- src/tty.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/tty.c b/src/tty.c index fdfd0f9..88eecc6 100644 --- a/src/tty.c +++ b/src/tty.c @@ -1407,6 +1407,14 @@ static bool is_serial_device(const char *format, ...) return false; } +#if defined(__APPLE__) + // Make sure device name is on the form /dev/cu.* or /dev/tty.* + if ((strncmp(filename, "/dev/cu.", 8) != 0) && (strncmp(filename, "/dev/tty.", 9) != 0)) + { + return false; + } +#endif + fd = open(filename, O_RDONLY | O_NONBLOCK | O_NOCTTY); if (fd == -1) {