I am attempting to read data from the serial port on my computer. It is connected to an arduino printing "hi" over and over. For some reason the program only returns gibberish. code:
import jssc.SerialPort;
import jssc.SerialPortException;
public class SerialRead {
public static void main(String[] args) {
byte[] x;
SerialPort serialPort = new SerialPort("/dev/cu.usbmodem411");
try {
serialPort.openPort();//Open serial port
serialPort.setParams(9600, 8, 1, 0);//Set params.
byte[] buffer = serialPort.readBytes(10);//Read 10 bytes from serial port
x = serialPort.readBytes(10);
serialPort.closePort();//Close serial port
System.out.println(x);
}
catch (SerialPortException ex) {
System.out.println("aw cwap, someting went wong");
}
}
}
it returns [B@60e53b93