I am trying to communicate with a microcontroller using java. In windows, I simply use "COM4" and my code works perfectly. In Linux i am trying to use "/dev/ttyUSB0". But gives me an error "Could not find serial port".
I used dmesg | grep to try to see the active serial port. is this the right method?
how can I solve this issue? I am really new to Linux so please explain in simple language
Here is my code:
Enumeration portIdentifiers = CommPortIdentifier.getPortIdentifiers(); CommPortIdentifier portId = null; while (portIdentifiers.hasMoreElements()) { CommPortIdentifier pid = (CommPortIdentifier) portIdentifiers.nextElement(); if(pid.getPortType() == CommPortIdentifier.PORT_SERIAL && pid.getName().equals("/dev/ttyUSB0")) { portId = pid; break; } } if(portId == null) { System.err.println("Could not find serial port "); // + wantedPortName); System.exit(1); }