CelerCOM Java library

 

CelerCOM is a minimalistic Java library, which can be used to interact with external devices over COM ports, for example: USB, virtual COM. It can be used to interact with TTY and FIFO files as well.

CelerCOM

The main features:

  • The native driver for Linux doesn't have any dependencies, not even libc. This makes it possible to use CelerCOM in very minimalistic environments like embedded systems. For example, it was successfully tested on Raspberry Pi.
  • The native driver for Windows is compatible with all Windows versions.
  • If there is no native driver available for the current Operating System (OS) and CPU architecture CelerCOM features an automatic fallback to use a pure Java driver based on RandomAccessFile (RAF) API. The RAF driver features limited compatibility with external devices though. The benefits of the native driver are explained below.
  • Both the library and the native drivers are bundled as a single JAR. CelerCOM can select the appropriate native driver, extract and load it automatically.

A native driver is used for the following OS and CPU:

WindowsLinux
x86 (32 bit)
AMD64 (64 bit)
ARM (32 bit)
 

The pure Java RAF driver is used as a fallback. The native driver is preferred:

  • The native driver can recover from unexpected communication errors automatically.
  • The ability to disable system cache for I/O operations, which is required for compatibility with some communication devices.
  • Read operations block for 200ms at most when using the native driver. The RAF driver blocks indefinitely when waiting for the device.

 

How to use

Just add CelerCOM.jar to you classpath. The API is described in the javadoc documentation.

CelerCOM contents

The CelerCOM library can be used as a simple TTY terminal as well. Just run CelerCOM.bat in Windows or CelerCOM.sh in Linux/Unix to launch the TTY. The COM port can be specified as the only configuration parameter inside the launcher script: COM_PORT.

In Windows the COM ports require the "\\.\" prefix if the port number is greater than 9. For example, valid Windows port names:

COM9
\\.\COM10

In Linux the typical name for a USB port is:

/dev/ttyUSB0

Note that you may have to be a member of the dialout group or root to have access to the USB or any other serial port in Linux. This is not necessary when interacting with TTY or FIFO files.

The TTY terminal will try to open the specified COM port and start sending and receiving text commands. If the device supports AT commands they can be sent through the TTY terminal.

 

Examples

GitHubPlease, refer to our GitHub repository.