Is it mandatory to call SerialX.read() in serialEventX() even when data is not my use?
Is this Particle related? or Arduino?
its related to particle
Why would you not want to read the data and use
But the plain answer is: “It’s not mandatory.”
based on some condition i want to read data (calls SerialX.read())
if condition is false i wont read data
–> so this causing the app running only in that particular serialEvent() only until i read data from that
i tested above said
in serialEvent1() i want to read only when lock1== true then only calling Serial1.read()
if not i was not calling Serial1.read()
then the app was looping in serialEvent1() until read data
That is perfectly acceptable, you just need to be aware that if you don’t regularly flush the buffer you will eventually lose data (buffer is 64byte) and once you start reading, you’ll possibly find some old garbage data in the buffer that arrived while your condition wasn’t sattisfied.
serialEvent1() should only be implemented as a function that does not trap the code flow - you enter, act and leave the function - no prolonged looping!
thanks for suggestion…
i was just confirming it
the code snippet should be
Serial.println(" event weight");
if(lock1 == true)
char a = Serial1.read();