I have a project in java, which is using comport for communication. And using comport 1 and 2 number. But my linux system is not capable to have com-port. I want to run the code and want to listen data send on comport. but when i am running code, it throws error. How should i pursue.
My comport utility code is something like this
import com.fazecast.jSerialComm.SerialPort;
public class ComPortUtil {
private static SerialPort comPort;
private static SerialPort relayPort;
static {
SerialPort[] serialPorts = SerialPort.getCommPorts();
comPort = serialPorts[3];
comPort.setBaudRate(115200);
comPort.setParity(SerialPort.NO_PARITY);
comPort.setNumDataBits(8);
comPort.setNumStopBits(SerialPort.ONE_STOP_BIT);
relayPort = serialPorts[1];
relayPort.setBaudRate(115200);
relayPort.setParity(SerialPort.NO_PARITY);
relayPort.setNumDataBits(8);
relayPort.setNumStopBits(SerialPort.ONE_STOP_BIT);
}
public static SerialPort getPOSPort() {
return comPort;
}
public static SerialPort getRelayPort() {
return relayPort;
}
}