Add command 'getchipstatus'

This commit is contained in:
Niklas Cathor 2024-02-09 08:52:11 +01:00
parent 64defcaf22
commit 4765efc36e
3 changed files with 31 additions and 3 deletions

View File

@ -22,7 +22,7 @@ ArduinoJson::DynamicJsonDocument machineModeJson(8000);
enum machineModeInstruction lastReceivedInstruction = unknown;
char machineModeInstructionString[NUMBEROFINSTRUCTIONS][20] = {"unknown", "netlist", "getnetlist", "bridgelist", "getbridgelist", "lightnode", "lightnet", "getmeasurement", "gpio", "uart", "arduinoflash", "setnetcolor", "setnodecolor", "setsupplyswitch", "getsupplyswitch"};
char machineModeInstructionString[NUMBEROFINSTRUCTIONS][20] = {"unknown", "netlist", "getnetlist", "bridgelist", "getbridgelist", "lightnode", "lightnet", "getmeasurement", "gpio", "uart", "arduinoflash", "setnetcolor", "setnodecolor", "setsupplyswitch", "getsupplyswitch", "getchipstatus"};
enum machineModeInstruction parseMachineInstructions(int *sequenceNumber)
{
@ -810,3 +810,24 @@ void listBridgesMachine(void)
}
Serial.println("]");
}
void printChipStatusMachine() {
Serial.println("::chipstatus-begin");
for (int i = 0; i < 12; i++) {
Serial.print("::chipstatus[");
Serial.print(chipNumToChar(i));
Serial.print(",");
for (int j = 0; j < 16; j++) {
Serial.print(ch[i].xStatus[j]);
Serial.print(",");
}
for (int j = 0; j < 8; j++) {
Serial.print(ch[i].yStatus[j]);
if (j != 7) {
Serial.print(",");
}
}
Serial.println("]");
}
Serial.println("::chipstatus-end");
}

View File

@ -2,7 +2,7 @@
#ifndef MACHINECOMMANDS_H
#define MACHINECOMMANDS_H
#define NUMBEROFINSTRUCTIONS 16
#define NUMBEROFINSTRUCTIONS 17
enum machineModeInstruction
{
@ -20,7 +20,8 @@ enum machineModeInstruction
setnetcolor,
setnodecolor,
setsupplyswitch,
getsupplyswitch
getsupplyswitch,
getchipstatus
};
extern char inputBuffer[INPUTBUFFERLENGTH];
@ -48,4 +49,6 @@ int setSupplySwitch(void);
void listNetsMachine(void);
void listBridgesMachine(void);
void printChipStatusMachine();
#endif

View File

@ -705,6 +705,10 @@ if (millis() - lastTimeCommandRecieved > 100)
}
break;
case getchipstatus:
printChipStatusMachine();
break;
// case gpio:
// break;