From b65870fbe73176c9dbea632200a7fef7e00301bf Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Sat, 23 May 2026 15:19:17 +1000 Subject: [PATCH] AP_HAL_SITL: avoid calling fcntl on -1 in-line the method to make setting non-blocking on _fd more proximate to where the thing is opened --- libraries/AP_HAL_SITL/UARTDriver.cpp | 7 ------- libraries/AP_HAL_SITL/UARTDriver.h | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/libraries/AP_HAL_SITL/UARTDriver.cpp b/libraries/AP_HAL_SITL/UARTDriver.cpp index 7b556929ac1..0c4ea42736f 100644 --- a/libraries/AP_HAL_SITL/UARTDriver.cpp +++ b/libraries/AP_HAL_SITL/UARTDriver.cpp @@ -200,8 +200,6 @@ void UARTDriver::_begin(uint32_t baud, uint16_t rxSpace, uint16_t txSpace) _readbuffer.clear(); _writebuffer.clear(); } - - _set_nonblocking(_fd); } void UARTDriver::_end() @@ -734,11 +732,6 @@ bool UARTDriver::_select_check(int fd) return false; } -void UARTDriver::_set_nonblocking(int fd) -{ - unsigned v = fcntl(fd, F_GETFL, 0); - fcntl(fd, F_SETFL, v | O_NONBLOCK); -} bool UARTDriver::set_unbuffered_writes(bool on) { if (_fd == -1) { diff --git a/libraries/AP_HAL_SITL/UARTDriver.h b/libraries/AP_HAL_SITL/UARTDriver.h index 29a28eb09bf..d9aed9a7588 100644 --- a/libraries/AP_HAL_SITL/UARTDriver.h +++ b/libraries/AP_HAL_SITL/UARTDriver.h @@ -108,7 +108,7 @@ private: void _udp_start_multicast(const char *address, uint16_t port); void _check_connection(void); static bool _select_check(int ); - static void _set_nonblocking(int ); + bool set_speed(int speed) const; SITL_State *_sitlState;