I'm having problems with Processing3, where when I attempt to connect to a certain COM port, the app crashes, with the Port Busy error.
Here's the code snippet:
boolean found = false;
text(Arrays.toString(Serial.list()), 20, 500);
println("Still checking...");
for (String port : Serial.list()) {
myPort = new Serial(this, port);
myPort.clear();
myPort.write("init\n");
if (myPort.readStringUntil(lf) == "connected") {
found = true;
break;
}
}
if (!found) {
myPort = emptyPort;
text("Waiting for device...", 20, 40);
}
This is part of the draw() loop, the error is thrown at line 5 in this example. Until that particular port becomes available, everything else is running just fine.
This is the setup() code from the connected arduino:
Serial.begin(256000);
while (!Serial.available()) {}
while (true) {
String recv = Serial.readStringUntil('\n');
if (recv == "init") {
Serial.println("connected");
break;
} else {
while (!Serial.available()) {}
}
}
Serial.println("600,400");
Testing from the Serial Monitor in Arduino IDE produces no such error.