From 4765efc36e187b3fda32f2a074da1a4d294c735d Mon Sep 17 00:00:00 2001 From: Niklas Cathor Date: Fri, 9 Feb 2024 08:52:11 +0100 Subject: [PATCH] Add command 'getchipstatus' --- JumperlessNano/src/MachineCommands.cpp | 23 ++++++++++++++++++++++- JumperlessNano/src/MachineCommands.h | 7 +++++-- JumperlessNano/src/main.cpp | 4 ++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/JumperlessNano/src/MachineCommands.cpp b/JumperlessNano/src/MachineCommands.cpp index f6f6472..51c2edb 100644 --- a/JumperlessNano/src/MachineCommands.cpp +++ b/JumperlessNano/src/MachineCommands.cpp @@ -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"); +} diff --git a/JumperlessNano/src/MachineCommands.h b/JumperlessNano/src/MachineCommands.h index ae04993..207f2fe 100644 --- a/JumperlessNano/src/MachineCommands.h +++ b/JumperlessNano/src/MachineCommands.h @@ -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 diff --git a/JumperlessNano/src/main.cpp b/JumperlessNano/src/main.cpp index 1ee20b1..c99e500 100644 --- a/JumperlessNano/src/main.cpp +++ b/JumperlessNano/src/main.cpp @@ -705,6 +705,10 @@ if (millis() - lastTimeCommandRecieved > 100) } break; + case getchipstatus: + printChipStatusMachine(); + break; + // case gpio: // break;