Loading...
Logo
Processing Forum
I'm simply trying to initiate a serial port and encountered this error anytime I tried
Copy code
  1. myPort = new Serial(this, Serial.list()[ndx], 9600);      
where ndx is an int that cycles from 0 to < Serial.list().length. I thought it was my code and couldn't find any solution having read many many forum entries on this error. I then tried the "Simple Write" example that comes with P5 (v.1.5.1) and get the same error.

My RXTX versions are correct, and I get this before the error:

Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version   = RXTX-2.1-7

I can see and list my COM ports and print the following to the console:

serial port(s) found
[0] "COM1"
[1] "COM3"

However, as soon as I try to establish a port to communicate with I get the following error, every time:

Error Inside Serial.<init>()

gnu.io.PortInUseException: Unknown Application
at gnu.io.CommPortIdentifier.open(CommPortIdentifier.java:354)
at processing.serial.Serial.<init>(Unknown Source)
at processing.serial.Serial.<init>(Unknown Source)
at Comm2Hydra_not_working_v1.setup(Commtest_not_working_v1.java:57)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:662)
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 Comm2Hydra_not_working_v1.setup(Commtest_not_working_v1.java:57)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:662)


I know there are (and I have read them) many posts on this topic but none have a reason as to why this error occurs nor how to remedy this. It also baffles me as to why the example code also doesn't work, perhaps indicating that there is some library component missing in my P5 installation? However I've double-checked everything I can think of to no avail.

Any assistance on this would be very helpful as my project is now dead in the water until I can get past this error.

Thanks in advance



Replies(1)

Well, I'm answering my own question....

There's nothing wrong with the code. Once I plugged in the Arduino (Teensy++ in my case) it all worked just fine. I guess the non-Arduino COM ports on my system don't provide the response expected. Since my project needs to talk with an Arduino anyway I'm good to go. I'm therefore posting my own answer to help the next person faced with this dilemma from having to spend hours digging through posts.

If you're getting this error and have yet to connect your Arduino (or other device), doing so will likely resolve the issue.