Properly clear Xon/Xoff flow control settings
This commit is contained in:
parent
0e6903362e
commit
1ef3467529
|
@ -2,10 +2,10 @@
|
|||
* PosixHelperFunctions.c
|
||||
*
|
||||
* Created on: Mar 10, 2015
|
||||
* Last Updated on: Feb 25, 2020
|
||||
* Last Updated on: Oct 29, 2021
|
||||
* Author: Will Hedgecock
|
||||
*
|
||||
* Copyright (C) 2012-2020 Fazecast, Inc.
|
||||
* Copyright (C) 2012-2021 Fazecast, Inc.
|
||||
*
|
||||
* This file is part of jSerialComm.
|
||||
*
|
||||
|
@ -491,6 +491,54 @@ baud_rate getBaudRateCode(baud_rate baudRate)
|
|||
return B921600;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
case 1000000:
|
||||
#ifdef B1000000
|
||||
return B1000000;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
case 1152000:
|
||||
#ifdef B1152000
|
||||
return B1152000;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
case 1500000:
|
||||
#ifdef B1500000
|
||||
return B1500000;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
case 2000000:
|
||||
#ifdef B2000000
|
||||
return B2000000;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
case 2500000:
|
||||
#ifdef B2500000
|
||||
return B2500000;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
case 3000000:
|
||||
#ifdef B3000000
|
||||
return B3000000;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
case 3500000:
|
||||
#ifdef B3500000
|
||||
return B3500000;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
case 4000000:
|
||||
#ifdef B4000000
|
||||
return B4000000;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
default:
|
||||
return 0;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* SerialPort_Posix.c
|
||||
*
|
||||
* Created on: Feb 25, 2012
|
||||
* Last Updated on: Oct 22, 2021
|
||||
* Last Updated on: Oct 29, 2021
|
||||
* Author: Will Hedgecock
|
||||
*
|
||||
* Copyright (C) 2012-2021 Fazecast, Inc.
|
||||
|
@ -278,7 +278,7 @@ JNIEXPORT jlong JNICALL Java_com_fazecast_jSerialComm_SerialPort_openPortNative(
|
|||
fcntl(serialPortFD, F_SETFL, 0);
|
||||
tcgetattr(serialPortFD, &options);
|
||||
#if defined(__sun__)
|
||||
options.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON);
|
||||
options.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON | IXOFF);
|
||||
options.c_oflag &= ~OPOST;
|
||||
options.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
|
||||
options.c_cflag &= ~(CSIZE | PARENB);
|
||||
|
@ -332,10 +332,10 @@ JNIEXPORT jboolean JNICALL Java_com_fazecast_jSerialComm_SerialPort_configPort(J
|
|||
unsigned char rs485RxDuringTx = (*env)->GetBooleanField(env, obj, rs485RxDuringTxField);
|
||||
unsigned char isDtrEnabled = (*env)->GetBooleanField(env, obj, isDtrEnabledField);
|
||||
unsigned char isRtsEnabled = (*env)->GetBooleanField(env, obj, isRtsEnabledField);
|
||||
unsigned char XonXoffInEnabled = ((flowControl & com_fazecast_jSerialComm_SerialPort_FLOW_CONTROL_XONXOFF_IN_ENABLED) > 0);
|
||||
unsigned char XonXoffOutEnabled = ((flowControl & com_fazecast_jSerialComm_SerialPort_FLOW_CONTROL_XONXOFF_OUT_ENABLED) > 0);
|
||||
tcflag_t byteSize = (byteSizeInt == 5) ? CS5 : (byteSizeInt == 6) ? CS6 : (byteSizeInt == 7) ? CS7 : CS8;
|
||||
tcflag_t parity = (parityInt == com_fazecast_jSerialComm_SerialPort_NO_PARITY) ? 0 : (parityInt == com_fazecast_jSerialComm_SerialPort_ODD_PARITY) ? (PARENB | PARODD) : (parityInt == com_fazecast_jSerialComm_SerialPort_EVEN_PARITY) ? PARENB : (parityInt == com_fazecast_jSerialComm_SerialPort_MARK_PARITY) ? (PARENB | CMSPAR | PARODD) : (PARENB | CMSPAR);
|
||||
tcflag_t XonXoffInEnabled = ((flowControl & com_fazecast_jSerialComm_SerialPort_FLOW_CONTROL_XONXOFF_IN_ENABLED) > 0) ? IXOFF : 0;
|
||||
tcflag_t XonXoffOutEnabled = ((flowControl & com_fazecast_jSerialComm_SerialPort_FLOW_CONTROL_XONXOFF_OUT_ENABLED) > 0) ? IXON : 0;
|
||||
|
||||
// Set updated port parameters
|
||||
tcgetattr(serialPortFD, &options);
|
||||
|
@ -356,7 +356,14 @@ JNIEXPORT jboolean JNICALL Java_com_fazecast_jSerialComm_SerialPort_configPort(J
|
|||
options.c_iflag |= ISTRIP;
|
||||
if (parityInt != 0)
|
||||
options.c_iflag |= (INPCK | IGNPAR);
|
||||
options.c_iflag |= (XonXoffInEnabled | XonXoffOutEnabled);
|
||||
if (XonXoffInEnabled)
|
||||
options.c_iflag |= IXOFF;
|
||||
else
|
||||
options.c_cflag &= ~(IXOFF);
|
||||
if (XonXoffOutEnabled)
|
||||
options.c_iflag |= IXON;
|
||||
else
|
||||
options.c_cflag &= ~(IXON);
|
||||
|
||||
// Set baud rate and apply changes
|
||||
baud_rate baudRateCode = getBaudRateCode(baudRate);
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue