rxtx / rxtx Goto Github PK
View Code? Open in Web Editor NEWrxtx - a Java cross platform wrapper library for the serial port
Home Page: http://rxtx.github.io/rxtx/
License: Other
rxtx - a Java cross platform wrapper library for the serial port
Home Page: http://rxtx.github.io/rxtx/
License: Other
/*------------------------------------------------------------------------- | RXTX License v 2.1 - LGPL v 2.1 + Linking Over Controlled Interface. | RXTX is a native interface to serial ports in java. | Copyright 1997-2012 by Trent Jarvi [email protected] and others who | actually wrote it. See individual source files for more information. | | A copy of the LGPL v 2.1 may be found at | http://www.gnu.org/licenses/lgpl.txt on March 4th 2007. A copy is | here for your convenience. | | This library is free software; you can redistribute it and/or | modify it under the terms of the GNU Lesser General Public | License as published by the Free Software Foundation; either | version 2.1 of the License, or (at your option) any later version. | | This library is distributed in the hope that it will be useful, | but WITHOUT ANY WARRANTY; without even the implied warranty of | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | Lesser General Public License for more details. | | An executable that contains no derivative of any portion of RXTX, but | is designed to work with RXTX by being dynamically linked with it, | is considered a "work that uses the Library" subject to the terms and | conditions of the GNU Lesser General Public License. | | The following has been added to the RXTX License to remove | any confusion about linking to RXTX. We want to allow in part what | section 5, paragraph 2 of the LGPL does not permit in the special | case of linking over a controlled interface. The intent is to add a | Java Specification Request or standards body defined interface in the | future as another exception but one is not currently available. | | http://www.fsf.org/licenses/gpl-faq.html#LinkingOverControlledInterface | | As a special exception, the copyright holders of RXTX give you | permission to link RXTX with independent modules that communicate with | RXTX solely through the Sun Microsytems CommAPI interface version 2, | regardless of the license terms of these independent modules, and to copy | and distribute the resulting combined work under terms of your choice, | provided that every copy of the combined work is accompanied by a complete | copy of the source code of RXTX (the version of RXTX used to produce the | combined work), being distributed under the terms of the GNU Lesser General | Public License plus this exception. An independent module is a | module which is not derived from or based on RXTX. | | Note that people who make modified versions of RXTX are not obligated | to grant this special exception for their modified versions; it is | their choice whether to do so. The GNU Lesser General Public License | gives permission to release a modified version without this exception; this | exception also makes it possible to release a modified version which | carries forward this exception. | | You should have received a copy of the GNU Lesser General Public | License along with this library; if not, write to the Free | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | All trademarks belong to their respective owners. --------------------------------------------------------------------------*/ This is README Wed Apr 25 22:37:26 MDT 2007 See Also: INSTALL: install instructions and solutions to common problems TODO: Comments for developers COPYING: The LGPL license PORTING: hints for people trying to port rxtx Authors: who wrote what. ChangeLog: when they wrote it. RMISecurityManager.html: Comments for people using RMISecurityManager SerialPortInstructions.txt: HOWTO on read/writing to your com ports on linux for beginners There are numerous possibilities for projects that involve serial communication. Java is an excellent language for putting GUI apps together. Well have fun. Send back stories. Copies of the latest RXTX will be on http://www.rxtx.org/download The primary source for information/support is http://www.rxtx.org. The rxtx mail-list is at [email protected]. Send email with "subscribe rxtx" in the subject without the quotes to join. This is a native lib for jdk 1.1.* and newer. If you find changes required for different platforms or OS's please pass them back this way so we may share it with others. Credit will be given unless one specifically requests no credit. We chopped rxtx out of my program and tried to put a small example together. There is plenty of room for configurability, safe guarding and error reporting. If you have some time please contribute some improvements. We are interested in sharing this code in hopes that a more versatile lib may be developed and released with minimal restrictions. Please send any patches back my way if you like. If you are interested in using rxtx for things like RS485, I2C or raw IO Please get the latest CVS version. Some work has been done for each of them. The latest development version is a stand alone implementation of CommAPI. For bug reports please follow the directions in INSTALL Trent Jarvi taj@www.linux.org.uk
Suggested fix:
String sExtDir = System.getProperty("java.ext.dirs");
final String[] extDirs = (sExtDir!=null)? sExtDir.split(":") : new String[0];
Our current build instructions can be found at http://rxtx.github.io/rxtx/ . It is very important these instructions are clear, easy to understand und up to date to everyone interested in working on rxtx. This is where even novices can shine, because they can identify missing parts. So if you want to help please pick a challenge below and report if there is anything you do not understand or that does not work. Don't hesitate to be picky. The problem is not you, it is bad documentation. We are open for your suggestions.
We still need a good example how to use rxtx. This could be in the form of
Some code may be shared with the Smoke/Integration Test issue #27.
male/female, male/male, female/female, male
I think all of gender changer is redundant.
please someone tell me the answer.
I can't fall asleep
Hello,
I got error C2011: 'timespec': 'struct' type redefinition, in Visual Studio 2015 error when compiling on Visual Studio 2015. I already defined HAVE_STRUCT_TIMESPEC preprocessor to prevent error but it doesn't solved it. What will be the problem?
Regards
The Linux default is that new ports have the HUPCL flag (hang up) set, so RTS is released when the last user of the port closes the device file. rxtx always reconfigures new ports with
ttyset.c_cflag = CREAD | CS8 | CLOCAL;
which overrides the HUPCL flag. Here is an example how this breaks HW that expects RTS to be inactive when the serial port is unused:
https://forum.arduino.cc/index.php?topic=46144.0
I've a similar setup where a modem expects RTS to be deasserted when the host doesn't communicate with it. This needs to work even if the application terminates
abnormally, so I use the same fix locally, but would like to have the functionality upstream as well.
As I guess there might be *nix systems where HUPCL is not a default, I could draft a patch that doesn't remove HUPCL if it's already set for a port. This would still break setups, where the user runs rxtx, sets RTS to active, closee the application and expects the RTS to stay asserted. I don't know how common such a use case is though.
Thoughts?
Problem: When a port is configured to use n data bits (5>n>=8) and 1.5 stop bits, the configuration is silently changed to 5 databits and 1.5 stop bits.
expected behaviour: the call to SerialPort.setSerialPortParams() should fail with UnsupportedCommOperationException and the configuration of the port should hold the last state
java.lang.NullPointerException thrown while loading gnu.io.RXTXCommDriver
We still need a simple test to evaluate the rxtx functionalities across different architectures. A simple loopback test comes to mind, which only requires a single port with the RX and TX signals shorted. There is already the currently empty rxtxSerial-test artifact for this purpose. The idea was to implement this in the form of a unit test using JUnit, but other ideas are welcome.
Some code may be shared with the Usage Example Task #26.
When calling CommPortIdentifier.getPortIdentifiers()
from a simple example application, it immediately returns because CommPortIndex
is null
- even if there are accessible serial ports. Using librxtx-java
from Debian instead works flawlessly.
It seems that the Java code never even accesses the native library (strace does not show any access, and no error is shown even if the library is missing).
I have built the current library version both with OpenJDK 11 and 17. The problem appears on Debian Linux and probably also on Windows (at least we have the same symptoms there).
Is there an initialization step missing to fill the list of ports?
The from CVS inherited README.*, AUTHORS, BeOS, ltconfig, ChangeLog files look outdated to me. Update them to describe/support the new infrastructure. Maybe some of them can be removed.
This is more an information request than an issue, but I can't tell if this Github project is the 'official' RxTx one. Is it?
RxTx wiki says that project use CSV, not Git, and have no link to this repository.
Current README seems to be 'official', but existing forks also share this one.
Project's last version on Maven Central is 2.1.7 (from April 2007).
Any details on current status of the project appreciated.
Support for the ARM soft float (armel) and ARM hard float (armhf) abi targets was added to the build process. However the library loader was not updated yet, because the decission between armel/armhf abi at runtime is not trivial.
There is a discussion about the solution on the raspberry pi forum.
I am getting this JVM crash on OpenJDK 11 when using rxtx on Windows 10
COMPortTracer listening on 'COM4' with baudRate '9600', databits: '8', stopbits: '1', parity: '0', sleeptime: '300', flowControlMode: '-1'...
WARNING: RXTX Version mismatch
Jar version = RXTX-2.2pre1
native lib Version = RXTX-2.2pre2
COMPortReceiver COM4 START at 2020-05-13 07:33:49, baud:9600, sleep:300...
Mai 13, 2020 7:33:49 VORM. org.nuveon.device.port.COMPortReceiver run
INFORMATION: COMPortReceiver COM4 START at 2020-05-13 07:33:49, baud:9600, sleep:300...
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000000180003990, pid=12268, tid=5824
#
# JRE version: OpenJDK Runtime Environment (11.0.7+10) (build 11.0.7+10)
# Java VM: OpenJDK 64-Bit Server VM (11.0.7+10, mixed mode, tiered, compressed oops, g1 gc, windows-amd64)
# Problematic frame:
# C [rxtxSerial.dll+0x3990]
#
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\home\wiki\device\hs_err_pid12268.log
#
# If you would like to submit a bug report, please visit:
# https://github.com/AdoptOpenJDK/openjdk-support/issues
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
BraysTerminal seems to have no problems reading the values
Here's the code i am using (Snippet)
byte[] buffer = new byte[1024];
int len = -1;
InputStream in = m_serialPort.getInputStream();
while (!Thread.currentThread().isInterrupted() && m_run) {
if ((in.available()) > 0) {
len = in.read(buffer);
if (len > -1)
{
// only notify observers if there is something in the buffer
if (len > 0) {
String codeBuffer = new String(buffer, 0, len);
this.notifyObservers(codeBuffer);
}
}
}
Thread.sleep(m_sleeptime);
}
Using https://github.com/Fazecast/jSerialComm it works fine.
I discovered your project when looking for examples of JNI building on windows.
However, I notice that https://github.com/rxtx/rxtx/blob/development/rxtxSerial-windows-x86_64/pom.xml is using OS=Linux. Is this correct?
BTW, you might be interested in my JNI loader, which I intend to package in a zero-dependency standalone project shortly https://github.com/fommil/netlib-java/blob/master/native_ref/java/src/main/java/com/github/fommil/jni/JniLoader.java
I have a weird issue when building. On my normal machine, mvn compile runs cleanly. On another machine that I recently set up, mvn compile exits with the following output:
[ERROR] Failed to execute goal on project librxtxSerial-linux-x86_64: Could not resolve dependencies for project gnu.io.rxtx:librxtxSerial-linux-x86_64:so:2.2-stabilize-SNAPSHOT: Could not find artifact gnu.io.rxtx:rxtxSerial-native:zip:sources:2.2-stabilize-SNAPSHOT -> [Help 1]
I don't know what I'm doing differently here. On a third machine (installed as a VM) I have the same problem.
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000000180005b00, pid=10380, tid=0x0000000000002524
#
# JRE version: Java(TM) SE Runtime Environment (8.0_291-b10) (build 1.8.0_291-b10)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.291-b10 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C [rxtxSerial.dll+0x5b00]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\RFID_Based_SmartShoppingSystem\hs_err_pid10380.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Process finished with exit code 1
Currently the maven project containing the cross toolchain wrapper scripts is loaded on every build -- also on NON cross builds.
The wrapper scripts should only be installed when a cross platform build is taking place to speed up the build (especially useful for the raspberry pi).
Apr. 11, 2021 6:31:12 PM gnu.io.LibraryLoader determineOsClass INFO: The os.name value Windows 10 is unknown. Please file a bug. Apr. 11, 2021 6:31:12 PM gnu.io.LibraryLoader load SEVERE: Unknown operating system! Can't resolve library name Exception in thread "AWT-EventQueue-0"
If the sender device has RTS/CTS enabled, no data is received on win64.
The data can be received with the same code on linux 64bit, or on win32 with the rxtx lib version 2.1.7.
When i execute mvn -Pwith-windows-x86_64 install, i get this error:
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Unknown packaging: dll @ line 6, column 17
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project gnu.io.rxtx:rxtxSerial-windows-x86_64:2.2-stabilize-SNAPSHOT (C:\Users\jguardiolag\rxtx\rxtxSerial-windows-x86_64\pom.xml) has 1 error
[ERROR] Unknown packaging: dll @ line 6, column 17
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
This is the line that throws that error:
I have tested by executing mvn -Pwith-windows-x86_64 compile as well as mvn -Pwith-windows-x86_64 clean install.
I would like to say that i am executing those commands from rxtx parent directory.
@alibabashack
tried to compile it on my Debian machine with openJDK11 ... I used latest version from development branch.
Does not work:
$ mvn -Pwith-linux-x86_64 clean install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] RXTX parent POM [pom]
[INFO] RXTX API [jar]
[INFO] rxtxSerial java [jar]
[INFO] rxtxSerial native [pom]
[INFO] [linux/x86_64] rxtxSerial [so]
[INFO] rxtxSerial binaries [pom]
[INFO] RXTX default serial driver [pom]
[INFO] rxtxSerial integration tests [jar]
[INFO]
[INFO] ----------------------< gnu.io.rxtx:rxtx-parent >-----------------------
[INFO] Building RXTX parent POM 2.2-stabilize-SNAPSHOT [1/8]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ rxtx-parent ---
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ rxtx-parent ---
[INFO] Installing /home/d463/dev/rxtx/pom.xml to /home/d463/.m2/repository/gnu/io/rxtx/rxtx-parent/2.2-stabilize-SNAPSHOT/rxtx-parent-2.2-stabilize-SNAPSHOT.pom
[INFO]
[INFO] ------------------------< gnu.io.rxtx:rxtx-api >------------------------
[INFO] Building RXTX API 2.2-stabilize-SNAPSHOT [2/8]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ rxtx-api ---
[INFO] Deleting /home/d463/dev/rxtx/rxtx-api/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ rxtx-api ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/d463/dev/rxtx/rxtx-api/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ rxtx-api ---
[INFO] Compiling 16 source files to /home/d463/dev/rxtx/rxtx-api/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ rxtx-api ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/d463/dev/rxtx/rxtx-api/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ rxtx-api ---
[INFO] Compiling 1 source file to /home/d463/dev/rxtx/rxtx-api/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ rxtx-api ---
[INFO] Surefire report directory: /home/d463/dev/rxtx/rxtx-api/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running gnu.io.DriverManagerTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.012 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ rxtx-api ---
[INFO] Building jar: /home/d463/dev/rxtx/rxtx-api/target/rxtx-api-2.2-stabilize-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ rxtx-api ---
[INFO] Installing /home/d463/dev/rxtx/rxtx-api/target/rxtx-api-2.2-stabilize-SNAPSHOT.jar to /home/d463/.m2/repository/gnu/io/rxtx/rxtx-api/2.2-stabilize-SNAPSHOT/rxtx-api-2.2-stabilize-SNAPSHOT.jar
[INFO] Installing /home/d463/dev/rxtx/rxtx-api/pom.xml to /home/d463/.m2/repository/gnu/io/rxtx/rxtx-api/2.2-stabilize-SNAPSHOT/rxtx-api-2.2-stabilize-SNAPSHOT.pom
[INFO]
[INFO] --------------------< gnu.io.rxtx:rxtxSerial-java >---------------------
[INFO] Building rxtxSerial java 2.2-stabilize-SNAPSHOT [3/8]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ rxtxSerial-java ---
[INFO] Deleting /home/d463/dev/rxtx/rxtxSerial-java/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ rxtxSerial-java ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ rxtxSerial-java ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to /home/d463/dev/rxtx/rxtxSerial-java/target/classes
[INFO] /home/d463/dev/rxtx/rxtxSerial-java/src/main/java/gnu/io/impl/serial/RXTXPort.java: /home/d463/dev/rxtx/rxtxSerial-java/src/main/java/gnu/io/impl/serial/RXTXPort.java uses or overrides a deprecated API.
[INFO] /home/d463/dev/rxtx/rxtxSerial-java/src/main/java/gnu/io/impl/serial/RXTXPort.java: Recompile with -Xlint:deprecation for details.
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ rxtxSerial-java ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/d463/dev/rxtx/rxtxSerial-java/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ rxtxSerial-java ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ rxtxSerial-java ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ rxtxSerial-java ---
[INFO] Building jar: /home/d463/dev/rxtx/rxtxSerial-java/target/rxtxSerial-java-2.2-stabilize-SNAPSHOT.jar
[INFO]
[INFO] --- maven-assembly-plugin:3.3.0:single (jni-header-assembly) @ rxtxSerial-java ---
[INFO] Reading assembly descriptor: src/assemble/src.xml
[INFO] Building zip: /home/d463/dev/rxtx/rxtxSerial-java/target/rxtxSerial-java-2.2-stabilize-SNAPSHOT-jni-headers.zip
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ rxtxSerial-java ---
[INFO] Installing /home/d463/dev/rxtx/rxtxSerial-java/target/rxtxSerial-java-2.2-stabilize-SNAPSHOT.jar to /home/d463/.m2/repository/gnu/io/rxtx/rxtxSerial-java/2.2-stabilize-SNAPSHOT/rxtxSerial-java-2.2-stabilize-SNAPSHOT.jar
[INFO] Installing /home/d463/dev/rxtx/rxtxSerial-java/pom.xml to /home/d463/.m2/repository/gnu/io/rxtx/rxtxSerial-java/2.2-stabilize-SNAPSHOT/rxtxSerial-java-2.2-stabilize-SNAPSHOT.pom
[INFO] Installing /home/d463/dev/rxtx/rxtxSerial-java/target/rxtxSerial-java-2.2-stabilize-SNAPSHOT-jni-headers.zip to /home/d463/.m2/repository/gnu/io/rxtx/rxtxSerial-java/2.2-stabilize-SNAPSHOT/rxtxSerial-java-2.2-stabilize-SNAPSHOT-jni-headers.zip
[INFO]
[INFO] -------------------< gnu.io.rxtx:rxtxSerial-native >--------------------
[INFO] Building rxtxSerial native 2.2-stabilize-SNAPSHOT [4/8]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ rxtxSerial-native ---
[INFO] Deleting /home/d463/dev/rxtx/rxtxSerial-native/target
[INFO]
[INFO] --- maven-assembly-plugin:3.3.0:single (source-assembly) @ rxtxSerial-native ---
[INFO] Reading assembly descriptor: src/assemble/src.xml
[INFO] Building zip: /home/d463/dev/rxtx/rxtxSerial-native/target/rxtxSerial-native-2.2-stabilize-SNAPSHOT-sources.zip
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ rxtxSerial-native ---
[INFO] Installing /home/d463/dev/rxtx/rxtxSerial-native/pom.xml to /home/d463/.m2/repository/gnu/io/rxtx/rxtxSerial-native/2.2-stabilize-SNAPSHOT/rxtxSerial-native-2.2-stabilize-SNAPSHOT.pom
[INFO] Installing /home/d463/dev/rxtx/rxtxSerial-native/target/rxtxSerial-native-2.2-stabilize-SNAPSHOT-sources.zip to /home/d463/.m2/repository/gnu/io/rxtx/rxtxSerial-native/2.2-stabilize-SNAPSHOT/rxtxSerial-native-2.2-stabilize-SNAPSHOT-sources.zip
[INFO]
[INFO] ---------------< gnu.io.rxtx:librxtxSerial-linux-x86_64 >---------------
[INFO] Building [linux/x86_64] rxtxSerial 2.2-stabilize-SNAPSHOT [5/8]
[INFO] ---------------------------------[ so ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ librxtxSerial-linux-x86_64 ---
[INFO] Deleting /home/d463/dev/rxtx/rxtxSerial-linux-x86_64/target
[INFO]
[INFO] --- native-maven-plugin:1.0-alpha-7:initialize (default-initialize) @ librxtxSerial-linux-x86_64 ---
[INFO]
[INFO] --- native-maven-plugin:1.0-alpha-7:unzipinc (default-unzipinc) @ librxtxSerial-linux-x86_64 ---
[INFO]
[INFO] --- native-maven-plugin:1.0-alpha-7:javah (default-javah) @ librxtxSerial-linux-x86_64 ---
[INFO]
[INFO] --- maven-dependency-plugin:2.5.1:unpack (unpack-sources) @ librxtxSerial-linux-x86_64 ---
[INFO] Configured Artifact: gnu.io.rxtx:rxtxSerial-native:sources:2.2-stabilize-SNAPSHOT:zip
[INFO] Unpacking /home/d463/dev/rxtx/rxtxSerial-native/target/rxtxSerial-native-2.2-stabilize-SNAPSHOT-sources.zip to /home/d463/dev/rxtx/rxtxSerial-linux-x86_64/target/extracted-c with includes "" and excludes ""
[INFO]
[INFO] --- maven-dependency-plugin:2.5.1:unpack (unpack-jni-headers) @ librxtxSerial-linux-x86_64 ---
[INFO] Configured Artifact: gnu.io.rxtx:rxtxSerial-java:jni-headers:2.2-stabilize-SNAPSHOT:zip
[INFO] Unpacking /home/d463/dev/rxtx/rxtxSerial-java/target/rxtxSerial-java-2.2-stabilize-SNAPSHOT-jni-headers.zip to /home/d463/dev/rxtx/rxtxSerial-linux-x86_64/target/jni-headers with includes "" and excludes ""
[INFO]
[INFO] --- native-maven-plugin:1.0-alpha-7:compile (default-compile) @ librxtxSerial-linux-x86_64 ---
[INFO] /bin/sh -c cd /home/d463/dev/rxtx/rxtxSerial-linux-x86_64 && gcc -DHAVE_TERMIOS_H -DHAVE_STDINT_H -DHAVE_SYS_FCNTL_H -DHAVE_SYS_SIGNAL_H -shared -fPIC -I/home/d463/dev/rxtx/rxtxSerial-linux-x86_64/target/jni-headers '-I${env.JAVA_HOME}/include' '-I${env.JAVA_HOME}/include/linux' -I/home/d463/dev/rxtx/rxtxSerial-linux-x86_64/target/extracted-c -o /home/d463/dev/rxtx/rxtxSerial-linux-x86_64/target/objs/SerialImp.o -c /home/d463/dev/rxtx/rxtxSerial-linux-x86_64/target/extracted-c/SerialImp.c
In file included from /home/d463/dev/rxtx/rxtxSerial-linux-x86_64/target/extracted-c/SerialImp.c:64:
/home/d463/dev/rxtx/rxtxSerial-linux-x86_64/target/jni-headers/gnu_io_impl_serial_RXTXPort.h:2:10: fatal error: jni.h: Datei oder Verzeichnis nicht gefunden
2 | #include <jni.h>
| ^~~~~~~
compilation terminated.
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for RXTX parent POM 2.2-stabilize-SNAPSHOT:
[INFO]
[INFO] RXTX parent POM .................................... SUCCESS [ 0.112 s]
[INFO] RXTX API ........................................... SUCCESS [ 1.236 s]
[INFO] rxtxSerial java .................................... SUCCESS [ 0.659 s]
[INFO] rxtxSerial native .................................. SUCCESS [ 0.032 s]
[INFO] [linux/x86_64] rxtxSerial .......................... FAILURE [ 0.392 s]
[INFO] rxtxSerial binaries ................................ SKIPPED
[INFO] RXTX default serial driver ......................... SKIPPED
[INFO] rxtxSerial integration tests ....................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.790 s
[INFO] Finished at: 2021-07-01T16:26:00+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:native-maven-plugin:1.0-alpha-7:compile (default-compile) on project librxtxSerial-linux-x86_64: Error executing command line. Exit code:1 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <args> -rf :librxtxSerial-linux-x86_64
$
Thought its caused by missing JAVA_HOME, so I ensured JAVA_HOME is available:
$ echo $JAVA_HOME
/usr/lib/jvm/java-11-openjdk-amd64
I also ensured that $JAVA_HOME/include contains the jni.h:
$ find $JAVA_HOME/include
/usr/lib/jvm/java-11-openjdk-amd64/include
/usr/lib/jvm/java-11-openjdk-amd64/include/jvmticmlr.h
/usr/lib/jvm/java-11-openjdk-amd64/include/linux
/usr/lib/jvm/java-11-openjdk-amd64/include/linux/jni_md.h
/usr/lib/jvm/java-11-openjdk-amd64/include/linux/jawt_md.h
/usr/lib/jvm/java-11-openjdk-amd64/include/jawt.h
/usr/lib/jvm/java-11-openjdk-amd64/include/classfile_constants.h
/usr/lib/jvm/java-11-openjdk-amd64/include/jni.h
/usr/lib/jvm/java-11-openjdk-amd64/include/jdwpTransport.h
/usr/lib/jvm/java-11-openjdk-amd64/include/jvmti.h
No idea why its not working.
Any ideas so far? What are the prerequisites to build it from scratch?
Hi guys,
Using RxTx 2.1.7 on a simple test case (see below), writing on the output stream works, but also triggers DATA_AVAILABLE on input stream (i.e. output data is also copied on input buffer). Is this the normal behavior, an RxTx bug or an hardware issue?
Test run with Windows X86_64 native driver.
My test code is (RxTx is loaded elsewhere)
public class SerialSocket implements SerialPortEventListener {
private static final Logger LOGGER = LoggerFactory.getLogger(SerialSocket.class);
private static final int BUFFER_SIZE = 1024;
private static final Charset CHARSET = Charset.forName("US-ASCII");
private final BufferedInputStream inputStream;
private final BufferedOutputStream writer;
public SerialSocket(final SerialPort port) throws TooManyListenersException, IOException {
port.addEventListener(this);
port.notifyOnDataAvailable(true);
this.inputStream = new BufferedInputStream(port.getInputStream());
this.writer = new BufferedOutputStream(port.getOutputStream());
}
public void writeString(final String message) throws IOException {
LOGGER.info("Writing new string {}", message);
this.writer.write(message.getBytes(CHARSET));
this.writer.flush();
}
@Override
public void serialEvent(SerialPortEvent event) {
switch (event.getEventType()) {
case SerialPortEvent.DATA_AVAILABLE:
this.processData();
break;
default:
// Do nothing, as it's the last break statement and no other case handled yet.
}
}
private void processData() {
final byte[] readBuffer = new byte[BUFFER_SIZE];
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try {
int readCount;
while ((readCount = this.inputStream.read(readBuffer)) > 0) { // Can't use -1 here, because EOF is never reached, so stop reading when no more data available.
outputStream.write(readBuffer, 0, readCount);
}
LOGGER.info("New incoming data: {}", new String(outputStream.toByteArray(), CHARSET));
} catch (final Exception e) {
LOGGER.error("Exception while reading incoming data: {}", e.getMessage());
}
}
public static void main(final String[] args) throws IllegalAccessException, NoSuchFieldException, IOException, NoSuchPortException, PortInUseException, UnsupportedCommOperationException, TooManyListenersException {
final String portName = args[0];
final int baudrate = Integer.parseInt(args[1]);
final SerialPort serialPort = SerialPortProvider.getSerialPort("RxTx Test Application", portName, baudrate);
LOGGER.info("Serial port type is {}", serialPort.getClass().getSimpleName());
final SerialSocket socket = new SerialSocket(serialPort);
socket.writeString("Test");
}
}
Output is
[main] INFO SerialSocket - Serial port type is RXTXPort
[main] INFO SerialSocket - Writing new string Test
[Thread-0] INFO SerialSocket - New incoming data: Test
Thanks in advance!
I am currently implementing a release workflow for rxtx. In order to efficiently derive the required semantic version for maven packaging from git tags, I want to use jgitver-maven-plugin.
Since jgitver analyzes the whole git history (especially git tags), a working configuration cannot be demonstrated on a single feature branch. Hence I experimented within my fork.
There is still an issue with release naming I could not fix and I opened an upstream ticket:
jgitver/jgitver-maven-plugin#169
I am using a call to CommPortIdentifier.getPortIdentifiers()
to get a list of com ports while my application starts.
When the application is running I connect or disconnect hardware so that there is one new com port available or gets removed. If I can the getPortIdentifiers
method, these changes are not reflected in the enumeration. It looks like a cached version of the com port list.
Is there a way to reload the list? Restarting the app is somewhat a dirty workaround I think.
Is RxTx Dead?
I am working on a Java project with rxtx enabled to communicate to a device via the COM port.
On Windows 10 everything is working fine. On Windows 11 I get the following error:
März 03, 2022 3:09:23 PM gnu.io.LibraryLoader determineOsClass
INFORMATION: The os.name value Windows 11 is unknown. Please file a bug.
März 03, 2022 3:09:23 PM gnu.io.LibraryLoader load
This is understandable, because Windows 11 is not checked for in rxtx-api\src\main\java\gnu\io\LibraryLoader.java.
I try to create a PR to fix this.
I believe I heard it is no longer state of the art to have a detached gh-pages branch within the same repository. Is this correct? If yes, we should move gh-pages to comply. Do you know about this? Any input welcome.
I have an application that needs to connect to a com with name "/dev/tty_dgrp_1_0" This is a remote device generated with the help of the Digi RealPort technology that emulates a com port.
I know there is a work around to force odd named port but why is this API doing any filtering? If we give it a specific a port, it should attempt to connect.
Hi world
I recently tried to install and use the RXTX lib in my Java project. I found at first the Maven control page and used it to install the lib in my pom.xml as follow:
<dependencies>
<dependency>
<groupId>dev.prokop.rxtx</groupId>
<artifactId>rxtx</artifactId>
<version>2.2.2</version>
</dependency>
</dependencies>
and then created a simple class with a main() method calling java.util.Enumeration<CommPortIdentifier> portEnum = CommPortIdentifier.getPortIdentifiers();
.
The build and installation work fine, no error in my IDE, but on runtime I get the following error:
juil. 28, 2021 4:08:56 PM gnu.io.RXTXInitializer provideNativeLibraries
INFOS: Native library rxtxSerial-amd64.so already exists at /tmp/rxtxSerial-amd64-2.2.2.so
juil. 28, 2021 4:08:57 PM gnu.io.RXTXInitializer <clinit>
INFOS: Native lib Version = RXTX-2.2-20081207 Cloudhopper Build rxtx.cloudhopper.net
juil. 28, 2021 4:08:57 PM gnu.io.RXTXInitializer <clinit>
INFOS: Java lib Version = RXTX-2.2-20081207 Cloudhopper Build rxtx.cloudhopper.net
java.lang.NullPointerException thrown while loading gnu.io.RXTXCommDriver
java.lang.NullPointerException thrown while loading gnu.io.RXTXCommDriver
I read a bit about that error and mostly found unrelated comments about an outdated Arduino IDE (which I don't use at all) before falling here. I saw something in #23 saying that the issue got fixed but... either I didn't install the lib correctly, or there's still something wrong :/
Here are the debug info asked by your doc:
$ which java
/lib/jvm/java-14-openjdk-amd64/bin/java
$ java -version
openjdk version "14.0.2" 2020-07-14
OpenJDK Runtime Environment (build 14.0.2+12-Ubuntu-120.04)
OpenJDK 64-Bit Server VM (build 14.0.2+12-Ubuntu-120.04, mixed mode, sharing)
$ uname -a
Linux temma-bmax 5.8.0-63-generic #71~20.04.1-Ubuntu SMP Thu Jul 15 17:46:08 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
$ make -version
GNU Make 4.2.1
Construit pour x86_64-pc-linux-gnu (ye I'm French)
If you need anything else, just tell me!
PS: I'm still a java newbie and not really used to maven yet, so any good tutorial/comments/explanation/help will be greatly appreciated 💚
We still need a working Continuous Integration and Delivery Pipeline. I think this is not trivial, because rxtx is neither a pure Java nor a pure C project. Since we use maven to build Java and C parts and even perform cross platform builds to problematic platforms (hallo apple!), I am not sure if there exists an off-the-shelf solution.
Dear CI/CD heads, Github Actions hackers, Jenkins wizards, we do need your input. Any idea what fits best for our scenario? It certainly would be nice if we can make this happen without own infrastructure.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.