From cdbb9e5342bd8e3fa88d3b9bde7e7c23e5504ac0 Mon Sep 17 00:00:00 2001 From: TimL Date: Thu, 11 Jul 2024 03:11:38 +1000 Subject: [PATCH] [posix] deassert DTR and RTS if flow control is disabled (#10454) Many USB radio devices (particularly those based on TI CC2652) have reset and bootloader activation directly connected to DTR/RTS lines. These devices will fail to start, in the default state where both DTR/RTS are asserted on connection. This patch ensures flow control is disabled and both DTR and RTS are deasserted on startup while configuring the terminal. --- src/posix/platform/hdlc_interface.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/posix/platform/hdlc_interface.cpp b/src/posix/platform/hdlc_interface.cpp index 12726fc72..a1a6c8c9a 100644 --- a/src/posix/platform/hdlc_interface.cpp +++ b/src/posix/platform/hdlc_interface.cpp @@ -600,6 +600,20 @@ int HdlcInterface::OpenFile(const Url::Url &aRadioUrl) { tios.c_cflag |= CRTSCTS; } + else + { +#ifndef __APPLE__ + int flags; +#endif + + tios.c_cflag &= ~(CRTSCTS); + +#ifndef __APPLE__ + // Deassert DTR and RTS + flags = TIOCM_DTR | TIOCM_RTS; + VerifyOrExit(ioctl(fd, TIOCMBIC, &flags) != -1, perror("tiocmbic")); +#endif + } VerifyOrExit((rval = cfsetspeed(&tios, static_cast(speed))) == 0, perror("cfsetspeed")); rval = tcsetattr(fd, TCSANOW, &tios);