cyberluke / java-simple-serial-connector

Automatically exported from code.google.com/p/java-simple-serial-connector
0 stars 0 forks source link

SerialPortList not refreshed when a USB serial port is unplugged #40

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. jSSC-2.6.0 
2. Plug a USB device (with usb/serial bridge)
3. call SerialPortList.getPortNames()
4. Open USB COM port and add a SerialPortEventListener (...do my code)
4. UnPlug USB device
5. call again SerialPortList.getPortNames()

What is the expected output? What do you see instead?
It seems that when i try to get an updated list of available COM ports this may 
not be updated when I remove the USB device.

What version of the product are you using? On what operating system?
jSSC-2.6.0 - Windows XP 32bit

Original issue reported on code.google.com by lciu...@i-piu.it on 6 Jun 2013 at 9:38

GoogleCodeExporter commented 8 years ago
In Windows jSSC take port names from registry: 
HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM\ If jSSC return list with 
unpluged port name, it's mean that this port name present in registry. It can 
be a problem with USB->Serial adapter driver. Try to close the port before 
after step #4 and try again. May be driver cannot unregister device if it busy.

Original comment by scream3r.org@gmail.com on 7 Jun 2013 at 4:43

GoogleCodeExporter commented 8 years ago
It's true, if the COM port is closed before i try to unplug the USB device, 
SerialPortList.getPortNames() return an updated list.

But, if i remove "brutally" the USB device when a SerialPortEventListener is 
still running (the COM port is always busy)... after i'm unable to close the 
connection.

This is the exception: setEventsMask(); Exception type - Can't set mask.

it is possible to handle this type of event?

Original comment by lciu...@i-piu.it on 7 Jun 2013 at 9:11

GoogleCodeExporter commented 8 years ago
You can't close port if device phisically removed from system, because port 
handle at this moment incorrect. You should close port before removing of 
device. It's a bad practice - remove device while working.

Original comment by scream3r.org@gmail.com on 7 Jun 2013 at 10:09

GoogleCodeExporter commented 8 years ago

Original comment by scream3r.org@gmail.com on 21 Jun 2013 at 5:49