Serial port communication in Java - FTDI D2XX, HID API, X/Y modem
SerialPundit is a Software Developer Kit (SDK) for serial port and HID communication. It has been ported to Linux, MAC, Windows and embedded SE Linux platforms for both 64/32 bit architectures.
It is powerfully configurable for both poll and event driven application designs be it low volume low frequency data or high volume high frequency data.
It eliminates the complexities of serial port programming for different operating systems, allowing engineers to concentrate on their application logic, facilitating faster engineering and development, reducing development cost and time to market.
It is consistent, portable, efficient, testable, reliable, extensible and modifiable.
Communication
File transfer protocols
Vendor libraries integration
Others
The project is :
Null modem emulator; tty2com is a feature rich null modem emulation driver supporting null modem, loopback, custom pinout and dynamic virtual serial port creation. Corresponding Desktop application, Eclipse IDE plugin, command line interface and Java/Python APIs are provided to manage virtual ports.
CP210x driver; kernel mode driver for usb-serial cp210x IC and products based on it with access to GPIO pins, IOCTL operations support, configuration and installations scripts, udev rules etc.
The folder prebuilt-release in this repository contains ready-to-use jar file (sp-tty.jar) that can be imported in any project and referenced right away. Simply add sp-tty.jar in your project as an external library.
To add a jar in Eclipse, right-click on the Project → Build Path → Configure Build Path. Under Libraries tab, click Add Jars or Add External JARs and give the sp-core.jar and sp-tty.jar.
import com.serialpundit.serial.SerialComManager;
import com.serialpundit.serial.SerialComManager.BAUDRATE;
import com.serialpundit.serial.SerialComManager.DATABITS;
import com.serialpundit.serial.SerialComManager.FLOWCONTROL;
import com.serialpundit.serial.SerialComManager.PARITY;
import com.serialpundit.serial.SerialComManager.STOPBITS;
public class Example {
public static void main(String[] args) {
try {
SerialComManager scm = new SerialComManager();
long handle = scm.openComPort("/dev/ttyUSB1", true, true, false);
scm.configureComPortData(handle, DATABITS.DB_8, STOPBITS.SB_1, PARITY.P_NONE, BAUDRATE.B115200, 0);
scm.configureComPortControl(handle, FLOWCONTROL.NONE, 'x', 'x', false, false);
scm.writeString(handle, "testing hello", 0) == true);
String data = scm.readString(handle);
System.out.println("data read is :" + data);
scm.closeComPort(handle);
} catch (Exception e) {
e.printStackTrace();
}
}
}
SerialPundit is designed, developed and maintained by Rishi Gupta. He does Linux driver development, embedded systems design, firmware development, circuit designing, prototyping, board bring up etc.
Linkdin profile : http://in.linkedin.com/pub/rishi-gupta/20/9b8/a10
SerialPundit is DUAL LICENSED. It is made available under the terms of the GNU Affero General Public License (AGPL) v3.0 for non-commercial use and under the terms of a commercial license for commercial use of this library. Contact author for commercial license.
See LICENSE file in repository for full license text for AGPL v3.0.