NRJavaSerial

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

License

License

GroupId

GroupId

com.neuronrobotics
ArtifactId

ArtifactId

nrjavaserial
Last Version

Last Version

5.2.1
Release Date

Release Date

Type

Type

jar
Description

Description

NRJavaSerial
A fork of the RXTX library with a focus on ease of use and embeddability in other libraries.
Project URL

Project URL

http://neuronrobotics.com
Source Code Management

Source Code Management

https://github.com/NeuronRobotics/nrjavaserial

Download nrjavaserial

How to add to project

<!-- https://jarcasting.com/artifacts/com.neuronrobotics/nrjavaserial/ -->
<dependency>
    <groupId>com.neuronrobotics</groupId>
    <artifactId>nrjavaserial</artifactId>
    <version>5.2.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.neuronrobotics/nrjavaserial/
implementation 'com.neuronrobotics:nrjavaserial:5.2.1'
// https://jarcasting.com/artifacts/com.neuronrobotics/nrjavaserial/
implementation ("com.neuronrobotics:nrjavaserial:5.2.1")
'com.neuronrobotics:nrjavaserial:jar:5.2.1'
<dependency org="com.neuronrobotics" name="nrjavaserial" rev="5.2.1">
  <artifact name="nrjavaserial" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.neuronrobotics', module='nrjavaserial', version='5.2.1')
)
libraryDependencies += "com.neuronrobotics" % "nrjavaserial" % "5.2.1"
[com.neuronrobotics/nrjavaserial "5.2.1"]

Dependencies

compile (1)

Group / Artifact Type Version
commons-net : commons-net jar 3.3

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

About

Financial Contributors on Open Collective Join the chat at https://gitter.im/NeuronRobotics/nrjavaserial Maven Central Build Status 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
     $ gradle build
    

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

Building Native Code

Native code is built using the Makefile found in the root of the repository. After the native code is built, the JAR is rebuilt.

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

# Build the windows binaries on Linux via Wine.
$ make wine

# Build both the 32- and 64-bit Linux x86 binaries.
$make linux

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

# Build the binaries for all the supported ARM flavors (requires arm-linux-geabi-* packages)
$ make arm

# Build the OSX binaries.
$ make osx

# Build the PPC binaries.
$ make ppc

# Build the FreeBSD binaries.
$ make freebsd32
$ make freebsd64

Building on Windows

You'll need some installation of GCC. We recommend the TDM-GCC distribution of mingw64-w64. To get the build working you need both mingw32, and ming64 installed in separate directories. Please modify JDKDIR to your installation of JDK.

Compile against Java

https://cdn.azul.com/zulu/bin/zulu8.44.0.13-ca-fx-jdk8.0.242-win_x64.zip

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]

com.neuronrobotics

Neuron Robotics

A system for communicating between hardware devices and software.

Versions

Version
5.2.1
5.2.0
5.1.1
5.1.0
5.0.2
5.0.0
4.2.0
4.1.0
4.0.2
4.0.1
4.0.0
3.21.0
3.20.1
3.20.0
3.19.0
3.18.0
3.17.0
3.16.1
3.16.0
3.15.0
3.14.0
3.13.0
3.12.1
3.12.0
3.11.0
3.10.2
3.10.1
3.7.5.1
3.7.5