Created
April 17, 2023 07:49
-
-
Save reefwing/a3c63b9ba5de23f82a2a8e627939f23c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void checkForCommand() { | |
char buffer[BUFFER_SIZE]; | |
// Check for xIMU3 Command Messages | |
if (Serial.available() > 0) { | |
// read the incoming bytes: | |
int blen = Serial.readBytesUntil(STOP_BYTE, buffer, BUFFER_SIZE); | |
bool cmdFound = false; | |
// Command character count | |
int index = 0; | |
for(int i = 0; i < blen; i++) { | |
// Extract Command | |
if (buffer[i] == CMD_BYTE) { | |
cmdFound = !cmdFound; | |
} | |
else if (cmdFound) { | |
cmd[index] = buffer[i]; | |
index++; | |
} | |
} | |
cmd[index] = NULL_TERMINATOR; | |
} | |
else { | |
cmd[0] = NULL_TERMINATOR; | |
} | |
} | |
bool newCommand() { | |
if (cmd[0] == NULL_TERMINATOR) { | |
return false; | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment