Repo for COM_MNG_TMTC_SIMPLE for integration with adf

Dependencies:   mbed-rtos mbed

Fork of COM_MNG_TMTC_SIMPLE by Shreesha S

Committer:
shreeshas95
Date:
Tue Dec 29 06:50:19 2015 +0000
Revision:
4:104dd82c99b8
Parent:
0:f016e9e8d48b
Child:
6:79d422d1ed42
Before making major modifications for testing

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shreeshas95 0:f016e9e8d48b 1 // TC TM
shreeshas95 0:f016e9e8d48b 2 #define TC_SHORT_SIZE 11
shreeshas95 0:f016e9e8d48b 3 #define TC_LONG_SIZE 135
shreeshas95 0:f016e9e8d48b 4 #define TM_LONG_SIZE 134
shreeshas95 0:f016e9e8d48b 5 #define TM_SHORT_SIZE 13
shreeshas95 0:f016e9e8d48b 6
shreeshas95 4:104dd82c99b8 7 #define SHORT_TC_CODE 0
shreeshas95 4:104dd82c99b8 8 #define LONG_TC_CODE 1
shreeshas95 4:104dd82c99b8 9
shreeshas95 4:104dd82c99b8 10 #define SHORT_TM_CODE 1
shreeshas95 4:104dd82c99b8 11 #define LONG_TM_CODE 0
shreeshas95 4:104dd82c99b8 12
shreeshas95 0:f016e9e8d48b 13 // COM_RX
shreeshas95 0:f016e9e8d48b 14 #define RX_BUFFER_LENGTH 60
shreeshas95 0:f016e9e8d48b 15 // 60+4 = 64
shreeshas95 0:f016e9e8d48b 16
shreeshas95 0:f016e9e8d48b 17 struct data_node{
shreeshas95 0:f016e9e8d48b 18 uint8_t values[RX_BUFFER_LENGTH];
shreeshas95 0:f016e9e8d48b 19 struct data_node* next_node;
shreeshas95 0:f016e9e8d48b 20 };
shreeshas95 0:f016e9e8d48b 21 typedef struct data_node COM_RX_DATA_NODE;
shreeshas95 0:f016e9e8d48b 22
shreeshas95 0:f016e9e8d48b 23 //TELECOMMAND:
shreeshas95 0:f016e9e8d48b 24
shreeshas95 0:f016e9e8d48b 25 /*
shreeshas95 0:f016e9e8d48b 26 exec_status:
shreeshas95 0:f016e9e8d48b 27 0: unexecuted
shreeshas95 0:f016e9e8d48b 28 1: successfully executed
shreeshas95 0:f016e9e8d48b 29 2: Execution Failed
shreeshas95 0:f016e9e8d48b 30 3: Disabled
shreeshas95 0:f016e9e8d48b 31 4: Marked For retry
shreeshas95 0:f016e9e8d48b 32 */
shreeshas95 0:f016e9e8d48b 33 #define TC_STATE_UNEXECUTED 0x00
shreeshas95 0:f016e9e8d48b 34 #define TC_STATE_SUCCESSFULLY_EXECUTED 0x01
shreeshas95 0:f016e9e8d48b 35 #define TC_STATE_EXECUTION_FAILED 0x02
shreeshas95 0:f016e9e8d48b 36 #define TC_STATE_DISABLED 0x03
shreeshas95 0:f016e9e8d48b 37 #define TC_STATE_MARKED_RETRY 0x04
shreeshas95 0:f016e9e8d48b 38
shreeshas95 0:f016e9e8d48b 39 //MASKS
shreeshas95 0:f016e9e8d48b 40 #define SHORT_LONG_TC_MASK 0x10
shreeshas95 0:f016e9e8d48b 41 #define CRC_MASK 0x08
shreeshas95 0:f016e9e8d48b 42 #define EXEC_STATUS_MASK 0x07
shreeshas95 0:f016e9e8d48b 43
shreeshas95 0:f016e9e8d48b 44 //USE ONLY THE BELOW MACROS TO MODIFY 'flags' VARIABLE
shreeshas95 0:f016e9e8d48b 45 //x should be a Base_tc pointer
shreeshas95 0:f016e9e8d48b 46 #define GETshort_or_long_tc(x) ( ( (x->flags) & SHORT_LONG_TC_MASK ) >> 4 )
shreeshas95 0:f016e9e8d48b 47 #define GETcrc_pass(x) ( ( (x->flags) & CRC_MASK ) >> 3 )
shreeshas95 0:f016e9e8d48b 48 #define GETabort_on_nack(x) ( ( (x->TC_string[1]) & 0x08 ) >> 3 )
shreeshas95 0:f016e9e8d48b 49 #define GETapid(x) ( ( (x->TC_string[1]) & 0xA0 ) >> 6 )
shreeshas95 0:f016e9e8d48b 50 #define GETexec_status(x) ( (x->flags) & EXEC_STATUS_MASK )
shreeshas95 0:f016e9e8d48b 51 #define GETpacket_seq_count(x) (x->TC_string[0])
shreeshas95 0:f016e9e8d48b 52
shreeshas95 0:f016e9e8d48b 53 //x should be a Base_tc pointer
shreeshas95 0:f016e9e8d48b 54 //y should be a 16-bit number with relevant data in LSB
shreeshas95 0:f016e9e8d48b 55 //use in a seperate line with ; at the end: similar to a function
shreeshas95 0:f016e9e8d48b 56 #define PUTshort_or_long(x,y) x->flags = ( (x->flags) & ~(SHORT_LONG_TC_MASK)) | ( (y << 4) & SHORT_LONG_TC_MASK )
shreeshas95 0:f016e9e8d48b 57 #define PUTcrc_pass(x,y) x->flags = ( (x->flags) & ~(CRC_MASK)) | ( (y << 3) & CRC_MASK)
shreeshas95 0:f016e9e8d48b 58 #define PUTexec_status(x,y) x->flags = ( (x->flags) & ~(EXEC_STATUS_MASK)) | ( y & EXEC_STATUS_MASK)
shreeshas95 0:f016e9e8d48b 59
shreeshas95 0:f016e9e8d48b 60 //PARENT TELECOMMAND CLASS
shreeshas95 0:f016e9e8d48b 61 class Base_tc{
shreeshas95 0:f016e9e8d48b 62 public:
shreeshas95 0:f016e9e8d48b 63 uint8_t flags;
shreeshas95 0:f016e9e8d48b 64 uint8_t *TC_string;
shreeshas95 0:f016e9e8d48b 65 Base_tc *next_TC;
shreeshas95 0:f016e9e8d48b 66
shreeshas95 0:f016e9e8d48b 67 virtual ~Base_tc(){}
shreeshas95 0:f016e9e8d48b 68 };
shreeshas95 0:f016e9e8d48b 69
shreeshas95 0:f016e9e8d48b 70 //DERIVED CLASS - SHORT TC
shreeshas95 0:f016e9e8d48b 71 class Short_tc : public Base_tc{
shreeshas95 0:f016e9e8d48b 72 private:
shreeshas95 0:f016e9e8d48b 73 uint8_t fix_str[TC_SHORT_SIZE];
shreeshas95 0:f016e9e8d48b 74 public:
shreeshas95 0:f016e9e8d48b 75 Short_tc(){
shreeshas95 0:f016e9e8d48b 76 TC_string = fix_str;
shreeshas95 0:f016e9e8d48b 77 flags = 0;
shreeshas95 0:f016e9e8d48b 78 }
shreeshas95 0:f016e9e8d48b 79
shreeshas95 0:f016e9e8d48b 80 ~Short_tc(){}
shreeshas95 0:f016e9e8d48b 81 };
shreeshas95 0:f016e9e8d48b 82
shreeshas95 0:f016e9e8d48b 83 //DERIVED CLASS - LONG TC
shreeshas95 0:f016e9e8d48b 84 class Long_tc : public Base_tc{
shreeshas95 0:f016e9e8d48b 85 private:
shreeshas95 0:f016e9e8d48b 86 uint8_t fix_str[TC_LONG_SIZE];
shreeshas95 0:f016e9e8d48b 87 public:
shreeshas95 0:f016e9e8d48b 88 Long_tc(){
shreeshas95 0:f016e9e8d48b 89 TC_string = fix_str;
shreeshas95 0:f016e9e8d48b 90 flags = 0;
shreeshas95 0:f016e9e8d48b 91 }
shreeshas95 0:f016e9e8d48b 92
shreeshas95 0:f016e9e8d48b 93 ~Long_tc(){}
shreeshas95 0:f016e9e8d48b 94 };
shreeshas95 0:f016e9e8d48b 95
shreeshas95 0:f016e9e8d48b 96 // TELEMETRY:
shreeshas95 0:f016e9e8d48b 97 // MASKS
shreeshas95 0:f016e9e8d48b 98 #define SHORT_LONG_TM_MASK 0x10
shreeshas95 0:f016e9e8d48b 99 #define TMID_MASK 0x0F
shreeshas95 0:f016e9e8d48b 100
shreeshas95 0:f016e9e8d48b 101 //x should be 'fields' variable defined in the Base_tm
shreeshas95 0:f016e9e8d48b 102 #define GETshort_or_long_tm(x) ((x & SHORT_LONG_TM_MASK) >> 4)
shreeshas95 0:f016e9e8d48b 103 #define GETtmid(x) (x & TMID_MASK)
shreeshas95 0:f016e9e8d48b 104
shreeshas95 0:f016e9e8d48b 105 //x should be 'fields' variable defines in the Base_tm
shreeshas95 0:f016e9e8d48b 106 //y should be an 8-bit number with relevent data at LSB
shreeshas95 0:f016e9e8d48b 107 #define PUTshort_or_long_tm(x,y) x = (x & ~(SHORT_LONG_TM_MASK)) | ((y<<4) & SHORT_LONG_TM_MASK)
shreeshas95 0:f016e9e8d48b 108 #define PUTtmid(x,y) x = (x & ~(TMID_MASK)) | (y & TMID_MASK)
shreeshas95 0:f016e9e8d48b 109
shreeshas95 0:f016e9e8d48b 110 // PARENT TELEMETRY CLASS
shreeshas95 0:f016e9e8d48b 111 class Base_tm{
shreeshas95 0:f016e9e8d48b 112 public:
shreeshas95 0:f016e9e8d48b 113 uint8_t fields;
shreeshas95 0:f016e9e8d48b 114 uint8_t *TM_string;
shreeshas95 0:f016e9e8d48b 115 Base_tm *next_TM;
shreeshas95 0:f016e9e8d48b 116
shreeshas95 0:f016e9e8d48b 117 virtual ~Base_tm(){}
shreeshas95 0:f016e9e8d48b 118 };
shreeshas95 0:f016e9e8d48b 119
shreeshas95 0:f016e9e8d48b 120 // DERIVED CLASS : Long tm [type 0]
shreeshas95 0:f016e9e8d48b 121 // type 0
shreeshas95 0:f016e9e8d48b 122 class Long_tm : public Base_tm{
shreeshas95 0:f016e9e8d48b 123 private:
shreeshas95 0:f016e9e8d48b 124 uint8_t fix_str[TM_LONG_SIZE];
shreeshas95 0:f016e9e8d48b 125 public:
shreeshas95 0:f016e9e8d48b 126 Long_tm(){
shreeshas95 0:f016e9e8d48b 127 TM_string = fix_str;
shreeshas95 0:f016e9e8d48b 128 // type 0
shreeshas95 0:f016e9e8d48b 129 fields = 0;
shreeshas95 0:f016e9e8d48b 130 }
shreeshas95 0:f016e9e8d48b 131
shreeshas95 0:f016e9e8d48b 132 ~Long_tm(){}
shreeshas95 0:f016e9e8d48b 133 };
shreeshas95 0:f016e9e8d48b 134
shreeshas95 0:f016e9e8d48b 135 // DERIVED CLASS : Short tm [type 1]
shreeshas95 0:f016e9e8d48b 136 // type 1
shreeshas95 0:f016e9e8d48b 137 class Short_tm : public Base_tm{
shreeshas95 0:f016e9e8d48b 138 private:
shreeshas95 0:f016e9e8d48b 139 uint8_t fix_str[TM_SHORT_SIZE];
shreeshas95 0:f016e9e8d48b 140 public:
shreeshas95 0:f016e9e8d48b 141 Short_tm(){
shreeshas95 0:f016e9e8d48b 142 TM_string = fix_str;
shreeshas95 0:f016e9e8d48b 143 // type 1
shreeshas95 0:f016e9e8d48b 144 fields = 0x10;
shreeshas95 0:f016e9e8d48b 145 }
shreeshas95 0:f016e9e8d48b 146
shreeshas95 0:f016e9e8d48b 147 ~Short_tm(){}
shreeshas95 0:f016e9e8d48b 148 };