2121#define BREAK_LINKS_COMMAND "atb"
2222#define GET_DEVICE_INFO "ati"
2323#define GET_MY_VC_ADDRESS "ati30"
24+ #define GET_RUNTIME "ati11"
2425#define GET_UNIQUE_ID "ati8"
2526#define GET_VC_STATE "ati31"
2627#define GET_VC_STATUS "ata"
3637#define DISPLAY_DATA_ACK 0
3738#define DISPLAY_DATA_NACK 1
3839#define DISPLAY_RESOURCE_USAGE 0
40+ #define DISPLAY_RUNTIME 0
3941#define DISPLAY_STATE_TRANSITION 0
4042#define DISPLAY_UNKNOWN_COMMANDS 0
4143#define DISPLAY_VC_STATE 0
@@ -106,6 +108,7 @@ typedef enum
106108 CMD_ATI31 , //Get the VC state
107109 CMD_ATI_2 , //Get the device type
108110 CMD_ATI8_2 , //Get the radio's unique ID
111+ CMD_ATI11 , //Get the runtime
109112
110113 //Last in the list
111114 CMD_LIST_SIZE
@@ -115,7 +118,7 @@ const char * const commandName[] =
115118{
116119 "ATI30" , "ATIB" , "ATI" , "ATI8" , "ATA" , "AT-CMDVC" , "ATC" ,
117120 "WAIT_CONNECT" ,
118- "AT-CMDVC_2" , "ATI31" , "ATI_2" , "ATI8_2" ,
121+ "AT-CMDVC_2" , "ATI31" , "ATI_2" , "ATI8_2" , "ATI11" ,
119122};
120123
121124typedef struct _VIRTUAL_CIRCUIT
@@ -124,6 +127,8 @@ typedef struct _VIRTUAL_CIRCUIT
124127 uint32_t activeCommand ;
125128 QUEUE_T commandQueue [COMMAND_QUEUE_SIZE ];
126129 uint32_t commandTimer ;
130+ uint64_t programmed ;
131+ uint64_t runtime ;
127132 uint8_t uniqueId [UNIQUE_ID_BYTES ];
128133 bool valid ;
129134} VIRTUAL_CIRCUIT ;
@@ -594,6 +599,9 @@ void radioToPcLinkStatus(VC_SERIAL_MESSAGE_HEADER * header, uint8_t * data, uint
594599 COMMAND_ISSUE (virtualCircuitList [srcVc ].commandQueue ,
595600 virtualCircuitList [srcVc ].commandTimer ,
596601 CMD_ATI8_2 );
602+ COMMAND_ISSUE (virtualCircuitList [srcVc ].commandQueue ,
603+ virtualCircuitList [srcVc ].commandTimer ,
604+ CMD_ATI11 );
597605 }
598606 break ;
599607 }
@@ -639,6 +647,23 @@ void radioDataNack(VC_SERIAL_MESSAGE_HEADER * header, uint8_t * data, uint8_t le
639647 virtualCircuitList [vcIndex ].vcState = VC_STATE_LINK_DOWN ;
640648}
641649
650+ void radioRuntime (VC_SERIAL_MESSAGE_HEADER * header , uint8_t * data , uint8_t length )
651+ {
652+ int index ;
653+ int vcIndex ;
654+ VC_RUNTIME_MESSAGE * vcMsg ;
655+
656+ vcMsg = (VC_RUNTIME_MESSAGE * )data ;
657+ vcIndex = header -> radio .srcVc & VCAB_NUMBER_MASK ;
658+ if (DISPLAY_RUNTIME )
659+ printf ("VC %d runtime: %lld, programmed: %lld\n" ,
660+ vcIndex , (long long )vcMsg -> runtime , (long long )vcMsg -> programmed );
661+
662+ //Set the time values
663+ memcpy (& virtualCircuitList [vcIndex ].runtime , & vcMsg -> runtime , sizeof (vcMsg -> runtime ));
664+ memcpy (& virtualCircuitList [vcIndex ].programmed , & vcMsg -> programmed , sizeof (vcMsg -> programmed ));
665+ }
666+
642667void radioCommandComplete (VC_SERIAL_MESSAGE_HEADER * header , uint8_t * data , uint8_t length )
643668{
644669 VC_COMMAND_COMPLETE_MESSAGE * vcMsg ;
@@ -800,6 +825,10 @@ int radioToHost()
800825 else if (header -> radio .destVc == PC_DATA_NACK )
801826 radioDataNack (header , data , length );
802827
828+ //Display radio runtime
829+ else if (header -> radio .destVc == PC_RUNTIME )
830+ radioRuntime (header , data , length );
831+
803832 //Display received messages
804833 else if ((header -> radio .destVc == myVc ) || (header -> radio .destVc == VC_BROADCAST ))
805834 {
@@ -1082,6 +1111,10 @@ bool issueVcCommands(int vcIndex)
10821111 case CMD_ATI8_2 :
10831112 sendVcCommand (GET_UNIQUE_ID , vcIndex );
10841113 return true;
1114+
1115+ case CMD_ATI11 :
1116+ sendVcCommand (GET_RUNTIME , vcIndex );
1117+ return true;
10851118 }
10861119 }
10871120 }
0 commit comments