Repo for COM_MNG_TMTC_SIMPLE for integration with adf

Dependencies:   mbed-rtos mbed

Fork of COM_MNG_TMTC_SIMPLE by Shreesha S

Committer:
shekhar
Date:
Thu Dec 31 08:39:43 2015 +0000
Revision:
8:d1951bbdcdd8
Parent:
6:79d422d1ed42
added adf.h and snd_tm;

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