Check return value of ioctl `TIOCGSERIAL` on Linux
This commit is contained in:
parent
4788ef8f4e
commit
9457337495
|
@ -510,13 +510,15 @@ int setBaudRateCustom(int portFD, baud_rate baudRate)
|
||||||
int retVal = ioctl(portFD, TCSETS2, &options);
|
int retVal = ioctl(portFD, TCSETS2, &options);
|
||||||
#else
|
#else
|
||||||
struct serial_struct serInfo;
|
struct serial_struct serInfo;
|
||||||
ioctl(portFD, TIOCGSERIAL, &serInfo);
|
int retVal = ioctl(portFD, TIOCGSERIAL, &serInfo);
|
||||||
serInfo.flags &= ~ASYNC_SPD_MASK;
|
if (retVal == 0) {
|
||||||
serInfo.flags |= ASYNC_SPD_CUST | ASYNC_LOW_LATENCY;
|
serInfo.flags &= ~ASYNC_SPD_MASK;
|
||||||
serInfo.custom_divisor = serInfo.baud_base / baudRate;
|
serInfo.flags |= ASYNC_SPD_CUST | ASYNC_LOW_LATENCY;
|
||||||
if (sersInfo.custom_divisor == 0)
|
serInfo.custom_divisor = serInfo.baud_base / baudRate;
|
||||||
serInfo.custom_divisor = 1;
|
if (sersInfo.custom_divisor == 0)
|
||||||
int retVal = ioctl(portFD, TIOCSSERIAL, &serInfo);
|
serInfo.custom_divisor = 1;
|
||||||
|
retVal = ioctl(portFD, TIOCSSERIAL, &serInfo);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
return (retVal == 0);
|
return (retVal == 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -336,9 +336,11 @@ JNIEXPORT jboolean JNICALL Java_com_fazecast_jSerialComm_SerialPort_configPort(J
|
||||||
// Attempt to set the transmit buffer size and any necessary custom baud rates
|
// Attempt to set the transmit buffer size and any necessary custom baud rates
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
struct serial_struct serInfo;
|
struct serial_struct serInfo;
|
||||||
ioctl(serialPortFD, TIOCGSERIAL, &serInfo);
|
int tiocgserialRetVal = ioctl(serialPortFD, TIOCGSERIAL, &serInfo);
|
||||||
serInfo.xmit_fifo_size = sendDeviceQueueSize;
|
if (tiocgserialRetVal == 0) {
|
||||||
ioctl(serialPortFD, TIOCSSERIAL, &serInfo);
|
serInfo.xmit_fifo_size = sendDeviceQueueSize;
|
||||||
|
ioctl(serialPortFD, TIOCSSERIAL, &serInfo);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if (nonStandardBaudRate)
|
if (nonStandardBaudRate)
|
||||||
setBaudRateCustom(serialPortFD, baudRate);
|
setBaudRateCustom(serialPortFD, baudRate);
|
||||||
|
|
Loading…
Reference in New Issue