0

I have created application that sends/receives messages using com port. I use rxtx lib for this purpose. When application starts I open com port like:

    String comportidentifier = "/dev/ttyS0";

            CommPortIdentifier portIdentifier = null;
            portIdentifier = CommPortIdentifier.getPortIdentifier(comportidentifier);

            if (portIdentifier.isCurrentlyOwned()) {
                JOptionPane.showMessageDialog(null, "port in use");
            } else {

                SerialPort serialPort = (SerialPort) portIdentifier.open("ReadComPort", 200);
}

And I close it when programm finishes job.

Unexpectedly I found that my comport (the one I have opened) transmits some strange command my code does't sends. I'm usig several libraryes in my code and I don't pass com port variable to them. The only description is that something in system is alsow has opened port and is sends command. But is this possible if I already have opened com port? I suppose that when I have opened port nobody can do that also until I close it. How to describe this situation?

When I have change port to /dev/ttyS1 unexpected command was not transmitted.

vico
  • 17,051
  • 45
  • 159
  • 315

1 Answers1

0

Rxtx can be a little buggy, especially if you are using stock libs and not one of the bug fixed forks like nrserial. I don't think isCurrentlyOwned actually works on every platform, and locking a port is not consistent. There are issues with closing a port too. Still, I have never seen it generate random data on the port.

You may want to look at one of the newer forks, they contain many fixes. Also the rxtx mailing list archive may be helpful to find other instances similar to the problem you see.

user3109924
  • 184
  • 4