I am working with jssc library. I want to emulate ELM327 device and I have already found OBDSim (https://icculus.org/obdgpslogger/obdsim.html).
I am in dialout group.
While mounting OBDSim on tty0, simple code:
import jssc.SerialPort;
import jssc.SerialPortException;
import jssc.SerialPortList;
public class Main {
public static void main(String[] args) {
String[] portNames = SerialPortList.getPortNames();
for(int i = 0; i < portNames.length; i++){
System.out.println(portNames[i]);
}
}
gives me empty list. While connecting real device to USB, this code gives me:
/dev/ttyUSB0
I read that jssc is searching over ttyUSB* and ttyS* ports, but I am unable to run OBDSim on ttyS0.
sudo obdsim -g gui_fltk -t /dev/ttyS0
result:
tcgetattr tty_device: Input/output error
Error creating virtual port
Any ideas?
For anyone dealing with that kind of issue, here is my tip:
You might want to use socat to create virtual serial port (PTY/PTS) and then mount OBDsim (or other tool) there. Then, symlink this port to ttyUSB*. Jssc will find that. I have no better solution so far and perhaps there won't be any.