From 44757c755e061fe03c790e9c3d0d602127b386c5 Mon Sep 17 00:00:00 2001 From: Patrick Grimm Date: Sat, 21 Sep 2024 16:00:08 +0200 Subject: [PATCH] bsd/rs485.c fix compiler warning (#771) declaration-after-statement --- ports/bsd/rs485.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/ports/bsd/rs485.c b/ports/bsd/rs485.c index 093d0996..f7f04e67 100644 --- a/ports/bsd/rs485.c +++ b/ports/bsd/rs485.c @@ -647,6 +647,25 @@ static int openSerialPort(const char *const bsdPath) int fileDescriptor = -1; int handshake; struct termios options; +#if defined(__APPLE__) || defined(__darwin__) + + /* The IOSSIOSPEED ioctl can be used to set arbitrary baud rates other than + * those specified by POSIX. The driver for the underlying serial hardware + * ultimately determines which baud rates can be used. This ioctl sets both + * the input and output speed. */ + + speed_t speed = RS485_Get_Baud_Rate(); + + /* Set the receive latency in microseconds. Serial drivers use this value to + determine how often to dequeue characters received by the hardware. Most + applications don't need to set this value: if an app reads lines of + characters, the app can't do anything until the line termination + character has been received anyway. The most common applications which + are sensitive to read latency are MIDI and IrDA applications. */ + + unsigned long mics = 1UL; + +#endif /* Open the serial port read/write, with no controlling terminal, and don't wait for a connection. The O_NONBLOCK flag also causes subsequent I/O on @@ -726,7 +745,6 @@ static int openSerialPort(const char *const bsdPath) * ultimately determines which baud rates can be used. This ioctl sets both * the input and output speed. */ - speed_t speed = RS485_Get_Baud_Rate(); if (ioctl(fileDescriptor, IOSSIOSPEED, &speed) == -1) { printf("Error calling ioctl(..., IOSSIOSPEED, ...) %s - %s(%d).\n", bsdPath, strerror(errno), errno); @@ -785,7 +803,6 @@ static int openSerialPort(const char *const bsdPath) printf("Handshake lines currently set to %d\n", handshake); #if defined(__APPLE__) || defined(__darwin__) - unsigned long mics = 1UL; /* Set the receive latency in microseconds. Serial drivers use this value to determine how often to dequeue characters received by the hardware. Most