JAVA - UBUNTU - Problem with serial ports

0

I'm a newbie in linux / xubuntu. I need to know in which ttyS * I have connected my RFID reader. My PC has 3 COM ports (COM1, COM2 and COM3). I connected it to COM1 and SUPUSE that corresponded to / dev / ttyS0 but I do not read anything (the software I did) ... I tried it in ttyS1 and ttyS2 but it does not read anything either. I put an RS232-USB converter and read it correctly on ttyUSB0 ... with which I know that the software and the reader work ... but I can not locate the ttyS that corresponds to COM1 in my ubuntu. Is there any way to know if there is something connected in a COM and how to locate it? The code I have is the following (I use the jserialcomm library):

SerialPort comPort = SerialPort.getCommPort("/dev/ttyS0");
                comPort.setBaudRate(57600);
                comPort.openPort();
                comPort.setComPortTimeouts(SerialPort.TIMEOUT_READ_BLOCKING, 100, 0);
                try {
                   while (true)
                   {
                      while (comPort.bytesAvailable() == 0)
                         Thread.sleep(20);

                      if (comPort.bytesAvailable() == 166) {
                          byte[] readBuffer = new byte[comPort.bytesAvailable()];
                          //byte[] readBuffer = new byte[1024];
                          int numRead = comPort.readBytes(readBuffer, readBuffer.length);
                          String value = new String(readBuffer);
                          System.out.println("Read " + numRead + " bytes. " + value);
                      }
                   }
                } catch (Exception e) { e.printStackTrace(); }
                comPort.closePort();

Now, as I mentioned earlier, if I put the rs232-usb converter I read it perfectly by / dev / ttyUSB0. To help you I leave a screenshot of the ports of my PC.

solutraz@solutraz-roca:~$ dmesg | grep ttyS[01]
[    3.827120] 00:06: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
[    3.848707] 00:07: ttyS1 at I/O 0x2f8 (irq = 3, base_baud = 115200) is a 16550A

I hope you can help me ... Thank you all!

    
asked by Emiliano Torres 02.01.2019 в 20:29
source

0 answers