mirror of
https://github.com/espressif/openthread.git
synced 2026-11-13 18:01:02 +00:00
[posix] deassert DTR and RTS on macOS too with uart-init-deassert (#13750)
`uart-init-deassert` deasserts DTR and RTS for radios whose reset and bootloader pins are driven by those lines, except under `#ifndef __APPLE__`: on macOS the parameter only cleared flow control and the lines stayed asserted, silently. #10454 added the guard because a macOS CI job failed on the unguarded version, which deasserted on every open, and the author had no Mac to look further; #10644 then made the deassert opt-in, so CI does not reach the ioctl today. macOS has the ioctl: sys/ttycom.h declares TIOCMBIC, TIOCM_DTR and TIOCM_RTS, and IOSerialBSDClient::iossioctl() passes the bits through to the serial driver's state. Drop the guard so the parameter behaves the same everywhere, and record the ioctl's result in rval so a tty that rejects it fails the open as the other termios steps do, instead of leaving the port half configured.
This commit is contained in:
@@ -636,17 +636,9 @@ int HdlcInterface::OpenFile(const Url::Url &aRadioUrl)
|
||||
else if (aRadioUrl.HasParam("uart-init-deassert"))
|
||||
{
|
||||
// When flow control is disabled, deassert DTR and RTS on init
|
||||
#ifndef __APPLE__
|
||||
int flags;
|
||||
#endif
|
||||
int flags = TIOCM_DTR | TIOCM_RTS;
|
||||
|
||||
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 = ioctl(fd, TIOCMBIC, &flags)) == 0, perror("tiocmbic"));
|
||||
}
|
||||
|
||||
VerifyOrExit((rval = cfsetspeed(&tios, static_cast<speed_t>(speed))) == 0, perror("cfsetspeed"));
|
||||
|
||||
Reference in New Issue
Block a user