Tuesday, November 4, 2014

Use jSSC (Java Simple Serial Connector) on Windows 8.1

jSSC (Java Simple Serial Connector) is a library for working with serial ports from Java. jSSC support Win32(Win98-Win8), Win64, Linux(x86, x86-64, ARM), Solaris(x86, x86-64), Mac OS X 10.5 and higher(x86, x86-64, PPC.

My old post show how to Install and test java-simple-serial-connector with Arduino, running on Ubuntu and Netbeans IDE.

This video show how to use jSSC on Windows 8.1/Nerbeans IDE. Basically it is the same, with different COM port assignment.


The Java code is listed here. It send a message to Arduino Esplora via USB Serial port, COM3, using jSSC library.

package java_testjssc;
 
import jssc.SerialPort;
import jssc.SerialPortException;
 
public class Java_testjSSC {
 
    public static void main(String[] args) {
        SerialPort serialPort = new SerialPort("COM3");
        try {
            System.out.println("Port opened: " + serialPort.openPort());
            System.out.println("Params setted: " 
                + serialPort.setParams(9600, 8, 1, 0));
            System.out.println("\"Hello World!!!\" successfully writen to port: " 
                + serialPort.writeBytes("Hello World!!!".getBytes()));
            System.out.println("Port closed: " 
                + serialPort.closePort());
        }
        catch (SerialPortException ex){
            System.out.println(ex);
        }
    }
     
}

The Arduino side code, refer to the post "Serial communication between Arduino Esplora and PC".



No comments:

Post a Comment