Closed wborn closed 4 years ago
I just retested this issue with 5.2.0 @madhephaestus and it now throws the PortInUseException: Unknown Owner
exception:
getting identifier for: /dev/ttyUSB0
opening: /dev/ttyUSB0
opened: /dev/ttyUSB0
sleeping...
closing: /dev/ttyUSB0
closed: /dev/ttyUSB0
sleeping...
getting identifier for: /dev/ttyUSB0
opening: /dev/ttyUSB0
sleeping...
PortInUseException: Unknown Owner
getting identifier for: /dev/ttyUSB0
open: locking has failed for /dev/ttyUSB0
opening: /dev/ttyUSB0
sleeping...
PortInUseException: Unknown Owner
getting identifier for: /dev/ttyUSB0
opening: /dev/ttyUSB0
open: locking has failed for /dev/ttyUSB0
Looks like the port isn't properly released.
Rather than hunt down where it should have been released, we could just move the workaround into the function?
It seems the get identifiers refreshes the state of the known ports list so that the new method can complete.
check with release 5.2.1 please?
It seems to resolve this issue. :+1:
I do notice if I repeat inserting/removing the USB stick, eventually issue https://github.com/NeuronRobotics/nrjavaserial/issues/111 occurs and it is no longer possible to use the serial port unless I restart the application.
lol, and the issue whack-a-mole continues, closing this one, reopening that one...
Yes but it is certainly improving now the whole application doesn't exit and most of the time you can reinsert your USB stick and use it. :wink:
When removing a USB stick the process exits when a port is reopened without first calling
CommPortIdentifier.getPortIdentifiers();
Here is a simple example to reproduce the issue with nrjavaserial 5.1.1 on Ubuntu 18.04:
If I don't uncomment the workaround it exits with the following output after unplugging the USB stick:
It works fine when uncommenting the workaround.