MCPcopy Create free account
hub / github.com/BruceDevices/firmware / parseSerialCommand

Function parseSerialCommand

src/core/serialcmds.cpp:15–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13 char text[512]; // command size
14};
15bool parseSerialCommand(const String &command, bool waitForResponse) {
16 if (!cmdQueue || !rspQueue) {
17 Serial.println("Command or response queue not initialized");
18 return false;
19 }
20 CmdPacket packet;
21 memset(&packet, 0, sizeof(packet));
22 strncpy(packet.text, command.c_str(), sizeof(packet.text) - 1);
23
24 // Enqueue the command packet for processing
25 if (xQueueSend(cmdQueue, &packet, 0) != pdTRUE) {
26 Serial.println("Failed to send command to queue");
27 return false;
28 }
29 if (!waitForResponse) { return true; }
30 // Wait for the response
31 bool result;
32 if (xQueueReceive(rspQueue, &result, pdMS_TO_TICKS(20))) { return result; }
33 Serial.println("Failed to receive command response");
34 return false;
35}
36
37void handleSerialCommands(SerialCli &serialCli) {
38 CmdPacket packet;

Callers 2

receiveCommandsMethod · 0.85
configureWebServerFunction · 0.85

Calls 1

printlnMethod · 0.45

Tested by

no test coverage detected