void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
delay(1000);
//Serial.setTimeout(1);
Serial.println("We're off!!!");
}
int msg_size = 20;
char msg [20];
uint16_t count = 0;
int size;
uint32_t start;
void loop() {
// put your main code here, to run repeatedly:
//uint8_t comm_data;
while (Serial.available() > 0) {
if (count == 0)start = micros();
char inChar = Serial.read();
msg[count] = inChar;
count++;
if (inChar == '\n' && msg[0] == '<') {
msg[count - 1] = '\0';
Serial.println(msg);
msg[0] = 0;
count = 0;
Serial.println(micros() - start);
}
}
}
/*
byte SOT = '<'; //Start Of Text
byte buffer[20];
uint32_t start;
void setup() {
Serial.begin(115200);
Serial.setTimeout(1);
Serial.println("Off we go");
}
void loop() {
while (Serial.available () > 0) {
//Serial.println(millis());
start = micros();
byte in_byte = Serial.read();
if (in_byte == SOT) {
int bytesRead = Serial.readBytesUntil('\n', buffer, 20);
Serial.write(buffer, bytesRead);
Serial.println(micros() - start);
Serial.println("Done");
}
}
}
*/