busy serial port and "new Serial"
in
Core Library Questions
•
1 year ago
Hi, I see that "Serial.list()" returns all the port: the free ones and also the ports with something already connected to. If I want to test all the ports to discover on wich a specific device is connected my program crashes at "new Serial(this, Serial.list()[X], 9600)" where X is a port that is busy.
The error is this:
gnu.io.PortInUseException: Unknown Application
at gnu.io.CommPortIdentifier.open(CommPortIdentifier.java:467)
at processing.serial.Serial.<init>(Unknown Source)
at processing.serial.Serial.<init>(Unknown Source)
at rilevaSeriale.setup(rilevaSeriale.java:41)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:722)
Exception in thread "Animation Thread" java.lang.RuntimeException: Error inside Serial.<init>()
at processing.serial.Serial.errorMessage(Unknown Source)
at processing.serial.Serial.<init>(Unknown Source)
at processing.serial.Serial.<init>(Unknown Source)
at rilevaSeriale.setup(rilevaSeriale.java:41)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:722)
Do you have any suggestion on how to exlude ports with something already connected to?
Is it possible that the constructor of Serial returns something (not described in the documentation)?
Thanks in advance
The error is this:
gnu.io.PortInUseException: Unknown Application
at gnu.io.CommPortIdentifier.open(CommPortIdentifier.java:467)
at processing.serial.Serial.<init>(Unknown Source)
at processing.serial.Serial.<init>(Unknown Source)
at rilevaSeriale.setup(rilevaSeriale.java:41)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:722)
Exception in thread "Animation Thread" java.lang.RuntimeException: Error inside Serial.<init>()
at processing.serial.Serial.errorMessage(Unknown Source)
at processing.serial.Serial.<init>(Unknown Source)
at processing.serial.Serial.<init>(Unknown Source)
at rilevaSeriale.setup(rilevaSeriale.java:41)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:722)
Do you have any suggestion on how to exlude ports with something already connected to?
Is it possible that the constructor of Serial returns something (not described in the documentation)?
Thanks in advance
1