arduino UNO R3 and IDE 1.01
here is what i have so far, and what i would like it to do. but not sure how to go about it, the length of amount of serial data is not known for each burst of data, and there is no way to tell the program. what i do know is that if i dont recieve data any data within 40ms then i want program to continue then while it is reading data i want to wait up to 6ms to revieve the next byte. if 7ms passes then i want to break the read and send info to server.
byte serav = Serial.available();
byte seravcount = 0;
byte lprtemp[200];
//here i would like to start to wait for data for up to 40ms then continue program (with reading serial port)if nothing is recieved but i want to start reading serial port as soon as its available(even if its only been 5ms)
if (serav > 0) {
while (Serial.available())
{
seravcount = seravcount +1;
lprtemp[seravcount] = Serial.read();
// if serial is no longer availble i want to wait up to 6ms to see if more will come, if 7ms passes without any serial being available then i want to exit the while
}
}
//server is a ethernet/tcp link to a pc (this is working
server.write(seravcount);
for (byte x = 1; x < seravcount+1 ;x++)
server.write(lprtemp[x]);
i hope this makes sense
here is the way it should work
server requests data
wait for data up to 40ms /if 40ms passes with no serial input then will have program contine and send a message to server stating that
if serial data present at anytime up to 40 ms start reading it
as each byte is read wait up to 6ms for the next byte (exit the read if 7ms passes since last byte.
i do not want to use things like delay (6) since i could lose info that way if data is actually coming in alot faster. the device i am reading (i cannot change) can sned it bytes as slow as 5ms apart.
thanks in advance