diff --git a/Firmware/LoRaSerial/Commands.ino b/Firmware/LoRaSerial/Commands.ino index 3f3f3da2..a054b0d2 100644 --- a/Firmware/LoRaSerial/Commands.ino +++ b/Firmware/LoRaSerial/Commands.ino @@ -224,6 +224,7 @@ bool commandAT(const char * commandString) systemPrintln(" ATI8 - Display system unique ID"); systemPrintln(" ATI9 - Display the maximum datagram size"); systemPrintln(" ATI10 - Display radio metrics"); + systemPrintln(" ATI11 - Display the system runtime"); //Virtual circuit information commands systemPrintln(" ATI30 - Return myVc value"); @@ -601,6 +602,32 @@ bool commandAT(const char * commandString) systemPrintln(" State History"); displayRadioStateHistory(); return true; + + case ('1'): //ATI11 - Display the system runtime + systemPrint("Runtime: "); + systemPrintU64(runtime.u64); + systemPrint(", Programmed: "); + systemPrintU64(programmed); + systemPrintln(); + if (settings.operatingMode == MODE_VIRTUAL_CIRCUIT) + { + VC_RUNTIME_MESSAGE msg; + uint8_t * data; + + //Build the runtime message + memcpy(&msg.runtime, &runtime.u64, sizeof(msg.runtime)); + memcpy(&msg.programmed, &programmed, sizeof(msg.programmed)); + + //Send the message + systemWrite(START_OF_VC_SERIAL); //Start byte + systemWrite(3 + sizeof(VC_RUNTIME_MESSAGE)); //Length + systemWrite(PC_RUNTIME); //Destination + systemWrite(myVc); //Source + data = (uint8_t *)&msg; + for (int index = 0; index < sizeof(msg); index++) + systemWrite(*data++); + } + return true; } } if ((commandString[2] == 'I') && (commandString[3] == '3') && (commandLength == 5)) diff --git a/Firmware/LoRaSerial/LoRaSerial.ino b/Firmware/LoRaSerial/LoRaSerial.ino index 2f6906bf..eb33984f 100644 --- a/Firmware/LoRaSerial/LoRaSerial.ino +++ b/Firmware/LoRaSerial/LoRaSerial.ino @@ -521,6 +521,12 @@ Settings tempSettings; //Temporary settings used for command processing Settings trainingSettings; //Settings used for training other radios char platformPrefix[25]; //Used for printing platform specific device name, ie "SAMD21 1W 915MHz" +union { + uint32_t u32[2]; + uint64_t u64; +} runtime; //Amount of time the system has been running in milliseconds +uint64_t programmed; //Time the system was programmed in milliseconds + //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- /* @@ -660,6 +666,12 @@ void loop() { petWDT(); + //Update the runtime + uint32_t currentMillis = millis(); + if (currentMillis < runtime.u32[0]) + runtime.u32[1] += 1; + runtime.u32[0] = currentMillis; + updateButton(); //Check if train button is pressed updateSerial(); //Store incoming and print outgoing diff --git a/Firmware/LoRaSerial/System.ino b/Firmware/LoRaSerial/System.ino index 37ab2d14..0da76963 100644 --- a/Firmware/LoRaSerial/System.ino +++ b/Firmware/LoRaSerial/System.ino @@ -23,6 +23,14 @@ void systemPrint(int value) systemPrint(temp); } +//Print an integer value +void systemPrintU64(uint64_t value) +{ + char temp[20 + 1]; + sprintf(temp, "%ld", value); + systemPrint(temp); +} + //Print an integer value as HEX or decimal void systemPrint(int value, uint8_t printType) { diff --git a/Firmware/LoRaSerial/Virtual_Circuit_Protocol.h b/Firmware/LoRaSerial/Virtual_Circuit_Protocol.h index d55f1048..3f2b05b2 100644 --- a/Firmware/LoRaSerial/Virtual_Circuit_Protocol.h +++ b/Firmware/LoRaSerial/Virtual_Circuit_Protocol.h @@ -31,18 +31,19 @@ //Address space 7 is reserved for the following special addresses: #define VC_RSVD_SPECIAL_VCS ((int8_t)(VCAB_CHANNEL_MASK << VCAB_NUMBER_BITS)) -#define VC_BROADCAST ((int8_t)(VC_RSVD_SPECIAL_VCS | VCAB_NUMBER_MASK)) -#define VC_COMMAND (VC_BROADCAST - 1) //Command input and command response -#define VC_UNASSIGNED (VC_COMMAND - 1) -#define VC_IGNORE_TX (VC_UNASSIGNED - 1) +#define VC_BROADCAST ((int8_t)(VC_RSVD_SPECIAL_VCS | VCAB_NUMBER_MASK)) //0xff +#define VC_COMMAND (VC_BROADCAST - 1) //0xfe: Command input and command response +#define VC_UNASSIGNED (VC_COMMAND - 1) //0xfd +#define VC_IGNORE_TX (VC_UNASSIGNED - 1) //0xfc //Source and destinations reserved for the local host -#define PC_COMMAND VC_RSVD_SPECIAL_VCS //Command input and command response -#define PC_LINK_STATUS (PC_COMMAND + 1) //Asynchronous link status output -#define PC_DATA_ACK (PC_LINK_STATUS + 1)//Indicate data delivery success -#define PC_DATA_NACK (PC_DATA_ACK + 1) //Indicate data delivery failure -#define PC_SERIAL_RECONNECT (PC_DATA_NACK + 1) //Disconnect/reconnect the serial port over LoRaSerial CPU reset -#define PC_COMMAND_COMPLETE (PC_SERIAL_RECONNECT + 1)//Command complete +#define PC_COMMAND VC_RSVD_SPECIAL_VCS //0xe0: Command input and command response +#define PC_LINK_STATUS (PC_COMMAND + 1) //0xe1: Asynchronous link status output +#define PC_DATA_ACK (PC_LINK_STATUS + 1)//0xe2: Indicate data delivery success +#define PC_DATA_NACK (PC_DATA_ACK + 1) //0xe3: Indicate data delivery failure +#define PC_SERIAL_RECONNECT (PC_DATA_NACK + 1) //0xe4: Disconnect/reconnect the serial port over LoRaSerial CPU reset +#define PC_COMMAND_COMPLETE (PC_SERIAL_RECONNECT + 1) //0xe5: Command complete +#define PC_RUNTIME (PC_COMMAND_COMPLETE + 1) //0xe6: Radio uptime //Address space 1 and 6 are reserved for the host PC interface to support remote //command processing. The radio removes these bits and converts them to the @@ -177,6 +178,12 @@ typedef struct _VC_COMMAND_COMPLETE_MESSAGE uint8_t cmdStatus; //Command status } VC_COMMAND_COMPLETE_MESSAGE; +typedef struct _VC_RUNTIME_MESSAGE +{ + uint64_t runtime; //Time the system has been running in milliseconds + uint64_t programmed; //Time the system was programmed in milliseconds +} VC_RUNTIME_MESSAGE; + //------------------------------------------------------------------------------ // Macros //------------------------------------------------------------------------------ diff --git a/Firmware/Tools/VcServerTest.c b/Firmware/Tools/VcServerTest.c index 28de675f..abb17ac7 100644 --- a/Firmware/Tools/VcServerTest.c +++ b/Firmware/Tools/VcServerTest.c @@ -7,9 +7,9 @@ #define POLL_TIMEOUT_USEC 1000 #endif // POLL_TIMEOUT_USEC -#define ONE_SECOND_COUNT 20 // (1000000 / POLL_TIMEOUT_USEC) +#define ONE_SECOND_COUNT (1000000 / POLL_TIMEOUT_USEC) #define COMMAND_POLL_COUNT (ONE_SECOND_COUNT / 10) //100 mSec -#define STALL_CHECK_COUNT 15 * ONE_SECOND_COUNT //15 Sec +#define STALL_CHECK_COUNT 5 * ONE_SECOND_COUNT //5 Sec #define BUFFER_SIZE 2048 #define INPUT_BUFFER_SIZE BUFFER_SIZE @@ -21,8 +21,9 @@ #define BREAK_LINKS_COMMAND "atb" #define GET_DEVICE_INFO "ati" #define GET_MY_VC_ADDRESS "ati30" +#define GET_RUNTIME "ati11" #define GET_UNIQUE_ID "ati8" -#define GET_VC_STATE "ati12" +#define GET_VC_STATE "ati31" #define GET_VC_STATUS "ata" #define LINK_RESET_COMMAND "atz" #define MY_VC_ADDRESS "myVc: " @@ -35,11 +36,12 @@ #define DISPLAY_COMMAND_COMPLETE 0 #define DISPLAY_DATA_ACK 0 #define DISPLAY_DATA_NACK 1 +#define DISPLAY_RESOURCE_USAGE 0 +#define DISPLAY_RUNTIME 0 #define DISPLAY_STATE_TRANSITION 0 #define DISPLAY_UNKNOWN_COMMANDS 0 #define DISPLAY_VC_STATE 0 #define DUMP_RADIO_TO_PC 0 -#define SEND_ATC_COMMAND 1 #define QUEUE_T uint32_t #define QUEUE_T_BITS ((int)(sizeof(QUEUE_T) * 8)) @@ -90,43 +92,23 @@ typedef enum { //List commands in priority order - CMD_ATI11 = 0, //Get myVC + CMD_ATI30 = 0, //Get myVC CMD_ATB, //Break all VC links + CMD_ATI, //Get the device type + CMD_ATI8, //Get the radio's unique ID CMD_ATA, //Get VC status + + //Connect to the remote radio CMD_AT_CMDVC, //Select target VC CMD_ATC, //Start the 3-way handshake CMD_WAIT_CONNECTED, //Wait until the client is connected - CMD_AT_CMDVC_2, //Select target VC - CMD_ATI12, //Get the VC state - CMD_GET_SERVER_MODEL, //Get the model name - CMD_GET_CLIENT_MODEL, //Get the model name - CMD_ATI, //Get the device type - CMD_ATI8, //Get the radio's unique ID - CMD_AT_DISABLE_CONTROLLER, //Disable the sprinkler controller - CMD_AT_DAY_OF_WEEK, //Set the day of week - CMD_AT_TIME_OF_DAY, //Set the time of day - CMD_ATI89, //Display the date and time - - //Select the solenoids for each of the zone - CMD_SELECT_ZONE, //Select the zone number - CMD_SELECT_SOLENOID, //Select the solenoid for the zone - COMPLETE_ZONE_CONFIGURATION,//Verify that all of the zones are configured - - //Set the start times - CMD_SET_DAY_OF_WEEK, //Set the day of the week - CMD_SET_START_TIME, //Set the start time - CMD_SET_ALL_START_TIMES, //Verify that all of the start times are set - - //Set the zone durations - CMD_SET_DAY_OF_WEEK_2, //Set the day of the week - CMD_SELECT_ZONE_2, //Select the zone number - CMD_SET_ZONE_DURATION, //Set the zone on duration - CMD_SET_ALL_DURATIONS, //Verify that all of the durations are set -/* -#define SET_MANUAL_ON "AT-ZoneManualOn=" -#define SET_ZONE_DURATION "AT-ZoneDuration=" -*/ + //Get remote radio connection status, type and ID + CMD_AT_CMDVC_2, //Select target VC + CMD_ATI31, //Get the VC state + CMD_ATI_2, //Get the device type + CMD_ATI8_2, //Get the radio's unique ID + CMD_ATI11, //Get the runtime //Last in the list CMD_LIST_SIZE @@ -134,21 +116,19 @@ typedef enum const char * const commandName[] = { - "ATI11", "ATIB", "ATA", "AT-CMDVC", "ATC", "WAIT_CONNECT", "AT-CMDVC_2", "ATI12", - "ATI93", "ATI81", "ATI", "ATI8", "AT-EnableController=0", - "AT-DayOfWeek", "AT-TimeOfDay", "ATI89", - "AT-CommandZone", "AT-LatchingSolenoid", "COMPLETE_ZONE_CONFIGURATION", - "AT-CommandDay", "AT-StartTime", "CMD_SET_ALL_START_TIMES", - "AT-CommandDay-2", "AT-CommandZone-2", "AT-ZoneDuration", "CMD_SET_ALL_DURATIONS", + "ATI30", "ATIB", "ATI", "ATI8", "ATA", "AT-CMDVC", "ATC", + "WAIT_CONNECT", + "AT-CMDVC_2", "ATI31", "ATI_2", "ATI8_2", "ATI11", }; - typedef struct _VIRTUAL_CIRCUIT { int vcState; uint32_t activeCommand; QUEUE_T commandQueue[COMMAND_QUEUE_SIZE]; uint32_t commandTimer; + uint64_t programmed; + uint64_t runtime; uint8_t uniqueId[UNIQUE_ID_BYTES]; bool valid; } VIRTUAL_CIRCUIT; @@ -161,7 +141,7 @@ int myVc = VC_SERVER; uint8_t outputBuffer[VC_SERIAL_HEADER_BYTES + BUFFER_SIZE]; uint32_t pcActiveCommand = CMD_LIST_SIZE; char pcCommandBuffer[128]; -uint8_t pcCommandQueue[COMMAND_QUEUE_SIZE]; +QUEUE_T pcCommandQueue[COMMAND_QUEUE_SIZE]; uint32_t pcCommandTimer; int pcCommandVc = MAX_VC; uint8_t remoteCommandVc; @@ -470,7 +450,6 @@ int hostToStdout(VC_SERIAL_MESSAGE_HEADER * header, uint8_t * data, uint8_t byte void radioToPcLinkStatus(VC_SERIAL_MESSAGE_HEADER * header, uint8_t * data, uint8_t length) { - int durationBase; int newState; int previousState; int srcVc; @@ -554,9 +533,15 @@ void radioToPcLinkStatus(VC_SERIAL_MESSAGE_HEADER * header, uint8_t * data, uint { if (DEBUG_PC_CMD_ISSUE) printf("VC %d ALIVE\n", srcVc); - COMMAND_ISSUE(virtualCircuitList[srcVc].commandQueue, virtualCircuitList[srcVc].commandTimer, CMD_AT_CMDVC); - COMMAND_ISSUE(virtualCircuitList[srcVc].commandQueue, virtualCircuitList[srcVc].commandTimer, CMD_ATC); - COMMAND_ISSUE(virtualCircuitList[srcVc].commandQueue, virtualCircuitList[srcVc].commandTimer, CMD_WAIT_CONNECTED); + COMMAND_ISSUE(virtualCircuitList[srcVc].commandQueue, + virtualCircuitList[srcVc].commandTimer, + CMD_AT_CMDVC); + COMMAND_ISSUE(virtualCircuitList[srcVc].commandQueue, + virtualCircuitList[srcVc].commandTimer, + CMD_ATC); + COMMAND_ISSUE(virtualCircuitList[srcVc].commandQueue, + virtualCircuitList[srcVc].commandTimer, + CMD_WAIT_CONNECTED); } if (DISPLAY_VC_STATE) @@ -591,28 +576,33 @@ void radioToPcLinkStatus(VC_SERIAL_MESSAGE_HEADER * header, uint8_t * data, uint case VC_STATE_CONNECTED: if (DEBUG_PC_CMD_ISSUE) printf("VC %d CONNECTED\n", srcVc); - if (myVc == VC_SERVER) + if (COMMAND_PENDING(pcCommandQueue, CMD_ATC) + && (pcActiveCommand == CMD_ATC) && (srcVc == pcCommandVc)) { if (virtualCircuitList[srcVc].activeCommand == CMD_ATC) COMMAND_COMPLETE(virtualCircuitList[srcVc].commandQueue, virtualCircuitList[srcVc].activeCommand); - - //Get the device information - if (srcVc == VC_SERVER) - { - COMMAND_ISSUE(pcCommandQueue, pcCommandTimer, CMD_ATI); - COMMAND_ISSUE(pcCommandQueue, pcCommandTimer, CMD_ATI8); - } - else - { - COMMAND_ISSUE(virtualCircuitList[srcVc].commandQueue, virtualCircuitList[srcVc].commandTimer, CMD_AT_CMDVC_2); - COMMAND_ISSUE(virtualCircuitList[srcVc].commandQueue, virtualCircuitList[srcVc].commandTimer, CMD_ATI12); - COMMAND_ISSUE(virtualCircuitList[srcVc].commandQueue, virtualCircuitList[srcVc].commandTimer, CMD_ATI); - COMMAND_ISSUE(virtualCircuitList[srcVc].commandQueue, virtualCircuitList[srcVc].commandTimer, CMD_ATI8); - } + COMMAND_COMPLETE(pcCommandQueue, pcActiveCommand); } - COMMAND_COMPLETE(pcCommandQueue, pcActiveCommand); if (DISPLAY_VC_STATE) printf("======= VC %d CONNECTED ======\n", srcVc); + if (srcVc != myVc) + { + COMMAND_ISSUE(virtualCircuitList[srcVc].commandQueue, + virtualCircuitList[srcVc].commandTimer, + CMD_AT_CMDVC_2); + COMMAND_ISSUE(virtualCircuitList[srcVc].commandQueue, + virtualCircuitList[srcVc].commandTimer, + CMD_ATI31); + COMMAND_ISSUE(virtualCircuitList[srcVc].commandQueue, + virtualCircuitList[srcVc].commandTimer, + CMD_ATI_2); + COMMAND_ISSUE(virtualCircuitList[srcVc].commandQueue, + virtualCircuitList[srcVc].commandTimer, + CMD_ATI8_2); + COMMAND_ISSUE(virtualCircuitList[srcVc].commandQueue, + virtualCircuitList[srcVc].commandTimer, + CMD_ATI11); + } break; } @@ -657,6 +647,23 @@ void radioDataNack(VC_SERIAL_MESSAGE_HEADER * header, uint8_t * data, uint8_t le virtualCircuitList[vcIndex].vcState = VC_STATE_LINK_DOWN; } +void radioRuntime(VC_SERIAL_MESSAGE_HEADER * header, uint8_t * data, uint8_t length) +{ + int index; + int vcIndex; + VC_RUNTIME_MESSAGE * vcMsg; + + vcMsg = (VC_RUNTIME_MESSAGE *)data; + vcIndex = header->radio.srcVc & VCAB_NUMBER_MASK; + if (DISPLAY_RUNTIME) + printf("VC %d runtime: %lld, programmed: %lld\n", + vcIndex, (long long)vcMsg->runtime, (long long)vcMsg->programmed); + + //Set the time values + memcpy(&virtualCircuitList[vcIndex].runtime, &vcMsg->runtime, sizeof(vcMsg->runtime)); + memcpy(&virtualCircuitList[vcIndex].programmed, &vcMsg->programmed, sizeof(vcMsg->programmed)); +} + void radioCommandComplete(VC_SERIAL_MESSAGE_HEADER * header, uint8_t * data, uint8_t length) { VC_COMMAND_COMPLETE_MESSAGE * vcMsg; @@ -673,20 +680,23 @@ void radioCommandComplete(VC_SERIAL_MESSAGE_HEADER * header, uint8_t * data, uin { if (pcCommandVc < MAX_VC) { - COMMAND_COMPLETE(virtualCircuitList[pcCommandVc].commandQueue, virtualCircuitList[pcCommandVc].activeCommand); + COMMAND_COMPLETE(virtualCircuitList[pcCommandVc].commandQueue, + virtualCircuitList[pcCommandVc].activeCommand); } COMMAND_COMPLETE(pcCommandQueue, pcActiveCommand); } else if (virtualCircuitList[pcCommandVc].activeCommand < CMD_LIST_SIZE) { //This was a VC command - COMMAND_COMPLETE(virtualCircuitList[srcVc].commandQueue, virtualCircuitList[srcVc].activeCommand); + COMMAND_COMPLETE(virtualCircuitList[srcVc].commandQueue, + virtualCircuitList[srcVc].activeCommand); } } else { //This was a VC command - COMMAND_COMPLETE(virtualCircuitList[srcVc].commandQueue, virtualCircuitList[srcVc].activeCommand); + COMMAND_COMPLETE(virtualCircuitList[srcVc].commandQueue, + virtualCircuitList[srcVc].activeCommand); } vcMsg = (VC_COMMAND_COMPLETE_MESSAGE *)data; @@ -697,6 +707,78 @@ void radioCommandComplete(VC_SERIAL_MESSAGE_HEADER * header, uint8_t * data, uin waitingForCommandComplete = false; } +int commandResponse(uint8_t * data, uint8_t length) +{ + uint8_t * dataStart; + uint8_t * dataEnd; + VC_SERIAL_MESSAGE_HEADER * header; + int status; + + dataEnd = &data[length]; + status = 0; + do + { + dataStart = data; + + //Walk through the command response looking for an embedded VC message + while ((data < dataEnd) && (*data != START_OF_VC_SERIAL)) + data++; + + //Output the serial data + length = data - dataStart; + if (length) + { + status = hostToStdout(NULL, dataStart, length); + if (status) + break; + } + + //Determine if there is an embedded VC message + if (data >= dataEnd) + break; + + //Verify that the entire VC message is in the buffer + header = (VC_SERIAL_MESSAGE_HEADER *)data; + data++; //Skip over the START_OF_VC_SERIAL byte + if ((data >= dataEnd) || (&data[*data] > dataEnd)) + { + fprintf(stderr, "ERROR: VC message not fully contained in command response"); + status = -20; + break; + } + + //Locate the VC message header and the remainder of the command response + length = header->radio.length; + dataStart = &data[VC_RADIO_HEADER_BYTES]; + data += length; + length -= VC_RADIO_HEADER_BYTES; + + //Display the VC header and message + if (DEBUG_RADIO_TO_PC) + { + printf("VC Header:\n"); + printf(" length: %d\n", header->radio.length); + printf(" destVc: %d (0x%02x)\n", (uint8_t)header->radio.destVc, (uint8_t)header->radio.destVc); + printf(" srcVc: %d (0x%02x)\n", header->radio.srcVc, header->radio.srcVc); + if (length > 0) + dumpBuffer(dataStart, length); + } + + //------------------------------ + //Process the message + //------------------------------ + + //Display radio runtime + if (header->radio.destVc == PC_RUNTIME) + radioRuntime(header, dataStart, length); + + //Dump the unknown VC message + else + dumpBuffer((uint8_t*)header, length + VC_SERIAL_HEADER_BYTES); + } while (data < dataEnd); + return status; +} + int radioToHost() { int bytesRead; @@ -801,7 +883,7 @@ int radioToHost() //Display remote command response else if (header->radio.destVc == (PC_REMOTE_RESPONSE | myVc)) - status = hostToStdout(header, data, length); + status = commandResponse(data, length); //Display command completion status else if (header->radio.destVc == PC_COMMAND_COMPLETE) @@ -815,6 +897,10 @@ int radioToHost() else if (header->radio.destVc == PC_DATA_NACK) radioDataNack(header, data, length); + //Display radio runtime + else if (header->radio.destVc == PC_RUNTIME) + radioRuntime(header, data, length); + //Display received messages else if ((header->radio.destVc == myVc) || (header->radio.destVc == VC_BROADCAST)) { @@ -863,27 +949,39 @@ void issuePcCommands() pcActiveCommand = cmd; switch (cmd) { - case CMD_ATB: //Break all of the VC links - if (DEBUG_PC_CMD_ISSUE) - printf("Issuing ATB command\n"); - cmdToRadio((uint8_t *)BREAK_LINKS_COMMAND, strlen(BREAK_LINKS_COMMAND)); - return; - - case CMD_ATI11: //Get myVC + case CMD_ATI30: //Get myVC if (myVc == VC_UNASSIGNED) { //Get myVc address if (DEBUG_PC_CMD_ISSUE) - printf("Issuing ATI11 command\n"); + printf("Issuing ATI30 command\n"); findMyVc = true; cmdToRadio((uint8_t *)GET_MY_VC_ADDRESS, strlen(GET_MY_VC_ADDRESS)); return; } if (DEBUG_PC_CMD_ISSUE) - printf("Skipping ATI11 command, myVC already known\n"); + printf("Skipping ATI30 command, myVC already known\n"); COMMAND_COMPLETE(pcCommandQueue, pcActiveCommand); break; + case CMD_ATB: //Break all of the VC links + if (DEBUG_PC_CMD_ISSUE) + printf("Issuing ATB command\n"); + cmdToRadio((uint8_t *)BREAK_LINKS_COMMAND, strlen(BREAK_LINKS_COMMAND)); + return; + + case CMD_ATI: + if (DEBUG_PC_CMD_ISSUE) + printf("Issuing ATI command\n"); + cmdToRadio((uint8_t *)GET_DEVICE_INFO, strlen(GET_DEVICE_INFO)); + return; + + case CMD_ATI8: + if (DEBUG_PC_CMD_ISSUE) + printf("Issuing ATI8 command\n"); + cmdToRadio((uint8_t *)GET_UNIQUE_ID, strlen(GET_UNIQUE_ID)); + return; + case CMD_ATA: //Get all the VC states if (DEBUG_PC_CMD_ISSUE) printf("Issuing ATA command\n"); @@ -906,24 +1004,12 @@ void issuePcCommands() cmdToRadio((uint8_t *)START_3_WAY_HANDSHAKE, strlen(START_3_WAY_HANDSHAKE)); return; - case CMD_ATI12: + case CMD_ATI31: //Get the VC state if (DEBUG_PC_CMD_ISSUE) - printf("Issuing ATI12 command\n"); + printf("Issuing ATI31 command\n"); cmdToRadio((uint8_t *)GET_VC_STATE, strlen(GET_VC_STATE)); return; - - case CMD_ATI: - if (DEBUG_PC_CMD_ISSUE) - printf("Issuing ATI command\n"); - cmdToRadio((uint8_t *)GET_DEVICE_INFO, strlen(GET_DEVICE_INFO)); - return; - - case CMD_ATI8: - if (DEBUG_PC_CMD_ISSUE) - printf("Issuing ATI8 command\n"); - cmdToRadio((uint8_t *)GET_UNIQUE_ID, strlen(GET_UNIQUE_ID)); - return; } } } @@ -1070,7 +1156,7 @@ bool issueVcCommands(int vcIndex) //Get the VC state COMMAND_ISSUE(pcCommandQueue, pcCommandTimer, CMD_AT_CMDVC_2); - COMMAND_ISSUE(pcCommandQueue, pcCommandTimer, CMD_ATI12); + COMMAND_ISSUE(pcCommandQueue, pcCommandTimer, CMD_ATI31); break; case CMD_AT_CMDVC_2: @@ -1078,25 +1164,29 @@ bool issueVcCommands(int vcIndex) if (commandProcessorIdle(vcIndex)) { if (DEBUG_PC_CMD_ISSUE) - printf("Migrating AT-CMDVC and ATI12 commands to PC command queue\n"); + printf("Migrating AT-CMDVC_2 and ATI31 commands to PC command queue\n"); COMMAND_ISSUE(pcCommandQueue, pcCommandTimer, CMD_AT_CMDVC_2); - if (COMMAND_PENDING(virtualCircuitList[vcIndex].commandQueue, CMD_ATI12)) - COMMAND_ISSUE(pcCommandQueue, pcCommandTimer, CMD_ATI12); + if (COMMAND_PENDING(virtualCircuitList[vcIndex].commandQueue, CMD_ATI31)) + COMMAND_ISSUE(pcCommandQueue, pcCommandTimer, CMD_ATI31); return true; } virtualCircuitList[vcIndex].activeCommand = CMD_LIST_SIZE; return true; - case CMD_ATI12: + case CMD_ATI31: return true; - case CMD_ATI: + case CMD_ATI_2: sendVcCommand(GET_DEVICE_INFO, vcIndex); return true; - case CMD_ATI8: + case CMD_ATI8_2: sendVcCommand(GET_UNIQUE_ID, vcIndex); return true; + + case CMD_ATI11: + sendVcCommand(GET_RUNTIME, vcIndex); + return true; } } } @@ -1212,7 +1302,9 @@ int main(int argc, char **argv) //Perform the initialization commands pcCommandTimer = 1; - COMMAND_ISSUE(pcCommandQueue, pcCommandTimer, CMD_ATI11); //Get myVC + COMMAND_ISSUE(pcCommandQueue, pcCommandTimer, CMD_ATI30); //Get myVC + COMMAND_ISSUE(pcCommandQueue, pcCommandTimer, CMD_ATI); //Get Radio type + COMMAND_ISSUE(pcCommandQueue, pcCommandTimer, CMD_ATI8); //Get Radio unique ID COMMAND_ISSUE(pcCommandQueue, pcCommandTimer, CMD_ATA); //Get all the VC states //Break the links if requested @@ -1300,7 +1392,7 @@ int main(int argc, char **argv) // Check the resource usage //---------------------------------------- - if (!(timeoutCount % (ONE_SECOND_COUNT * 60))) + if (DISPLAY_RESOURCE_USAGE && (!(timeoutCount % (ONE_SECOND_COUNT * 60)))) { struct rusage usage; int s_days;