Hallo zusammen
ich habe eine Routine für das lesen der Kommandos aus der USB Schnittstelle. Die Schnittstelle bekommt die Daten vom PC bzw. Raspberry.
z.B:
Die Zykluszeit des Arduino beträgt ca. 400ms. Der PC kann die Kommandos schneller anliefern z.B. 2 oder 3 Kommandos innerhalb der Zykluszeit des Arduino.
Werden die Daten im Arduino (Betriebssystem) gepuffert, wie gross ist dieser Puffer?
Es kommt vor dass ich im Arduino überschriebene Kommandos sehe (hab sie zum PC gespiegelt)
ich rufe die Routine 1x im Zyklus des Arduino auf. Solange die Kommandos einzeln kommen ist alles richtig.
Code
void SerialParser(void)
{
// One command per line.
// Command Format: "up to 18 Letter command <\n>"
// count will be below Zero on a timeout.
// read up to X chars until EOT - in this case "\n"
ByteCount = -1;
ByteCount = Serial.readBytesUntil('\n', Buffer, bSize);
if (ByteCount > 0) strcpy(Command, strtok(Buffer, "\n"));
memset(Buffer, 0, sizeof(Buffer)); // Clear contents of Buffer
//Serial.flush();
}
Alles anzeigen