GithubHelp home page GithubHelp logo

neuronrobotics / nrjavaserial Goto Github PK

View Code? Open in Web Editor NEW
344.0 42.0 143.0 8.27 MB

A Java Serial Port system. This is a fork of the RXTX project that uses in jar loading of the native code.

License: Other

Makefile 2.65% C 43.17% Java 54.18%

nrjavaserial's Introduction

About

Financial Contributors on Open Collective Join the chat at https://gitter.im/NeuronRobotics/nrjavaserial Maven Central Build License

This is a fork of the RXTX library with a focus on ease of use and embeddability in other libraries.

Some of the features we have added

  • A simplified serial port object called NRSerialPort. See below for an example.

  • Self-deployment of native libraries (all native code is stored inside the JAR and deployed at runtime). No more manual installation of native code.

  • Arm Cortex support (Gumstix).

  • Android (3.x or lower, requires a rooted phone to access the serial hardware).

    This feature is depricated by changes in Android permissions moving forward with 4.x

  • Single Makefile compile which simplifies the compilation of project binaries.

  • Gradle support for JAR creation.

  • Removal of partially-implemented RXTX code to streamline the library for just serial port access.

  • Full Eclipse integration for testing application code against sources.

  • RFC 2217 support provided by incorporating the jvser library.

  • RS485 support for Linux

And a bunch of bug fixes

  • Fixed the memory access error that causes OS X to crash the JVM when serial.close() is called.

  • Fixed the Windows serial port zombie bind that prevents re-accessing serial ports when exiting on an exception.

  • Fixed erroneous printouts of native library mis-match.

Dependency Management

Maven Java 8 and Java 11+

	<dependency>
	  <groupId>com.neuronrobotics</groupId>
	  <artifactId>nrjavaserial</artifactId>
	  <version>5.1.1</version>
	</dependency>

Building the JAR

  1. Checkout the repository.

     $ git clone https://github.com/NeuronRobotics/nrjavaserial.git
    
  2. Build with Gradle.

     $ cd nrjavaserial
     $ ./gradlew build
    

The resulting JAR will be found in the build/libs/ directory.

Building the native libraries

The native libraries are written in C, and are built with Make. The source, including the master makefile, lives in src/main/c. The makefile in the project root will delegate to this makefile, and rebuild the JAR afterwards.

You'll also need a copy of the JNI development headers for your system. The easiest way to get these is to install a copy of the JDK. The headers are located in JAVA_HOME/include. The build process will attempt to automatically determine the location of your Java installation; however, to ensure a predictable build process, you should set the JAVA_HOME environment variable to the path of your Java installation directory.

# Install cross-compilation toolchains for all of the supported Linux
# architectures and Windows onto an amd64 Linux build host running
# Debian 10 or a modern derivative.
$ sudo make -C src/main/c crosstools

# Build both the 32- and 64-bit Windows binaries.
$ make windows

# Build Linux binaries for 32- and 64-bit x86, 32-bit ARMv5/v6/v7/v8,
# 64-bit ARMv8, and 32-bit PPC.
$ make linux

# Build only 32- or 64-bit x86 Linux binaries, respectively.
$ make linux32
$ make linux64

# Build binaries for all the supported ARM flavors.
$ make arm

# Build the PPC binaries.
$ make ppc

# Build 64-bit x86 macOS binaries. This requires a macOS build host.
$ make osx

# Build 32- and 64-bit x86 FreeBSD binaries, or just for 32/64-bit,
# respectively. This requires a FreeBSD build host.
$ make freebsd
$ make freebsd32
$ make freebsd64

Building on Windows

You'll need some installation of GCC. We recommend the TDM-GCC distribution of Mingw64-w64. Following its default installation process should result in its bin/ directory being added to your path; if you can pop open a command prompt and run x86_64-w64-mingw32-gcc, you're good to go.

Building on OS X

We're pretty big on maintaining backwards compatibility as far as reasonable. Our OS X natives target OS X 10.5, so to build them, you'll need an appropriate SDK installed. This StackOverflow answer provides pointers for getting the appropriate SDK installed.

How to use NRSerialPort objects

import gnu.io.NRSerialPort;
String port = "";
for(String s:NRSerialPort.getAvailableSerialPorts()){
	System.out.println("Availible port: "+s);
	port=s;
}

int baudRate = 115200;
NRSerialPort serial = new NRSerialPort(port, baudRate);
serial.connect();

DataInputStream ins = new DataInputStream(serial.getInputStream());
DataOutputStream outs = new DataOutputStream(serial.getOutputStream());
try{
	//while(ins.available()==0 && !Thread.interrupted());// wait for a byte
	while(!Thread.interrupted()) {// read all bytes
		if(ins.available()>0) {
			char b = ins.read();
			//outs.write((byte)b);
			System.out.print(b);
		}
    		Thread.sleep(5);
	}
}catch(Exception ex){
	ex.printStackTrace();
}
serial.disconnect();

Contributors

Code Contributors

This project exists thanks to all the people who contribute. [Contribute].

Financial Contributors

Become a financial contributor and help us sustain our community. [Contribute]

Individuals

Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]

nrjavaserial's People

Contributors

50watt avatar afernandezmlt avatar akuhtz avatar bobbrez avatar bparees avatar crea-doo avatar cxbrooks avatar david-pace avatar earcam avatar fwolter avatar gitter-badger avatar jaghatei avatar kaikreuzer avatar leif81 avatar luca-domenichini avatar madhephaestus avatar mnlipp avatar monkeywithacupcake avatar mores avatar mrdos avatar msteigenberger avatar rafallukawiecki avatar rallymen007 avatar riedlse avatar siepkes avatar wborn avatar weslleymfd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nrjavaserial's Issues

nrjavaserial-3.9.2 fails on RHEL 5.8 (Tikanga) 64-bit

Trying to use nrjavaserial-3.9.2 on a Redhat Enterprise Linux 5.8 machine (64-bit), we see this:
...
java.lang.UnsatisfiedLinkError: /tmp/libNRJavaSerial_uwe_0/libNRJavaSerial.so: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /tmp/libNRJavaSerial_uwe_0/libNRJavaSerial.so)
...
Which makes me wonder ... on what machine(s) is nrjavaserial compiled, and by whom ? I tried building myself on the RHEL 5.8 machine and the native build seems good but the Java part fails with compile errors ("annotations are only available if source level is 5.0"). I'm willing to help, but an incomplete build leaves me a bit unsure ...

Update Gradle build to use C dir for artifacts

The gradle build can be modified to point to a specific directory for its 'resources'. We should point it at the directory where the C compile places the artifacts so no symlinks or anything like that is needed.

Arm64 v8hf support

I didn't see an issue that called this out in particular, but is there any plan to support the new 64bit ARM v8 cpus? The Odroid C2 sports this CPU and is in the wild (I have one). If I understand correctly, the Pine64 that just started shipping is also of this arch. OpenHAB uses nrjavaserial and as such cannot support (without some tinkering) serial devices on these new cpus. They currently try to load the 32 bit library, and fail.

libNRJavaSerial.so: wrong ELF class: ELFCLASS32 (Possible cause: can't load IA 32-bit .so on a ARM-bit platform)

uname -a
Linux odroid64 3.14.29-29 #1 SMP PREEMPT Fri Feb 26 11:00:53 BRT 2016 aarch64 aarch64 aarch64 GNU/Linux

specs here: http://www.hardkernel.com/main/products/prdt_info.php

Other mention of ARM64 here: #51

no rxtxSerial in java.library.path thrown while loading gnu.io.RXTXCommDriver

Hello everyone:

I use the nrjavaserial-3.9.3.jar file in an Eclipse project and I get the following error message:

java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path thrown while loading gnu.io.RXTXCommDriver
Port: COM7
java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at gnu.io.CommPortIdentifier.(CommPortIdentifier.java:123)
at ch.ntb.inf.repower.TwoWaySerialComm.main(TwoWaySerialComm.java:102)
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class gnu.io.CommPortIdentifier
at ch.ntb.inf.repower.TwoWaySerialComm.connect(TwoWaySerialComm.java:18)
at ch.ntb.inf.repower.TwoWaySerialComm.main(TwoWaySerialComm.java:114)

What do I have to do to resolve this error?

Rene

Release compiled with lower version of JDK (1.5)

Would it be possible to make next release with 1.5 version of Java? My application is still on 1.5, since we want to support also older (especially Mac) models. Does nrjavaserial code contain anything that requires Java 1.7? Or even 1.6?

Not listing serial ports even though there's a plenty of them

Hi, I was testing this lib on my computer (linux amd 64) to maybe replace the one that I daily use (RXTX) and I did a small example to list all the serial ports on my computer as:

package com.serialtest;

import gnu.io.NRSerialPort;

public class Main {

    public static void main(String[] args) {
        for(String s: NRSerialPort.getAvailableSerialPorts()) {
            System.out.println("Availible port(s): " + s);
        }
    }
}

But, though I have a lot of serial ports, as seen in:

[ranu@ranu-laptop ~]$ ls -l /dev/ttyS*
crw-rw---- 1 root dialout 4, 64 Jun  3 07:15 /dev/ttyS0
crw-rw---- 1 root dialout 4, 65 Jun  3 07:15 /dev/ttyS1
crw-rw---- 1 root dialout 4, 74 Jun  3 07:15 /dev/ttyS10
crw-rw---- 1 root dialout 4, 75 Jun  3 07:15 /dev/ttyS11
crw-rw---- 1 root dialout 4, 76 Jun  3 07:15 /dev/ttyS12
crw-rw---- 1 root dialout 4, 77 Jun  3 07:15 /dev/ttyS13
crw-rw---- 1 root dialout 4, 78 Jun  3 07:15 /dev/ttyS14
crw-rw---- 1 root dialout 4, 79 Jun  3 07:15 /dev/ttyS15
crw-rw---- 1 root dialout 4, 80 Jun  3 07:15 /dev/ttyS16
crw-rw---- 1 root dialout 4, 81 Jun  3 07:15 /dev/ttyS17
crw-rw---- 1 root dialout 4, 82 Jun  3 07:15 /dev/ttyS18
crw-rw---- 1 root dialout 4, 83 Jun  3 07:15 /dev/ttyS19
crw-rw---- 1 root dialout 4, 66 Jun  3 07:15 /dev/ttyS2
crw-rw---- 1 root dialout 4, 84 Jun  3 07:15 /dev/ttyS20
crw-rw---- 1 root dialout 4, 85 Jun  3 07:15 /dev/ttyS21
crw-rw---- 1 root dialout 4, 86 Jun  3 07:15 /dev/ttyS22
crw-rw---- 1 root dialout 4, 87 Jun  3 07:15 /dev/ttyS23
crw-rw---- 1 root dialout 4, 88 Jun  3 07:15 /dev/ttyS24
crw-rw---- 1 root dialout 4, 89 Jun  3 07:15 /dev/ttyS25
crw-rw---- 1 root dialout 4, 90 Jun  3 07:15 /dev/ttyS26
crw-rw---- 1 root dialout 4, 91 Jun  3 07:15 /dev/ttyS27
crw-rw---- 1 root dialout 4, 92 Jun  3 07:15 /dev/ttyS28
crw-rw---- 1 root dialout 4, 93 Jun  3 07:15 /dev/ttyS29
crw-rw---- 1 root dialout 4, 67 Jun  3 07:15 /dev/ttyS3
crw-rw---- 1 root dialout 4, 94 Jun  3 07:15 /dev/ttyS30
crw-rw---- 1 root dialout 4, 95 Jun  3 07:15 /dev/ttyS31
crw-rw---- 1 root dialout 4, 68 Jun  3 07:15 /dev/ttyS4
crw-rw---- 1 root dialout 4, 69 Jun  3 07:15 /dev/ttyS5
crw-rw---- 1 root dialout 4, 70 Jun  3 07:15 /dev/ttyS6
crw-rw---- 1 root dialout 4, 71 Jun  3 07:15 /dev/ttyS7
crw-rw---- 1 root dialout 4, 72 Jun  3 07:15 /dev/ttyS8
crw-rw---- 1 root dialout 4, 73 Jun  3 07:15 /dev/ttyS9

It lists no ports! I tested on a Windows machine and it does display a single serial port COM1, so I assumed that the problem may be in my computer, do you guys have any idea of what might be the problem?

Duplicated ressource in distribution jar

Some files (in meta-inf folder) are duplicated. When we want to use this library in a applet way, our JRE raise an exception because "LICENSE.txt" entry is duplicated in JAR file (this is not the single file).

What is the point of the โ€œlegacyโ€ native libraries?

The native resources include a whole bunch of libraries with โ€œ_legacyโ€ in their names. What was the intent of these? Are they the original binaries imported from RXTX? The Makefile doesn't give any indication of how they're built, which makes me suspect they're more older versions than alternatives.

Which is the main source directory now?

As of f240847, the source directory seems to be src, not nrjavaserial/src. But 14493a8 was accepted as a change to nrjavaserial/src, and the Ant and Maven build files are still in the nrjavaserial directory. I can create a pull request to clean this up, but which do we want to use going forward: src or nrjavaserial/src?

Exception in thread "main" java.lang.NoClassDefFoundError rxtx

Hello Dude!!!

Iโ€™m using this code and Iโ€™m trying to use it to start RXTX with Arduino. I get the following compile errors:
C:\Users\cwc\java>java SerialTest.java
Exception in thread โ€œmainโ€ java.lang.NoClassDefFoundError: SerialTest/java
Caused by: java.lang.ClassNotFoundException: SerialTest.java
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: SerialTest.java. Program will exit.
I followed these directions:
Windows 64-bit
RXTXcomm.jar goes in \jre\lib\ext
rxtxSerial.dll goes in \jre\bin
Please any body help!!!!!

read method behavior win/linux

Hello,

I notice a different behavior between Windows (>= xp) and Linux :

int value = input.read();
while ((value & 0xFF) != ENQ) {
  System.out.println("Waiting....");
  value = input.read();
}

Under Windows, I can read message "Waiting" until ENQ code was reached. Under Linux, my code is stuck on the first input.read() call. In my real usecase, I use this loop to reach a lapse of time before throwing a TimeoutException.

Is it possible to have the same behavior between Windows & Linux ?

Error 0x1 at src/windows/termios.c(512 or 2725): Fonction incorrecte.

Hello,

I'm using version 3.11.0 to create a java program which talk through a serial port.
When my computer goes to sleep with an open connection, i have a lot of times the same errors in the console:
Error 0x1 at src/windows/termios.c(512): Fonction incorrecte.
Error 0x1 at src/windows/termios.c(2725): Fonction incorrecte.

which seems to be something like that one : http://marc.info/?l=rxtx&m=125310032820956&w=2

I use the following code to get all present serial port:
public List getAllAvailablePorts() {
final List res = new ArrayList<>();
final Enumeration portEnum = CommPortIdentifier.getPortIdentifiers();
while (portEnum.hasMoreElements()) {
final CommPortIdentifier portIdentifier = portEnum.nextElement();
if (portIdentifier.getPortType() == CommPortIdentifier.PORT_SERIAL) {
res.add(portIdentifier);
}
}
return res;
}

And this code for the connection:
final CommPort commPort = selectedPortIdentifier.open("TrBusValidationPanel", TIMEOUT); // 50 ms
//the CommPort object can be casted to a SerialPort object
serialPort = (SerialPort) commPort;
serialPort.setSerialPortParams(38400, 8, 1, 0); // 8 data bit, 1 stop, no parity @ 38400

After I just wait for my computer to go to sleep and I wake it up from standby.

250000 baud is rejected as an invalid baudrate

This is a valid baud for 3d printers and should not be rejected. In fact most baud rates could be valid given strange microcontroller configurations. The rejection of invalid baud rates makes too many assumptions and should be eliminated.

Installation instructions?

I'm trying to get nrjavaserial up and running on Windows10 but am not having much luck.
Is there any special install routine that is required or is it enough to include the nrjavaserial.jar in the classpath?

The following app completes without finding any serial ports.

public class App {
    public static void main(String[] args) throws IOException {
        for(String s: NRSerialPort.getAvailableSerialPorts()){
            System.out.println("Available port: "+s);
        }
    }
}

NRSerialPort should make RXTX port instance accessible to user

Hi !
I started using nrjavaserial instead of vanilla Rxtx... I really like using NRSerialPort because it makes Rxtx easy usable (without need to set parameters, which are use default values), but for some devices I use, option to set specific values would be very welcome.
If user could access underlaying RXTX instance this wouldnรถรคt be a problem, but so far we donรคt have that option. Would it be possible to get this instance directly, or if you could implement needed methods:

  • enableReceiveTimeout
  • setSerialPortParams
  • setDTR
  • setRTS

I use a lot of serial devices in my application and about 90% are covered with default settings, but some require extra settings...

Take care,
Andy

Get Gradle to build with Java 1.5 compatibility

#21 asked us to compile for Java 1.5, and we've maintained that between then and now (I think). However, Gradle doesn't run on Java 1.5 โ€“ it has a minimum of 1.6. Before we build a new JAR for the 3.12.0 release, we need to figure out the configuration required to get Gradle to target 1.5 from a 1.6 compiler, or to get Gradle to invoke a 1.5 javac when running under 1.6.

gradle build error on jcenter() method not found

I commented that line out of the build.gradle file and it appeared to work then, but I fear I have probably just ended up with an incomplete library.

ab4mw@shack:~/src/nrjavaserial$ gradle --info build
Starting Build
Settings evaluated using empty settings script.
Projects loaded. Root project using build file '/home/ab4mw/src/nrjavaserial/build.gradle'.
Included projects: [root project 'nrjavaserial']
Evaluating root project 'nrjavaserial' using build file '/home/ab4mw/src/nrjavaserial/build.gradle'.

FAILURE: Build failed with an exception.

* Where:
Build file '/home/ab4mw/src/nrjavaserial/build.gradle' line: 41

* What went wrong:
A problem occurred evaluating root project 'nrjavaserial'.
> Could not find method jcenter() for arguments [] on root project 'nrjavaserial'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.

BUILD FAILED

Total time: 5.408 secs

Better build infrastructure

In light of the number of issues that have to do with binaries (#3, #8, #14, #17), I'd like to set up a publicly-accessible build server which periodically fetches the latest source and builds Linux, Windows, and possibly MacOS X natives, builds the Java source, and puts them all in a jar. @madhephaestus, as the man in charge, would you have any objection to this?

Available bytes are not readable

Hi,

we use nrjavaserial (3.11.0) in our AT command framework jModuleConnect. But now we have an issue with reading in a obscure constellation. After a while of running without problems occurs following issue. The method available() of SerialInputStream delivers 9 or more bytes are available but the following read(byte[], int, int) delivers 0. After that its impossible to remove the bytes from available() neither read(byte[], int, int) or skip(int) will remove the count from available(). And the read delivers only 0 or -1.

We can reproduce the issue easy but at the moment only with a big project application. With a minimal test app was not reproducable at the moment. The only think that was anyway identical, that was the position in buffer at reading (1024 966 58 from nrjavaserial debug). The problem occurs every on this buffer position. The buffer has an size of 1024 and cames from BufferedInputStream.

Here are a part of the log:

    sendEvent return
Entering RXTXPort:SerialOutputStream:write(9) 
Leaving RXTXPort:SerialOutputStream:write(9)
RXTXPort:SerialOutputStream:flush() enter
RXTXPort:SerialOutputStream:flush() leave
RXTXPort:sendEvent(
DATA_AVAILABLE true)
    checking flags 
    getting event
    sending event
2016-03-24 16:06:29:676 DEBUG [Thread-6] d.s.j.CommHandlerImpl SE-EVENT
RXTXPort:available() called
RXTXPort:available() returning 9
2016-03-24 16:06:29:691 DEBUG [Thread-6] d.s.j.CommHandlerImpl Check: AtImpl
RXTXPort:available() called
RXTXPort:available() returning 45
2016-03-24 16:06:29:704 INFO [Thread-6] d.s.j.a.AtImpl Check AT protocol - 0
RXTXPort:available() called
RXTXPort:available() returning 45
RXTXPort:available() called
RXTXPort:available() returning 45
2016-03-24 16:06:29:718 DEBUG [Thread-6] d.s.j.DebugInputStream IN: 45 OUT: 45
RXTXPort:SerialInputStream:read(1024 966 58) called
RXTXPort:SerialInputStream:read(1024 966 58) returned 0 bytes
2016-03-24 16:06:29:734 DEBUG [Thread-6] d.s.j.DebugInputStream Read-Meth: 1024-966-58-0
2016-03-24 16:06:29:738 INFO [Thread-6] d.s.j.a.AtImpl Test skip
RXTXPort:available() called
RXTXPort:available() returning 45
RXTXPort:available() called
RXTXPort:available() returning 45
RXTXPort:available() called
RXTXPort:available() returning 45
2016-03-24 16:06:29:759 DEBUG [Thread-6] d.s.j.DebugInputStream IN: 45 OUT: 45
RXTXPort:SerialInputStream:read(1024 966 58) called
RXTXPort:SerialInputStream:read(1024 966 58) returned 0 bytes
2016-03-24 16:06:29:773 DEBUG [Thread-6] d.s.j.DebugInputStream Read-Meth: 1024-966-58-0

I have no idea is an bug in nrjavaserial or and usage mistake of us...

Incompatibility with older "RxTx" library

Hello,

I'm new here but I would like to ask you for support. I would like to use "nrjavaserial" instead of the older RxTx 2.1.7 library, unfortunately there are differences in the interface. The first I have met is following difference in class "gnu.io.CommPortIdentifier":

RxTx:
public synchronized CommPort open(String paramString, int paramInt) throws PortInUseException;

NRJavaSerial
public RXTXPort open(String TheOwner, int i) throws PortInUseException;

Class "RXTXPort" extends the abstract class "CommPort" but unfortunately the exact prototype is required by JRE, so this incompatibility disables simple library replacement. I get the following error when used the NRJavaSerial library and called this "open(String, int)" method in code compiled with RxTx library:

java.lang.NoSuchMethodError: "gnu.io.CommPortIdentifier.open(Ljava/lang/String;I)Lgnu/io/CommPort;"

Would you be so kind to verify and slightly update the interface so that both these libraries are mutually compatible / replace-able?

I'm sorry if this topic was already discussed here in another thread/issue.

Thank you in advance,
Robert

Unable to read more than 256 ports in Windows

Hello All,

We are using nrjavaSerial-3.8.8 APIs on Windows 64 bit environment with JDK 7 (64 bit). We have a moxa server which can virtually provide around 4096 COMM ports over the network. However, nrjavaseail APIs read only maximum of 256 ports out of total 4096 COMM ports present in the network. Moreover, Java comm APIs available for 32 bit JDK by Oracle, provides this support and it shows all the 4096 COMM ports available.

Could you please explain/confirm, if its possible to read more than 256 COMM ports using nrJavaSerial APIs?

Your help is highly appreciated as we are struggling with it for last few days.

Thanks
Sandeep Wadhwa
Application Architect
+918860850650

Compile for MIPs Architecture

Hello, I have been unsuccessfully trying to compile for MIPS architecture.
I actually know very little C / Makefiles.

The goal is to generate a lib for OpenWRT

The guide we got was normal compile codes:
http://www.componentality.com/res/Step-By-Step-Instruction-To-Run-Apps-On-FlexRoad-HW.en.pdf

I've managed to run inside the router JamVM:
wiki.openwrt.org/toh/tp-link/tl-mr3020

Now we need to get access the serial port.
This can be done with LUA:
http://www.ediy.com.my/index.php/blog/item/40-send-message-to-serial-port-or-router-using-lua

Why not Java?!

Issue receiving data from Arduino Leonardo

Hello,

I am having issues receiving data from the Arduino Leonardo. It sends data without any issues, but never receives anything from it. If I try using the console provided by the Arduino IDE (which also uses RXTX for serial communication), data is received correctly - so the issue is from the library. For example, I'm also connecting to an Arduino Mega, and the communication there is flawless for both send and receive.

I am currently using Windows 64bit. I have read about something, that the Leonardo requires flow control (I'm not an expert in serial communication), but it seems you have already implemented this (in one of the pulls). I am using your latest version of the library, that I have downloaded from this git and then compiled.

Please provide any assistance if you can in resolving this issue because this has halted development on a personal project that I'm working on. Thanks!

Kind regards,
Lorand.

short select() timeout causes MonitorThread CPU consumption

using nrjavaserial-3.8.8, I'm seeing significant CPU consumption on low-end (atom) CPUs due to the RXTX MonitorThread being busy, although no EventListeners are attached to the port.
I believe this is due to the eventLoop() in SerialImp.c having a fairly short timeout on the select() call:

                    do {
            eis.ret = SELECT( eis.fd + 1, &eis.rfds, NULL, NULL,
                &eis.tv_sleep );
        } while (eis.ret < 0 && errno==EINTR);

The eis.tv_sleep is set to only 1000usec in intialise_event_info_struct():

if (eis->fd < FD_SETSIZE && eis->fd > 0) {
    FD_SET( eis->fd, &eis->rfds );
    eis->tv_sleep.tv_sec = 0;
    eis->tv_sleep.tv_usec = 1000;
    eis->initialised = 1;
    return( 1 );
} else {
    // you can reduce this limitation only with migration to epool or something like that.
}

Which should cause the thread to wake up 1000 times per second, although no listener is attached.

Any suggestions on how to fix this?

Detect fifo buffer underrun

Is it possible to detect fifo buffer overflows with this library?

The reason why I'am asking is because of the changes in this issue: #36

I suspect that my OpenHAB server is loosing some ZWave events because of this. Is there a way to check how often the serial port buffer did overflow?

Parallel port

Hello,
The original RXTX library has parallel port support.
Is it possible with nrjavaserial?

ARM library load order might be wrong

I interpret the way the list of ARM libraries is defined in code and how they're iterated over and loaded as preferring the ARMv5 library, then ARMv6HF, ARMv6, ARMv7HF, and finally ARMv7. And if I understand how ARM backwards compatibility works, the ARMv5 library should work fine on later architectures. So I wonder if this code isn't mostly seeing success loading the ARMv5 library and not touching anything else.

@TheNetStriker, you were building ARMv7 โ€“ did you run into any troubles with this?

Error 0x1f at src/windows/termios.c(2360) PortInUse even that it isn't

We are encounter the follow error with any version of nrjavaserial (3.9 up to 2.12.0):
Error 0x1f at src/windows/termios.c(2360): A device attached to the system is n...
which is raised when we open the port. We really checked for sure that the port isn't used by any other application. And other serial programs (not based upon nrjavaserial) can open the port without any problems.
The serial port is a emulated port by the USBCom Driver version 5.23.00 from a datalogic handheld scanner D9530 STD, which seems to be cause for the failure. We know that nrjavaserial and the USBCom Driver can work together from previously projects. But we don't access anymore to an older version of the USBCom driver. Thus is there a way to workaround it in nrjavaserial?

serialPort.getInputStream().read() never returns -1 at end of data on Linux

We are communicating with an external device connected to a serial port. The following code works flawlessly on Windows, but when running on Linux (Suse) it blocks indefinately.

Below is a simplified version of our code with a lot of log-statemens and stuff removed, also the actual handling of the data after the input-stream is closed.

We can see from our logs that on both Windows and Linux exactly the same bytes are read from the InputStream, and buffer.postion is incremented identically on both platforms.

After the final byte is read, on Windows the code moves on to evaluate the if-statement after the while loop (if (buffer.position() != bufPos)) and execute the handling of the received data. But on Linux after the final byte is read nothing more happens. I've added log-statements everywhere to try and see what actually happens, and my only conclusion is that on Linux in.read() blocks indefinately after the final byte is received and never returns -1. Any idea how to remedy this?

public void serialEvent(SerialPortEvent e) {
  int data;
  synchronized(bufferLock) {
    try {
        InputStream in = serialPort.getInputStream();
        int bufPos = buffer.position();

        while ((data = in.read()) > -1) {
                byte b = (byte) data;

                if (buffer.remaining() == 0) {
                    log.warn("Out of buffer space. Doubling buffer size.");
                    int newSize = buffer.capacity() * 2;
                    ByteBuffer newBuffer = ByteBuffer.allocate(newSize);
                    buffer.flip();
                    newBuffer.put(buffer);
                    buffer = newBuffer;
                 }

                buffer.put(b);
        }

        if (buffer.position() != bufPos) {
            // We have added to the buffer
            // Handle the received data
        }
    } catch (IOException ex) {
        log.error("Error reading data.", ex);
        disconnect();
    } 
  }

Custom port names [linux]

Hello!

If I want to use an udev rule to specify a fixed name for a serial interface, I have to use "gnu.io.rxtx.SerialPorts" or "gnu.io.SerialPorts" to add this port to the known ports.
Internally RXTXCommDriver is using the addSpecifiedPorts method to add ports to the list (read from the system property).
For example:

addSpecifiedPorts("/dev/ttyMyCustomName0:/dev/ttyMyCusomName1", CommPortIdentifier.PORT_SERIAL);

If I would like to use the library, I could do something similar to (very simplified):

final CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(device);
final CommPort commPort = portIdentifier.open(id, TIMEOUT_MS_WAIT_FOR_OPEN);
final SerialPort serialPort = (SerialPort) commPort;

This will fail if device is a custom device name and not set using the system property.

Will it be able, to add a public method that grant us to add some user specified devices.

RXTXCommDriver.addCustomPort(device, CommPortIdentifier.PORT_SERIAL);

or

CommPortIdentifier.addCustomSerialPort(device);

The implementation could check, if the device is already added (return true) and will use (as already done for system property) a testRead to test the device (return true is succeeded, otherwise false). So a return of true, signals I could use that device.

Are there some architectural problems or security risks?

Provide a slim jar packaging besides the fat jar

With 1.1MB version 3.11.0 doubled in size from 3.10.0 with 550KB.
As discussed in #29 (comment), the reason is that it now includes an commons net as a dependency in a fat jar.
Specifically for OSGi use, it does not make any sense to package other OSGi bundles. Therefore it would be much desired to have a "pure" bundle as a download that does not contain this dependency.

When RXTX.run() exits, C code should no longer access the eis structure

madhephaestus suggested that I make an issue for this and add a comment or commit.

Under Mac OS X, running a Ptolemy model (SerialHelloWorld.xml )model was crashing Java in readArray(). I don't have a small test case for this, and my changes are more of a workaround than a fix.

The model opens two ports, writes to one port and halts after 5 seconds.

The code does not use the RXTXListener facility, instead it creates reader and writer threads.

The cause is that when the Java RXTXPort.run() method exits, a C struct named eis goes out of scope. If the drain thread tries to access eis after a timeout, then a segfault occurs.

What's happening is that in nrjavaserial/src/main/c/src/SerialImp.c, readArray() is calling read_byte_array() and read_byte_array() is crashing when eis is accessed:

        while( bytes < length &&  count++ < 20 ) /* && !is_interrupted( eis ) )*/
        {
                if (timeout >= 0) {
                        now = GetTickCount();
                        if ( now-start >= timeout )
                        {
--->                            eis->eventflags[SPE_DATA_AVAILABLE] = flag;
                                return bytes;
                        }
                }

The reason that it is crashing here is because eis is allocated in eventLoop() in SerialImp.c by struct event_info_struct eis:

JNIEXPORT void JNICALL RXTXPort(eventLoop)( JNIEnv *env, jobject jobj )
{
#ifdef WIN32
        int i = 0;
#endif /* WIN32 */
        struct event_info_struct eis;
        eis.jclazz = (*env)->GetObjectClass( env, jobj );
        eis.env = env;
        eis.jobj = &jobj;
        eis.initialised = 0;

        ENTER( "eventLoop\n" );
        if ( !initialise_event_info_struct( &eis ) ) goto end;
        if ( !init_threads( &eis ) ) goto end;

init_threads() sets the Java eis object:

        report("init_threads: get eis\n");
        jeis  = (*eis->env)->GetFieldID( eis->env, eis->jclazz, "eis", "J" );
        report("init_threads: set eis\n");
        (*eis->env)->SetLongField(eis->env, *eis->jobj, jeis, ( size_t ) eis );

nrjavaserial/src/main/java/gnu/io/RXTXPort.java invokes eventLoop()

        /** a pointer to the event info structure used to share information 
            between threads so write threads can send output buffer empty   
            from a pthread if need be.     

            long for 64 bit pointers.                                                                                                    
        */
        long eis = 0;

...

        /** Process SerialPortEvents */
        native void eventLoop();

...


        /**                                                                                                                              
        *  run the thread and call the event loop.                                                                                      
        */
                public void run()
                {
                        if (debug)
                                z.reportln( "RXTXPort:MontitorThread:run()");
                        monThreadisInterrupted=false;
                        eventLoop();
                        if (debug)
                                z.reportln( "eventLoop() returned");
                }

So, if the run() method ends, the eis automatic variable in eventloop() goes out of scope.

Logging of native code

Hi,
I am trying to debug a problem with connecting with a serial device.

A fatal error has been detected by the Java Runtime Environment:

SIGILL (0x4) at pc=0xa9d0d3e2, pid=1408, tid=2841312064

JRE version: Java(TM) SE Embedded Runtime Environment (7.0_55-b13) (build 1.7.0_55-b13)
Java VM: Java HotSpot(TM) Embedded Client VM (24.55-b03 mixed mode linux-x86 )
Problematic frame:
C [libNRJavaSerial.so+0x93e2] check_group_uucp+0x72

Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again

An error report file with more information is saved as:
/home/root/hs_err_pid1408.log
[thread -1443280064 also had an error]

If you would like to submit a bug report, please visit:
http://bugreport.sun.com/bugreport/crash.jsp
The crash happened outside the Java Virtual Machine in native code.
See problematic frame for where to report the bug.

From the full exception of the problem i got
Stack: [0xaafec000,0xab03c000], sp=0xab039a40, free space=310k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [libNRJavaSerial.so+0x93e2] check_group_uucp+0x72

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j gnu.io.RXTXCommDriver.testRead(Ljava/lang/String;I)Z+0
j gnu.io.RXTXCommDriver.registerValidPorts([Ljava/lang/String;[Ljava/lang/Strin
g;I)V+202
j gnu.io.RXTXCommDriver.registerScannedPorts(I)V+1502
j gnu.io.RXTXCommDriver.initialize()V+35
j gnu.io.CommPortIdentifier.getPortIdentifiers()Ljava/util/Enumeration;+53
j gnu.io.NativeResource.testNativeCode()V+0
j gnu.io.NativeResource.inJarLoad(Ljava/lang/String;)V+37
j gnu.io.NativeResource.loadLib(Ljava/lang/String;)V+54
j gnu.io.NativeResource.load(Ljava/lang/String;)V+138
j gnu.io.SerialManager.()V+23
j gnu.io.SerialManager.getInstance()Lgnu/io/SerialManager;+10
j gnu.io.RXTXCommDriver.()V+39
v ~StubRoutines::call_stub
J 1772 java.lang.Class.forName0(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljav
a/lang/Class; (0 bytes) @ 0xb4ecc47b [0xb4ecc410+0x6b]
j java.lang.Class.forName(Ljava/lang/String;)Ljava/lang/Class;+8
j gnu.io.CommPortIdentifier.()V+12
v ~StubRoutines::call_stub
j org.openhab.binding.zwave.internal.protocol.ZWaveController.connect(Ljava/lan
g/String;)V+13
j org.openhab.binding.zwave.internal.protocol.ZWaveController.(Ljava/lang
/String;)V+161
j org.openhab.binding.zwave.internal.ZWaveActiveBinding.updated(Ljava/util/Dict
ionary;)V+65
j org.eclipse.equinox.internal.cm.ManagedServiceTracker$1.run()V+8
j org.eclipse.equinox.internal.cm.SerializedTaskQueue$1.run()V+15
v ~StubRoutines::call_stub

I have checked your code and in the SerialImp.check_group_uucp there is logging statements. When i get the JVM error it only shows that the problem was in the check_group_uucp method. Does not show the line in native C code that produced the problem or the log error. If i had that native logging i could debug my problem faster.

How do you turn on native code logging for nrjavaserial? I could add it to the Git Hub wiki once i have verified it worked.

Constant CPU usage by gnu.io.RXTXPort.eventLoop

I've just tested this library on my BeagleBone Black and I noticed that the gnu.io.RXTXPort.eventLoop is constantly using about 15% percent of the cpu. (Even if there is no activity on the serial port) I found an older issue where this problem was discussed before: #22

The solution that is described there does not work for me because I'am already using the serialEvent to receive data from the serial port. How can this problem be solved?

Takes more than 15 minutes to load 256 ports

Hi,
We are using nrjavaSerial-3.8.8 API on a Windows 64 bit environment with JDK 7 (64 bit).
We're using CommPortIdentifier.getPortIdentifiers() to get a list of available ports. This method takes more than 15 minutes to load around 256 ports.
Our server has more than 4000 virtual ports. Is there a better way or a work around to reduce the loading time?

Thanks.

Serial port I/O best pratices

Hi,

_TLDR;_ I'm looking for best pratice/high performance for serial port reading and writing.

Background

I'm quite new on Java I/O so i took a bunch of readings about the subject, but all information that i found was talking about networking and filesystem reading and writing.

I work with agriculture software, therefore i need to communicate with all sort of sensors(scales, rfid readers, termometers, anemometer, etc).

On my current project, the software must be able to handle concurrents weighing from a bunch of scales dispersed all over the farm. The weighing data will come via radio and will be forwarded for my software via USB/Serial COM port.

What i am currently doing

Currently, i'm adding a SerialPortEventListener who relies on the internal MonitorThread from _nrjavaserial_ library. My listener is acting as a dispatcher, it handles serial port events, perform i/o, wraps the inputs and dispatch them for another threads to handle it.

When the listener recieve the SerialPortEvent.DATA_AVAILABLE, it performs a byte-by-byte reading(using directly the the nrjavaserial's InputStream) until it find a line-feed char('\n'). Just after the reading, it wraps the string that were read on a new event and post to a Guava's EventBus.

What i'm exactly looking for

In order to design a proper solution, i have to know more about Serial port I/O. I want be able to trade-off about byte-by-byte/buffered reading, buffer size, multi-thread strategy and so on...

I want to build reliable and responsive system with a modest memory footprint.

Maybe you guys can help me ;)

Include OSGI Bundle-NativeCode?

What about including the specification of the native libs for OSGI? I am not sure if I everything is correct, but my best guess is:

Bundle-NativeCode:
native/linux/ARM/libNRJavaSerial.so;
native/linux/ARM/libNRJavaSerial_HF.so;
native/linux/ARM/libNRJavaSerialv5.so;
native/linux/ARM/libNRJavaSerialv6.so;
native/linux/ARM/libNRJavaSerialv6_HF.so;
osname=Linux; processor=ARM,

native/linux/ARM_A8/libNRJavaSerial.so;
native/linux/ARM_A8/libNRJavaSerial_legacy.so;
osname=Linux; processor=???,

native/linux/PPC/libNRJavaSerial.so;
osname=Linux; processor=PowerPC,

native/linux/x86_32/libNRJavaSerial.so;
native/linux/x86_32/libNRJavaSerial_legacy.so;
osname=Linux; processor=x86,

native/linux/x86_64/libNRJavaSerial.so;
native/linux/x86_64/libNRJavaSerial_legacy.so;
osname=Linux; processor=x86-64,

native/osx/libNRJavaSerial.jnilib;
osname=MacOSX,

native/windows/x86_32/libNRJavaSerial.dll;
osname=Win32; processor=x86,

native/windows/x86_64/libNRJavaSerial.dll;
osname=Win32; processor=x86-64,

Serial port disappearing from nrjavaserial when USB device reboots

I have a device (a payment terminal) connected via a USB connection to a computer running Windows 7. It manifests itself as a virtual serial port (usually COM4). I have no problems communicating with the device using nrjavaserial, except for in one instance.

If I trigger an action that causes the device to reboot itself (such as a firmware update), I can no longer reach it using nrjavaserial. First of all, the existing connection fails to write with the following exception:

java.io.IOException: No error in writeArray
    at gnu.io.RXTXPort.writeArray(Native Method)
    at gnu.io.RXTXPort$SerialOutputStream.write(RXTXPort.java:1183)
    at se.extenda.eps.adapter.host2t.client.comm.SerialConnection.sendData(SerialConnection.java:126)
    at se.extenda.eps.adapter.host2t.client.comm.Host2TComm.sendMessageToTerminal(Host2TComm.java:349)
    at se.extenda.eps.adapter.host2t.client.comm.Host2TComm$1.run(Host2TComm.java:172)

If I call getAvailableSerialPorts then the virtual serial port (COM4) will no longer be in that list. If I explicity try to connect to COM4 I get the following exception:

gnu.io.NoSuchPortException
    at gnu.io.CommPortIdentifier.getPortIdentifier(CommPortIdentifier.java:273)
    at se.extenda.eps.adapter.host2t.client.comm.SerialConnection.connect(SerialConnection.java:67)
    at se.extenda.eps.adapter.host2t.client.comm.Host2TComm.connect(Host2TComm.java:122)
    at se.extenda.eps.adapter.host2t.client.comm.Host2TComm$3.run(Host2TComm.java:234)
    at java.util.TimerThread.mainLoop(Timer.java:512)
    at java.util.TimerThread.run(Timer.java:462)

The serial port COM4 is still visible in the device manager, though. The funny thing is that even restarting my application does not make COM4 work in my application. I have to disconnect the device from the computer and connect it again.

I'm aware that this may very well be an issue with the USB driver that is being used for the virtual serial port, but I'm submitting this here right away because maybe someone else has had the same issue or knows of a fix or a workaround. If I find anything more I'll of course update this issue.

Use proper lock directory

It is a nice attempt to provide the native parts of the serial interface embedded in the jar. However, you should be aware that this moves the burden of keeping things "proper and up-to-date" to you, the maintainers of this package. RXTXComm, in contrary, is available for all Linux distributions that I know of but maintained by their packagers.

At least Fedora and Arch have changed the directory for the device lock files to "/var/lock/lockdev" with the owner/mode for "/var/lock" having been changed to drwxr-xr-x. 7 root root /var/run/lock (link to /run/lock) (about 3 years ago). (Ubuntu is in a kind of "transition phase" with owner/mode set to drwxrwxrwt 8 root root /var/run/lock (link to /run/lock) and a "/var/lock/lockdev" directory.) This has been done for security reasons and should not be undone light-heartedly.

While package maintainers for RXTXComm have adapted this change and the RXTXComm packages work fine on these systems, the libraries provided with nrjavaserial still attempt to create the lock in "/var/lock" which fails, of course, despite the process being a member of groups uucp/tty and lock.

This is not only a technical issue. It also makes discussions of problems with the serial interface difficult, as I have just experienced. Because nrjavaserial claims to have the native support "on board" Java developers with little background in OS specifics tend to ignore related problems and tend to call you ignorant or simply state "works for me" (because they use Windows or Ubuntu). I'm emphasizing on this because the problem has arisen by nrjavaserial's claim to be the out-of-box solution instead of sticking to the well working principal that package maintainers are responsible for the native libraries.

Currently, nrjavaserial does not work on Fedora or Arch Linux because it uses the wrong lock directory. This should be changed. Maybe the best approach would be to replace the "static" definition of LOCKDEV with a more flexible one for "__linux__" (see SerialImp.h): check if "/var/lock/lockdev" exists and is writable, else fall back to "/var/lock" (because not all Linuxes are equal).

Define compatibility goals

We've had a number of issues asking us to support older environments (e.g., #16, #21). I'd like to think that we don't do too badly in this area, but what we're trying for remains a little wishy-washy. It would be nice to define more clearly which platforms we intend to support.

This is a little pie-in-the-sky right now and I've assigned it to me as the answer is partially dependent on the limits of automation (#19). However, if you (yes, you, the person reading this) have some specific platform requirement in mind โ€“ especially a non-x86 processor, or an old version of Java โ€“ please respond here so we have some idea of what's definitely desired by users of the library.

Update Compiled Libraries

A request that the compiled libraries found in the Resources folder be recompiled and posted after any native code updates. Unless I am reading it wrong, the compiled libraries are 11 months old. Some of us don't have the ability to generate all of the compiled libraries and this would be of help to us.
Thanks!

JVM crash when hardware in use disconnected

Dear NRJavaSerial devs,

We have an issue with NRJavaSerial library who crash our JRE (1.6.31-33, compulsory). This issue occurs on physical or virtual serial port (same behaviour).

Below a full sample to the our issue:

import gnu.io.NRSerialPort;
import gnu.io.SerialPortEvent;
import gnu.io.SerialPortEventListener;
import java.io.IOException;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class MainApp {

    public static void main(String args[]) throws Exception {
        final String port = args[0];
        final int baudRate = Integer.valueOf(args[1]);
        final NRSerialPort serial = new NRSerialPort(port, baudRate);
        final ExecutorService executor = Executors.newSingleThreadExecutor();

        serial.connect();
        serial.getSerialPortInstance().notifyOnDSR(true);
        serial.getSerialPortInstance().notifyOnBreakInterrupt(true);
        serial.getSerialPortInstance().notifyOnFramingError(true);
        serial.getSerialPortInstance().notifyOnOverrunError(true);
        serial.getSerialPortInstance().notifyOnParityError(true);


        try {
            final Future<Void> task = executor.submit(new Callable<Void>() {
                @Override
                public Void call() throws Exception {
                    while (!Thread.currentThread().isInterrupted()) {
                        System.out.println(serial.getInputStream().read());
                    }
                    return null;
                }
            });

            serial.addEventListener(new SerialPortEventListener() {
                @Override
                public void serialEvent(SerialPortEvent ev) {
                    System.err.println("Receive code " + ev.getEventType());
                    serial.removeEventListener();
                    task.cancel(true);
                }
            });
            task.get();
        } catch (Exception ex) {
            throw new IOException(ex);
        } finally {
            serial.removeEventListener();
            executor.shutdownNow();
            serial.disconnect();
        }
    }

}

Now we test our hardware connected on a COM4 physical serial port:

C:\temp\SerialNotifier>java -cp serialnotifier-1.0.0.jar;nrjavaserial-3.11.0.jar
 MainApp COM4 9600
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
Receive code 4     (hardware disconnected)
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6ac47568, pid=11152, tid=9072

#
# JRE version: 6.0_31-b05
# Java VM: Java HotSpot(TM) Client VM (20.6-b01 mixed mode windows-x86 )
# Problematic frame:
# C  [libNRJavaSerial.dll+0x7568]
#
# An error report file with more information is saved as:
# C:\temp\SerialNotifier\hs_err_pid11152.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

C:\temp\SerialNotifier>

JVM crash report:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6ac47568, pid=11152, tid=9072
#
# JRE version: 6.0_31-b05
# Java VM: Java HotSpot(TM) Client VM (20.6-b01 mixed mode windows-x86 )
# Problematic frame:
# C  [libNRJavaSerial.dll+0x7568]
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

---------------  T H R E A D  ---------------

Current thread (0x16f16400):  JavaThread "pool-1-thread-1" [_thread_in_native, id=9072, stack(0x17140000,0x17190000)]

siginfo: ExceptionCode=0xc0000005, writing address 0x1713fac0

Registers:
EAX=0x1713fab8, EBX=0x00000000, ECX=0x00000001, EDX=0x00471fd0
ESP=0x1718fa40, EBP=0x00000001, ESI=0x00000013, EDI=0x00000001
EIP=0x6ac47568, EFLAGS=0x00010297

Top of Stack: (sp=0x1718fa40)
0x1718fa40:   000003e8 1718faa0 00000001 6ac5413c
0x1718fa50:   1718fa60 471fd070 1713fab8 00000001
0x1718fa60:   1718fa78 6d881ff2 16f16400 16f16528
0x1718fa70:   16f17734 00000001 1718faf8 6ac476ae
0x1718fa80:   16f16528 1718fb04 00000001 1718faa0
0x1718fa90:   00000001 00000064 00912f03 00000064
0x1718faa0:   00000001 02b271a8 1718faa8 12bbc33a
0x1718fab0:   1718fae0 12bbd040 00000000 12bbc368 

Instructions: (pc=0x6ac47568)
0x6ac47548:   75 c6 c7 04 24 e8 03 00 00 e8 4a 16 00 00 39 5c
0x6ac47558:   24 50 7f be 8d 74 26 00 8b 44 24 18 8b 4c 24 1c
0x6ac47568:   89 48 08 83 c4 2c 89 d8 5b 5e 5f 5d c3 e8 0e ac
0x6ac47578:   00 00 83 38 04 74 06 90 e8 03 ac 00 00 8b 44 24 


Register to memory mapping:

EAX=0x1713fab8 is an unknown value
EBX=0x00000000 is an unknown value
ECX=0x00000001 is an unknown value
EDX=0x00471fd0 is an unknown value
ESP=0x1718fa40 is pointing into the stack for thread: 0x16f16400
EBP=0x00000001 is an unknown value
ESI=0x00000013 is an unknown value
EDI=0x00000001 is an unknown value


Stack: [0x17140000,0x17190000],  sp=0x1718fa40,  free space=318k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libNRJavaSerial.dll+0x7568]  Java_gnu_io_RXTXPort_nativeSetEndOfInputChar+0x1e8

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  gnu.io.RXTXPort.readByte()I+0
j  gnu.io.RXTXPort$SerialInputStream.read()I+61
j  MainApp$1.call()Ljava/lang/Void;+19
j  MainApp$1.call()Ljava/lang/Object;+1
j  java.util.concurrent.FutureTask$Sync.innerRun()V+30
j  java.util.concurrent.FutureTask.run()V+4
j  java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Ljava/lang/Runnable;)V+59
j  java.util.concurrent.ThreadPoolExecutor$Worker.run()V+28
j  java.lang.Thread.run()V+11
v  ~StubRoutines::call_stub

---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )
=>0x16f16400 JavaThread "pool-1-thread-1" [_thread_in_native, id=9072, stack(0x17140000,0x17190000)]
  0x16b60c00 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=7528, stack(0x16db0000,0x16e00000)]
  0x16b5c800 JavaThread "C1 CompilerThread0" daemon [_thread_blocked, id=9412, stack(0x16d60000,0x16db0000)]
  0x16b59400 JavaThread "Attach Listener" daemon [_thread_blocked, id=2420, stack(0x16d10000,0x16d60000)]
  0x16b57c00 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=2488, stack(0x16cc0000,0x16d10000)]
  0x16b4a400 JavaThread "Finalizer" daemon [_thread_blocked, id=9100, stack(0x16c70000,0x16cc0000)]
  0x16b45800 JavaThread "Reference Handler" daemon [_thread_blocked, id=4556, stack(0x16c20000,0x16c70000)]
  0x002b6800 JavaThread "main" [_thread_blocked, id=9144, stack(0x008c0000,0x00910000)]

Other Threads:
  0x16b41c00 VMThread [stack: 0x16bd0000,0x16c20000] [id=4680]
  0x16b6b800 WatcherThread [stack: 0x16e00000,0x16e50000] [id=7728]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
 def new generation   total 4928K, used 2228K [0x02990000, 0x02ee0000, 0x07ee0000)
  eden space 4416K,  38% used [0x02990000, 0x02b3d0a8, 0x02de0000)
  from space 512K, 100% used [0x02de0000, 0x02e60000, 0x02e60000)
  to   space 512K,   0% used [0x02e60000, 0x02e60000, 0x02ee0000)
 tenured generation   total 10944K, used 4431K [0x07ee0000, 0x08990000, 0x12990000)
   the space 10944K,  40% used [0x07ee0000, 0x08333c28, 0x08333e00, 0x08990000)
 compacting perm gen  total 12288K, used 2273K [0x12990000, 0x13590000, 0x16990000)
   the space 12288K,  18% used [0x12990000, 0x12bc8748, 0x12bc8800, 0x13590000)
No shared spaces configured.

Code Cache  [0x00910000, 0x009a8000, 0x02910000)
 total_blobs=180 nmethods=51 adapters=66 free_code_cache=32941376 largest_free_block=0

Dynamic libraries:
0x00400000 - 0x00425000     C:\Windows\system32\java.exe
0x7c900000 - 0x7c9af000     C:\Windows\system32\ntdll.dll
0x7c800000 - 0x7c8f6000     C:\Windows\system32\kernel32.dll
0x77dd0000 - 0x77e6b000     C:\Windows\system32\ADVAPI32.dll
0x77e70000 - 0x77f02000     C:\Windows\system32\RPCRT4.dll
0x77fe0000 - 0x77ff1000     C:\Windows\system32\Secur32.dll
0x7c340000 - 0x7c396000     C:\Program Files\Java\jre6\bin\msvcr71.dll
0x6d7f0000 - 0x6da9f000     C:\Program Files\Java\jre6\bin\client\jvm.dll
0x7e410000 - 0x7e4a1000     C:\Windows\system32\USER32.dll
0x77f10000 - 0x77f59000     C:\Windows\system32\GDI32.dll
0x76b40000 - 0x76b6d000     C:\Windows\system32\WINMM.dll
0x76390000 - 0x763ad000     C:\Windows\system32\IMM32.DLL
0x6d7a0000 - 0x6d7ac000     C:\Program Files\Java\jre6\bin\verify.dll
0x6d320000 - 0x6d33f000     C:\Program Files\Java\jre6\bin\java.dll
0x6d7e0000 - 0x6d7ef000     C:\Program Files\Java\jre6\bin\zip.dll
0x6ac40000 - 0x6ac66000     C:\Documents and Settings\Administrator\Local Settings\Temp\libNRJavaSerial_Administrateur_0\libNRJavaSerial.dll
0x77c10000 - 0x77c68000     C:\Windows\system32\msvcrt.dll
0x76bf0000 - 0x76bfb000     C:\Windows\system32\PSAPI.DLL

VM Arguments:
java_command: MainApp COM4 9600
Launcher Type: SUN_STANDARD

Environment Variables:
PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\system32\WindowsPowerShell\v1.0;C:\httpd\Php\extras\wso2-wsf-php-bin-2.0.0-win32\wsf_c\lib\;C:\httpd\Php\extras\bindlib-cvs-vc8\lib\;C:\httpd\Php\extras\iconv-1.9.2.win32\bin\;C:\httpd\Php\extras\libxml2-2.7.6.win32\bin\;C:\httpd\Php\extras\openssl-0.9.8a.win32\bin\;c:\Program Files\Panda Security\WaAgent\Common;C:\Program Files\Skype\Phone\
USERNAME=Administrateur
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 6 Model 28 Stepping 2, GenuineIntel



---------------  S Y S T E M  ---------------

OS: Windows XP Build 2600 Service Pack 3

CPU:total 2 (1 cores per cpu, 2 threads per core) family 6 model 28 stepping 2, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, ht

Memory: 4k page, physical 2087020k(1352620k free), swap 2957980k(2166384k free)

vm_info: Java HotSpot(TM) Client VM (20.6-b01) for windows-x86 JRE (1.6.0_31-b05), built on Feb  3 2012 18:44:09 by "java_re" with MS VC++ 7.1 (VS2003)

time: Tue Feb 23 09:47:21 2016
elapsed time: 14 seconds

License information is missing in the repo

I assume you make the code available under the LGPL 2.1 as this is how RXTX is licensed. You do not have any license header on additional classes such as https://github.com/NeuronRobotics/nrjavaserial/blob/master/nrjavaserial/src/main/java/gnu/io/NRSerialPort.java nor have you a LICENSE file in the root of the repo.

It would be great if you could add such a license information as this is suggested as a best practice on Github, see https://help.github.com/articles/open-source-licensing/.

Thanks!
Kai

PPC Breaks ARM

The PPC code broke the ARM implementation. Fortunately, fix is simple:
Change line 115 in NativeResource.java from (from "if" to "else if"):
} if(OSUtil.isPPC()) {
to:
}else if(OSUtil.isPPC()) {

Apply XON/XOFF patch for Windows

XON/XOFF flow control is used incorrectly due to two missing initializations in termios.c. The patch attached to the mail corrects this.

In Google Code Project this had issue no 35. I can confirm that the fix works. We have a printer with XON / XOFF that didn't work, we applied the patch and now it works. Please include in future releases.
Please add these to termios.c
ttyset->c_cc[VSTART] = 0x11; /* 8: DC1/XON /
ttyset->c_cc[VSTOP] = 0x13; /
9: DC3/XOFF */

Below is a copy of fix as added to issue 35 in GCP.

Index: nrjavaserial/src/main/c/src/windows/termios.c

--- nrjavaserial/src/main/c/src/windows/termios.c (revision 185)
+++ nrjavaserial/src/main/c/src/windows/termios.c (working copy)
@@ -807,6 +807,10 @@
ttyset->c_cc[VTIME] = 0; /* 5: read timeout /
ttyset->c_cc[VMIN] = 1; /
6: read returns after this
many bytes */

  • ttyset->c_cc[VSTART] = 0x11; /* 8: DC1/XON */
  • ttyset->c_cc[VSTOP] = 0x13; /* 9: DC3/XOFF */
  • ttyset->c_cc[VSUSP] = 0x1a; /* 10: C-z /
    ttyset->c_cc[VEOL] = '\r'; /
    11: /
    ttyset->c_cc[VREPRINT] = 0x12; /
    12: C-r */

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.