Serial.list() error

edited February 2016 in Library Questions

This is a issue with the Serial.list(), when you are connected to a port as in myPort = new Serial(this, Serial.list[1], 9600); and you pull the COM cable your connected to, the Serial.list() has some kind of runtime error and will never clear out the old ports.

I can add to the Serial.list() array by adding more COM ports but the old ones never get removed like they would before you improperly disconnected.

Meaning if Serial.list()[1] is COM3, and you pull the connection, Serial.list()[1] will forever have COM3 listed, if you add a different COM like Serial.list()[2] is COM4 that adds but it also will never remove that listing.

I've proven this to be true over several tests, most noticeable being that Serial.list().length will never get shorter, only longer.

How do you get processing to recover from this without a restart?

Note: I can still myPort.stop() and then reconnect to the ports if I plug them back in, but without the Serial.list() updating correctly I'm finding it really hard to detect the cable pull while in the running loop. Having a timeout counter for serial data is sloppy and not always relevant to the application.

Tagged:
Sign In or Register to comment.