hi everyone, i’m a new member, and i’m using processing recently.
I am currently having difficulty with the “readStringUntil ()” function.
Processing communicates with Arduino via LAN, but if the connection fails, the program stops and waits for the “new line” marker, which however, as there is no connection, will not arrive.
is there any way to set some sort of timeout to exit the readStringUntil () function in case of no connection?
I am attaching the part of the code concerned.
import processing.net.*;
Client myClient;
String inString = null;
byte interesting = 10;
String [] data;
int mem4;
int mem5;
int mem6;
int mem8;
int mem9;
int mem10;
int mem11;
int mem13;
int mem15;
int mem16;
int mem17;
void setup() {
fullScreen();
frameRate(10);
myClient = new Client(this, "192.168.1.177", 3000);
delay(2000);
}
void draw() {
background(#989890);
while (myClient.available () >0) {
inString = myClient.readStringUntil(interesting);
if (inString!=null) {
data=split(inString, ",");
mem4=int(data[0]);
mem5=int(data[1]);
mem6=int(data[2]);
mem7=int(data[3]);
mem8=int(data[4]);
mem9=int(data[5]);
mem10=int(data[6]);
mem11=int(data[7]);
mem12=int(data[8]);
mem13=int(data[9]);
mem14=int(data[10]);
mem15=int(data[11]);
mem16=int(data[12]);
mem17=int(data[13]);
}
}