Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions src/SerialCom.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,22 @@ namespace SerialCom {
}

Serial.print("Receiving:");
while (sensorSerial.available()) {
serialRxBuf[rxBufIdx++] = sensorSerial.read();
Serial.print(".");

// Without this delay, receiving data breaks for reasons that are beyond me
delay(15);

if (rxBufIdx >= 64) {
clearRxBuf();
long now = millis();
long lastMsg = now;
// wait for data with a timeout.
while (millis() - lastMsg < 15)
{
if (sensorSerial->available())
{
lastMsg = millis(); // re-init the timeout timer since we received new data.

serialRxBuf[rxBufIdx++] = sensorSerial->read();
Serial.print(".");

if (rxBufIdx >= 64)
{
clearRxBuf();
}
}
}
Serial.println("Done.");
Expand Down