Skip to content

Commit

Permalink
made rpc comms more sensical
Browse files Browse the repository at this point in the history
  • Loading branch information
markzakharyan committed Aug 28, 2024
1 parent 34f8fd6 commit 710fd4a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
23 changes: 9 additions & 14 deletions m4/src/UserIOHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,17 @@ struct UserIOHandler {


static std::vector<String> query_rpc() {
char received = '\0';
String inByte = "";
String input = RPC.readStringUntil('\n');
input.trim();
std::vector<String> comm;
while (received != '\r') // Wait for carriage return
{
if (RPC.available()) {
received = RPC.read();
if (received == '\n' || received == ' ') {
} else if (received == ',' || received == '\r') {
comm.push_back(inByte); // Adds string to vector of command arguments
inByte = ""; // Resets to a null string for the next word
} else {
inByte += received; // Adds newest char to end of string
}
}
int startPos = 0;
int commaPos = input.indexOf(',');
while (commaPos != -1) {
comm.push_back(input.substring(startPos, commaPos));
startPos = commaPos + 1;
commaPos = input.indexOf(',', startPos);
}
comm.push_back(input.substring(startPos));
return comm;
}

Expand Down
1 change: 0 additions & 1 deletion m7/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ void setup() {
RPC.begin();
}

int i = 0;
void loop() {
String buffer = "";
while (RPC.available()) {
Expand Down

0 comments on commit 710fd4a

Please sign in to comment.