File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
microcontroller-src/kv4p_ht_esp32_wroom_32 Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -278,11 +278,16 @@ void loop() {
278278 uint8_t tempBuffer[100 ]; // Big enough for a command and params, won't hold audio data
279279 int bytesRead = 0 ;
280280
281- while (bytesRead < (DELIMITER_LENGTH + 1 )) { // Read the delimiter and the command byte only (no params yet)
282- if (Serial.available ()) {
283- tempBuffer[bytesRead++] = Serial.read ();
281+ while (bytesRead < (DELIMITER_LENGTH)) { // Read the delimiter and the command byte only (no params yet)
282+ uint8_t tmp = Serial.read ();
283+ if (tmp != COMMAND_DELIMITER[bytesRead]) {
284+ // Not a delimiter. Reset.
285+ bytesRead = 0 ;
286+ continue ;
284287 }
288+ tempBuffer[bytesRead++] = tmp;
285289 }
290+ tempBuffer[DELIMITER_LENGTH] = Serial.read ();
286291 switch (tempBuffer[DELIMITER_LENGTH]) {
287292
288293 case COMMAND_STOP:
You can’t perform that action at this time.
0 commit comments