I have an arduino that prints 'T' on its serial port every 100 millisecs. I want to write a processing program that looks at all serial ports on the PC and find the one that the arduino is attached to. I'm sure someone would have done this before but couldn't find anything in my searches. The code I am trying looks like the following:
long millisStart;
int i = 0;
int len=Serial.list().length;
println(Serial.list());
println("Serial Port Count = " + len);
for ( i = 0; i < len; i++)
{
arduinoPort = new Serial(this, Serial.list()[i], 9600); // start arduino communications
millisStart = millis();
println("Testing port " + i);
while ((millis() - millisStart) < 10000) ;
arduinoPort.clear();
arduinoPort.bufferUntil('T');
if(arduinoPort.available()>0)
{
println("Char available");
int c = arduinoPort.readChar();
println("Char = " + c);