usnig readString working but , program got pause wherever no string available on Serial .it only resume
String data="";
void setup() {
Serial.begin(9600);
}
void loop() {
top:
if Serial.available()>0{//-------fisrt funtion it must run when data available on RX
Serial.println("Data recived from web it "):
data=Serial.readString();
if( Serial.readString()==NULL)goto top;
if(data.length();==23){
println("fist weigtment got ");
//in my main programm is send data on web server
}
if(data.length();==33){
println("Second weigtment got ");
//in my main programm is send data on web server
}
goto top;
}
if(! Serial.available()){//------this funtion must not work if any data avilable on RX
println("Doing less impoortant work ");
}
}
'while' or 'do-while'. You might have to re-structure your code so it makes sense... I'm not going to do the dirty work though. It's your hole, you can dig yourself out of it.
One thing I can help you with, if you can describe the program logic step by step in plain language, I and others can help you code it from scratch.
There is so much wrong with the code provided, did you even try compiling it ?
When you do get it to compile, you’ll have to start figuring out the runtime errors.
We like to help people that try, but correcting code that has no chance of working is lost time.
i am reading string using this program properly working . but some time there was use less data available on serial and this time program got paused at Seria.readString();
Maybe this will do what you want. At least it doesn't have all the errors in your original sketch.
String data;
void setup()
{
Serial.begin(9600);
}
void loop()
{
data = "";
if (Serial.available()) //-------first funtion it must run when data available on RX
{
Serial.println("Data recived from web it ");
data = Serial.readString();
}
if (data.length() == 23)
{
Serial.println("first weigtment got ");
//in my main programm is send data on web server
}
if (data.length() == 33)
{
Serial.println("Second weigtment got ");
//in my main programm is send data on web server
}
Serial.println("Doing less impoortant work ");
}
Sir am taking data from web_it (make from nuvaton controller) on stand by mode it send garbage data (on RX of my controller) continually . due to this i got
"Data received from web it " .
i want- if no useful data come on RX -----"Doing less important work" this should be done at this time. this is my actual problem
thanks for support.
In that case, you need to parse the input to identify valid input, so that you can reject the garbage data. As long as your code contains 'goto' statements, 99% of all C programmers will refuse to even look at it. It usually obfuscates the logic and sometimes even the purpose of the program. So please re-write it without using goto statements, and re-post.
You have both your original program, and a sample re-write to use. That should be enough to put together a creditable attempt.