Talking to a serial device,
The device respond to me with 9 bytes
First byte is NULL then 7 randon bytes and then last byte is NULL
The problem I have is that even tho the 9 bytes are sent all together (at 9600baud) with just a few ms total transmision time Serial1.available() always reports 1 never 9!
Im starting to think perhaps its the NULL that terminates.
So i have tried with a flush and a read() to get rid of the first byte but the rest of the 8 never gets "seen"
I know 9 bytes comes, i can see them on my serial sniffer.
Here is part of my code, that run directly after i query my serial decive and it sends its responce
byte temp = Serial1.read();
//Serial1.flush();
Serial.print("0 milli");
Serial.println(Serial1.available());
delay(20);
Serial.print("20 milli");
Serial.println(Serial1.available());
delay(50);
Serial.print("50 milli");
Serial.println(Serial1.available());
delay(100);
Serial.print("100 milli");
Serial.println(Serial1.available());
delay(200);
Serial.print("200 milli");
Serial.println(Serial1.available());
delay(300);
Serial.print("300 milli");
Serial.println(Serial1.available());
delay(400);
Serial.print("400 milli");
Serial.println(Serial1.available());
delay(500);
Serial.print("500 milli");
Serial.println(Serial1.available());
my output from Serial.println(Serial1.available()); is 0 on all prints, If i remove the Serial1.read i will get 1 on all Serial.println(Serial1.available());
The device respond to me with 9 bytes
First byte is NULL then 7 randon bytes and then last byte is NULL
The problem I have is that even tho the 9 bytes are sent all together (at 9600baud) with just a few ms total transmision time Serial1.available() always reports 1 never 9!
Im starting to think perhaps its the NULL that terminates.
So i have tried with a flush and a read() to get rid of the first byte but the rest of the 8 never gets "seen"
I know 9 bytes comes, i can see them on my serial sniffer.
Here is part of my code, that run directly after i query my serial decive and it sends its responce
byte temp = Serial1.read();
//Serial1.flush();
Serial.print("0 milli");
Serial.println(Serial1.available());
delay(20);
Serial.print("20 milli");
Serial.println(Serial1.available());
delay(50);
Serial.print("50 milli");
Serial.println(Serial1.available());
delay(100);
Serial.print("100 milli");
Serial.println(Serial1.available());
delay(200);
Serial.print("200 milli");
Serial.println(Serial1.available());
delay(300);
Serial.print("300 milli");
Serial.println(Serial1.available());
delay(400);
Serial.print("400 milli");
Serial.println(Serial1.available());
delay(500);
Serial.print("500 milli");
Serial.println(Serial1.available());
my output from Serial.println(Serial1.available()); is 0 on all prints, If i remove the Serial1.read i will get 1 on all Serial.println(Serial1.available());