Set LOW_LATENCY mode and remove tcdrain before close
This commit is contained in:
parent
f3d1e897c2
commit
759914cb3f
2
NOTICE
2
NOTICE
|
@ -1,5 +1,5 @@
|
||||||
Fazecast jSerialComm
|
Fazecast jSerialComm
|
||||||
Copyright (C) 2012-2019 Fazecast, Inc.
|
Copyright (C) 2012-2020 Fazecast, Inc.
|
||||||
|
|
||||||
This product includes software developed at Fazecast, Inc: you can
|
This product includes software developed at Fazecast, Inc: you can
|
||||||
redistribute it and/or modify it under the terms of either the Apache
|
redistribute it and/or modify it under the terms of either the Apache
|
||||||
|
|
31
README.md
31
README.md
|
@ -107,14 +107,15 @@ recommended to simply use the pre-built ```jSerialComm``` library in your
|
||||||
application. For installation/usage instructions, please skip to the [usage](#usage) section.
|
application. For installation/usage instructions, please skip to the [usage](#usage) section.
|
||||||
|
|
||||||
If you do choose to build this library for your specific system, the recommended
|
If you do choose to build this library for your specific system, the recommended
|
||||||
methodology is to use [Gradle](https://gradle.org/) coupled with the
|
methodology is to use [Gradle](https://gradle.org/) coupled with two
|
||||||
Java SDK, [version 1.6](http://www.oracle.com/technetwork/java/archive-139210.html)
|
Java SDKs, [version 1.6](https://www.oracle.com/java/technologies/javase-java-archive-javase6-downloads.html)
|
||||||
|
and [version 9.0.4](https://www.oracle.com/java/technologies/javase/javase9-archive-downloads.html)
|
||||||
(for backward compatibility).
|
(for backward compatibility).
|
||||||
|
|
||||||
Once the Java SDK 1.6 has been installed, ensure that you have an environment
|
Once the Java SDKs have been installed, ensure that you have an environment
|
||||||
variable called ```JDK_HOME``` set to the base directory of your JDK installation.
|
variable called ```JDK_HOME``` set to the base directory of your JDK 9.0.4
|
||||||
Once this has been done, refer to the section corresponding to your specific
|
installation. Once this has been done, refer to the section corresponding to
|
||||||
Operating System for further instructions.
|
your specific Operating System for further instructions.
|
||||||
|
|
||||||
Please note, if you would like to edit any of the source code or view it in an
|
Please note, if you would like to edit any of the source code or view it in an
|
||||||
IDE (such as Eclipse), you can automatically build the Eclipse project files by
|
IDE (such as Eclipse), you can automatically build the Eclipse project files by
|
||||||
|
@ -135,7 +136,7 @@ Ensure that the following tools are installed on your Linux distribution:
|
||||||
# On some distros, these may be called multilib tools for gcc and binutils
|
# On some distros, these may be called multilib tools for gcc and binutils
|
||||||
gcc make glibc-devel.x86_64 glibc-devel.i686
|
gcc make glibc-devel.x86_64 glibc-devel.i686
|
||||||
|
|
||||||
Ensure that the ```JDK_HOME``` environment variable has been set for the 1.6
|
Ensure that the ```JDK_HOME``` environment variable has been set for the 9.0.4
|
||||||
version of your Java SDK. The correct directory can usually be found by entering
|
version of your Java SDK. The correct directory can usually be found by entering
|
||||||
the following command:
|
the following command:
|
||||||
|
|
||||||
|
@ -143,8 +144,8 @@ the following command:
|
||||||
|
|
||||||
Export the result of this command ***up to but not including*** the
|
Export the result of this command ***up to but not including*** the
|
||||||
```/jre/...``` portion using the ```export``` command. For example, if
|
```/jre/...``` portion using the ```export``` command. For example, if
|
||||||
```readlink``` produced ```/usr/lib/jvm/java-6-jdk/jre/bin/java``` as an output,
|
```readlink``` produced ```/usr/lib/jvm/java-9.0.4/jre/bin/java``` as an output,
|
||||||
the export command would look like: ```export JDK_HOME=/usr/lib/jvm/java-6-jdk```
|
the export command would look like: ```export JDK_HOME=/usr/lib/jvm/java-9.0.4```
|
||||||
|
|
||||||
Run the following commands:
|
Run the following commands:
|
||||||
|
|
||||||
|
@ -164,7 +165,7 @@ capable of compiling for both x86 and Sparc-based Solaris architectures.
|
||||||
Instructions for creating such a toolchain can be found on the
|
Instructions for creating such a toolchain can be found on the
|
||||||
[Solaris Cross-Compiler wiki](https://github.com/Fazecast/jSerialComm/wiki/Building-Solaris-Cross-Compilers).
|
[Solaris Cross-Compiler wiki](https://github.com/Fazecast/jSerialComm/wiki/Building-Solaris-Cross-Compilers).
|
||||||
|
|
||||||
Ensure that the ```JDK_HOME``` environment variable has been set for the 1.6
|
Ensure that the ```JDK_HOME``` environment variable has been set for the 9.0.4
|
||||||
version of your Java SDK. The correct directory can usually be found by entering
|
version of your Java SDK. The correct directory can usually be found by entering
|
||||||
the following command:
|
the following command:
|
||||||
|
|
||||||
|
@ -172,8 +173,8 @@ the following command:
|
||||||
|
|
||||||
Export the result of this command ***up to but not including*** the
|
Export the result of this command ***up to but not including*** the
|
||||||
```/jre/...``` portion using the ```export``` command. For example, if
|
```/jre/...``` portion using the ```export``` command. For example, if
|
||||||
```readlink``` produced ```/usr/lib/jvm/java-6-jdk/jre/bin/java``` as an output,
|
```readlink``` produced ```/usr/lib/jvm/java-9.0.4/jre/bin/java``` as an output,
|
||||||
the export command would look like: ```export JDK_HOME=/usr/lib/jvm/java-6-jdk```
|
the export command would look like: ```export JDK_HOME=/usr/lib/jvm/java-9.0.4```
|
||||||
|
|
||||||
Run the following commands:
|
Run the following commands:
|
||||||
|
|
||||||
|
@ -192,7 +193,7 @@ Ensure that you have a cross-compiler installed on your Linux distribution
|
||||||
capable of compiling for ARM-based architectures. I prefer ```crosstool-ng```
|
capable of compiling for ARM-based architectures. I prefer ```crosstool-ng```
|
||||||
for this purpose.
|
for this purpose.
|
||||||
|
|
||||||
Ensure that the ```JDK_HOME``` environment variable has been set for the 1.6
|
Ensure that the ```JDK_HOME``` environment variable has been set for the 9.0.4
|
||||||
version of your Java SDK. The correct directory can usually be found by entering
|
version of your Java SDK. The correct directory can usually be found by entering
|
||||||
the following command:
|
the following command:
|
||||||
|
|
||||||
|
@ -200,8 +201,8 @@ the following command:
|
||||||
|
|
||||||
Export the result of this command ***up to but not including*** the
|
Export the result of this command ***up to but not including*** the
|
||||||
```/jre/...``` portion using the ```export``` command. For example, if
|
```/jre/...``` portion using the ```export``` command. For example, if
|
||||||
```readlink``` produced ```/usr/lib/jvm/java-6-jdk/jre/bin/java``` as an output,
|
```readlink``` produced ```/usr/lib/jvm/java-9.0.4/jre/bin/java``` as an output,
|
||||||
the export command would look like: ```export JDK_HOME=/usr/lib/jvm/java-6-jdk```
|
the export command would look like: ```export JDK_HOME=/usr/lib/jvm/java-9.0.4```
|
||||||
|
|
||||||
Run the following commands:
|
Run the following commands:
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* SerialPort_Posix.c
|
* SerialPort_Posix.c
|
||||||
*
|
*
|
||||||
* Created on: Feb 25, 2012
|
* Created on: Feb 25, 2012
|
||||||
* Last Updated on: Apr 03, 2020
|
* Last Updated on: Apr 29, 2020
|
||||||
* Author: Will Hedgecock
|
* Author: Will Hedgecock
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012-2020 Fazecast, Inc.
|
* Copyright (C) 2012-2020 Fazecast, Inc.
|
||||||
|
@ -260,7 +260,6 @@ JNIEXPORT jlong JNICALL Java_com_fazecast_jSerialComm_SerialPort_openPortNative(
|
||||||
// Ensure that multiple root users cannot access the device simultaneously
|
// Ensure that multiple root users cannot access the device simultaneously
|
||||||
if (flock(serialPortFD, LOCK_EX | LOCK_NB) == -1)
|
if (flock(serialPortFD, LOCK_EX | LOCK_NB) == -1)
|
||||||
{
|
{
|
||||||
tcdrain(serialPortFD);
|
|
||||||
while ((close(serialPortFD) == -1) && (errno == EINTR))
|
while ((close(serialPortFD) == -1) && (errno == EINTR))
|
||||||
errno = 0;
|
errno = 0;
|
||||||
serialPortFD = -1;
|
serialPortFD = -1;
|
||||||
|
@ -292,7 +291,6 @@ JNIEXPORT jlong JNICALL Java_com_fazecast_jSerialComm_SerialPort_openPortNative(
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Close the port if there was a problem setting the parameters
|
// Close the port if there was a problem setting the parameters
|
||||||
tcdrain(serialPortFD);
|
|
||||||
while ((close(serialPortFD) == -1) && (errno == EINTR))
|
while ((close(serialPortFD) == -1) && (errno == EINTR))
|
||||||
errno = 0;
|
errno = 0;
|
||||||
serialPortFD = -1;
|
serialPortFD = -1;
|
||||||
|
@ -366,6 +364,7 @@ JNIEXPORT jboolean JNICALL Java_com_fazecast_jSerialComm_SerialPort_configPort(J
|
||||||
if (ioctl(serialPortFD, TIOCGSERIAL, &serInfo) == 0)
|
if (ioctl(serialPortFD, TIOCGSERIAL, &serInfo) == 0)
|
||||||
{
|
{
|
||||||
serInfo.xmit_fifo_size = sendDeviceQueueSize;
|
serInfo.xmit_fifo_size = sendDeviceQueueSize;
|
||||||
|
serInfo.flags |= ASYNC_LOW_LATENCY;
|
||||||
ioctl(serialPortFD, TIOCSSERIAL, &serInfo);
|
ioctl(serialPortFD, TIOCSSERIAL, &serInfo);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -527,7 +526,6 @@ JNIEXPORT jboolean JNICALL Java_com_fazecast_jSerialComm_SerialPort_closePortNat
|
||||||
options.c_cc[VTIME] = 0;
|
options.c_cc[VTIME] = 0;
|
||||||
int retVal = fcntl(serialPortFD, F_SETFL, flags);
|
int retVal = fcntl(serialPortFD, F_SETFL, flags);
|
||||||
tcsetattr(serialPortFD, TCSANOW, &options);
|
tcsetattr(serialPortFD, TCSANOW, &options);
|
||||||
tcdrain(serialPortFD);
|
|
||||||
|
|
||||||
// Close the port
|
// Close the port
|
||||||
flock(serialPortFD, LOCK_UN | LOCK_NB);
|
flock(serialPortFD, LOCK_UN | LOCK_NB);
|
||||||
|
|
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.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue