This is my code
import processing.serial.*;
Serial myPort;
String aString = "HOMING_DONE";
String bString = "POSITION_REACHED_OK";
String testString;
String inPort;
void setup()
{
println("Setup() is running........");
println("Arduino found on Port: "+Serial.list());
println("Serial Port Assigning Started........");
myPort = new Serial(this , Serial.list()[0] , 115200);
println("Serial Port Assigning Ended........OK");
myPort.clear();
}
void draw() {
}
void serialEvent(Serial p)
{
inPort = p.readStringUntil('\n');
if(inPort != null) //this check is the key to making code in draw work
{
testString = inPort.trim();
print(testString);
if(testString.equals(aString) == true)
{
println(" <-- COMMAND_FOUND_OK");
// now send first line from txt file in format like ( 0,0,0,0,0,100,100,500,500,0 )
//myPort.write("0,0,0,0,0,100,100,500,500,0");
//wait for bString = "POSITION_REACHED_OK" and then next line ( repeat process until last line )
}
else if(testString.equals(bString) == true)
{
//problem is -> as soon I start code, this bString comes up ( I need to wait first for aString
// and then before sending each line need to wait for bString.
println(" <-- READY_TO_SEND");
}
else
{
println(" <-- CHECKING...");
}
}
}
and here is console output
Setup() is running…
Arduino found on Port: [Ljava.lang.String;@417b5e46
Serial Port Assigning Started…
Serial Port Assigning Ended…OK
POSITED_OK ← CHECKING…
POSITION_REACHED_OK ← READY_TO_SEND
HOMING_START ← CHECKING…
Z_HOME_OK ← CHECKING…
J3_HOME_OK ← CHECKING…
J2_HOME_OK ← CHECKING…
HOMING_DONE ← COMMAND_FOUND_OK
POSITION_REACHED_OK ← READY_TO_SEND
POSITION_REACHED_OK ← READY_TO_SEND
POSITION_REACHED_OK ← READY_TO_SEND
POSITION_REACHED_OK ← READY_TO_SEND
POSITION_REACHED_OK ← READY_TO_SEND
POSITION_REACHED_OK ← READY_TO_SEND