Dummy program to demonstrate problems: working code

Dependencies:   SLCD mbed-rtos mbed

Fork of MNG_TC by Shreesha S

Revision:
15:cc266eccf327
Parent:
13:7b27a8e9cbb4
--- a/Structures.h	Mon Aug 17 12:05:09 2015 +0000
+++ b/Structures.h	Thu Sep 17 12:59:07 2015 +0000
@@ -1,8 +1,5 @@
 // TELECOMMAND CLASS :
 
-#define TC_SHORT_SIZE 11
-#define TC_LONG_SIZE 135
-
 typedef struct TC_list{
     // received from the RCV_TC
     unsigned char *TC_string;
@@ -33,128 +30,58 @@
     ~TM_list(){}
 }TM_List;
 
+
+
+
+
+/*//NEW CODE: UNDER CONSTRUCTION
+//SIZE
+#define TC_SHORT_SIZE 11
+#define TC_LONG_SIZE 135
+#define TM_LONG_SIZE 134
+#define TM_SHORT_SIZE 13
+
+//TELECOMMAND CLASS:
+
 //MASKS
-/*#define SHORT_LONG_TC_MASK 0x4000
+#define SHORT_LONG_TC_MASK 0x4000
 #define CRC_MASK 0x2000
 #define ABORT_ON_NACK_MASK 0x1000
 #define APID_MASK 0x0C00
 #define EXEC_STATUS_MASK 0x0300
 #define PACKET_SEQ_COUNT_MASK 0x00FF
 
+//x should be fields defined variable in the Base_tc
+#define GETshort_or_long(x) ((x & SHORT_LONG_TC_MASK) >> 14)
+#define GETcrc_pass(x) ((x & CRC_MASK) >> 13)
+#define GETabort_on_nack(x) ((x & ABORT_ON_NACK_MASK) >> 12)
+#define GETapid(x) ((x & APID_MASK) >> 10)
+#define GETexec_status(x) ((x & EXEC_STATUS_MASK) >> 8)
+#define GETpacket_seq_count(x) (x & PACKET_SEQ_COUNT_MASK)
+
+//x should be fields defined variable in the Base_tc
+//y should be a 16 bit number Eg: 0xFFFF, or 0x0000
+//use in a seperate line
+#define PUTshort_or_long(x,y) fields = (fields & ~(SHORT_OR_LONG_MASK)) | (y & SHORT_OR_LONG_MASK)
+#define PUTcrc_pass(x,y) fields = (fields & ~(CRC_MASK)) | (y & CRC_MASK)
+#define PUTabort_on_nack(x,y) fields = (fields & ~(ABORT_ON_NACK_MASK)) | (y & ABORT_ON_NACK_MASK)
+#define PUTapid(x,y) fields = (fields & ~(APID_MASK)) | (y & APID_MASK)
+//#define PUTexec_status(x,y) fields = 
+
 //PARENT CLASS
-class Base_tc {
-protected:
+class Base_tc{
+public:
     uint16_t fields;
-public:
-    uin8_t *TC_string;
+    uint8_t *TC_string;
     Base_tc *next_node;
     
-//    short = 0, long = 1
-    bool inline GETshort_or_long(){
-        return (fields & SHORT_LONG_TC_MASK);
-    }
-    void inline PUTshort_or_long(bool input){
-        if(input){
-            fields |= SHORT_LONG_TC_MASK;
-        }
-        else{
-            fields &= ~(SHORT_LONG_TC_MASK);
-        }
-    }
-    
-    bool inline GETcrc_pass(){
-        return (fields & CRC_MASK);
-    }
-    void inline PUTcrc_pass(bool input){
-        if(input){
-            fields |= CRC_MASK;
-        }
-        else{
-            fields &= ~(CRC_MASK);
-        }
-    }
-        
-    bool inline GETabort_on_nack(){
-        return (fields & ABORT_ON_NACK_MASK);
-    }
-    void inline PUTabort_on_nack(bool input){
-        if(input){
-            fields |= ABORT_ON_NACK_MASK;
-        }
-        else{
-            fields &= ~(ABORT_ON_NACK_MASK);
-        }
-    }
-    
-    uint8_t inline GETapid(){
-        uint16_t temp = fields & APID_MASK;
-        temp = temp >> 10;
-        return (temp & 0xFF);
-    }
-    void inline PUTapid(uint8_t input){
-        uint16_t temp = input;
-        temp = temp << 10;
-        fields &= ~(APID_MASK);
-        fields |= (temp & APID_MASK);
-    }
-    
-    uint8_t inline GETexec_status(){
-        uint16_t temp = fields & EXEC_STATUS_MASK;
-        temp = temp >> 8;
-        return (temp & 0xFF);
-    }
-    void inline PUTexec_status(uint8_t input){
-        uint16_t temp = input;
-        temp = temp << 8;
-        fields &= ~(EXEC_STATUS_MASK);
-        fields |= (temp & EXEC_STATUS_MASK);
-    }
-    
-    uint8_t inline GETpacket_seq_count(){
-        uint16_t temp = fields & PACKET_SEQ_COUNT_MASK;
-        return (temp & 0xFF);
-    }
-    void inline PUTpacket_seq_count(uint8_t input){
-        uint16_t temp = input;
-        fields &= ~(PACKET_SEQ_COUNT_MASK);
-        fields |= (temp & PACKET_SEQ_COUNT_MASK);
-    }
-    
-//    update everything other than short_or_long, and crc_pass from TC_string
-    void update_fields(){
-//        abort on nack
-        uint8_t temp = TC_string[1];
-        uint16_t t16 = 0;
-        if(temp & 0x10){
-            fields |= ABORT_ON_NACK_MASK;
-        }
-        else{
-            fields &= ~(ABORT_ON_NACK_MASK);
-        }
-        
-        // apid
-        t16 = temp;
-        t16 = t16 << 4;
-        fields &= ~(APID_MASK);
-        fields |= (t16 & APID_MASK);
-        
-        // exec_status : default value of exec status
-        fields &= ~(EXEC_STATUS_MASK);
-        
-        // packet seq count
-        temp = TC_string[0];
-        t16 = temp;
-        fields &= ~(PACKET_SEQ_COUNT_MASK);
-        fields |= (t16 & PACKET_SEQ_COUNT_MASK);
-    }
-    
     virtual ~Base_tc(){}
 };
 
 //DERIVED CLASS - SHORT TC
 class Short_tc : public Base_tc{
 private:
-    uin8_t fix_str[TC_SHORT_SIZE];
+    uint8_t fix_str[TC_SHORT_SIZE];
 public:
     Short_tc(){
         TC_string = fix_str;
@@ -167,7 +94,7 @@
 //DERIVED CLASS - LONG TC
 class Long_tc : public Base_tc{
 private:
-    uin8_t fix_str[TC_LONG_SIZE];
+    uint8_t fix_str[TC_LONG_SIZE];
 public:
     Long_tc(){
         TC_string = fix_str;
@@ -191,31 +118,9 @@
     uint8_t *TM_string;
     Base_tm *next_node;
     
-    // short = 0, long = 1
-    bool GETshort_or_long(){
-        return (fields & SHORT_LONG_TM_MASK);
-    }
-    void PUTshort_or_long(bool input){
-        if(input){
-            fields |= SHORT_LONG_TM_MASK;
-        }
-        else{
-            fields &= ~(SHORT_LONG_TM_MASK);
-        }
-    }
-    
-    uint8_t GETtmid(){
-        return (fields & TMID_MASK);
-    }
-    void PUTtmid(uint8_t input){
-        fields &= ~(TMID_MASK);
-        fields |= (input & TMID_MASK);
-    }
-    
     virtual ~Base_tm(){}
 };
 
-
 // DERIVED CLASS : Long tc [type 0]
 // type 0
 class Long_tm : public Base_tm{
@@ -244,4 +149,234 @@
     }
     
     ~Short_tm(){}
-};*/
\ No newline at end of file
+};
+
+//END*/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+////PARENT CLASS
+//class Base_tc{
+//public:
+//    uint16_t fields;
+//    uint8_t *TC_string;
+//    Base_tc *next_node;
+    
+//    short = 0, long = 1
+//    bool GETshort_or_long(void){
+//        return (fields & SHORT_LONG_TC_MASK);
+//    }
+//    void PUTshort_or_long(bool input){
+//        if(input){
+//            fields |= SHORT_LONG_TC_MASK;
+//        }
+//        else{
+//            fields &= ~(SHORT_LONG_TC_MASK);
+//        }
+//    }
+//    
+//    bool inline GETcrc_pass(){
+//        return (fields & CRC_MASK);
+//    }
+//    void inline PUTcrc_pass(bool input){
+//        if(input){
+//            fields |= CRC_MASK;
+//        }
+//        else{
+//            fields &= ~(CRC_MASK);
+//        }
+//    }
+//        
+//    bool inline GETabort_on_nack(){
+//        return (fields & ABORT_ON_NACK_MASK);
+//    }
+//    void inline PUTabort_on_nack(bool input){
+//        if(input){
+//            fields |= ABORT_ON_NACK_MASK;
+//        }
+//        else{
+//            fields &= ~(ABORT_ON_NACK_MASK);
+//        }
+//    }
+//    
+//    uint8_t inline GETapid(){
+//        uint16_t temp = fields & APID_MASK;
+//        temp = temp >> 10;
+//        return (temp & 0xFF);
+//    }
+//    void inline PUTapid(uint8_t input){
+//        uint16_t temp = input;
+//        temp = temp << 10;
+//        fields &= ~(APID_MASK);
+//        fields |= (temp & APID_MASK);
+//    }
+//    
+//    uint8_t inline GETexec_status(){
+//        uint16_t temp = fields & EXEC_STATUS_MASK;
+//        temp = temp >> 8;
+//        return (temp & 0xFF);
+//    }
+//    void inline PUTexec_status(uint8_t input){
+//        uint16_t temp = input;
+//        temp = temp << 8;
+//        fields &= ~(EXEC_STATUS_MASK);
+//        fields |= (temp & EXEC_STATUS_MASK);
+//    }
+//    
+//    uint8_t inline GETpacket_seq_count(){
+//        uint16_t temp = fields & PACKET_SEQ_COUNT_MASK;
+//        return (temp & 0xFF);
+//    }
+//    void inline PUTpacket_seq_count(uint8_t input){
+//        uint16_t temp = input;
+//        fields &= ~(PACKET_SEQ_COUNT_MASK);
+//        fields |= (temp & PACKET_SEQ_COUNT_MASK);
+//    }
+//    
+////    update everything other than short_or_long, and crc_pass from TC_string
+//    void update_fields(){
+////        abort on nack
+//        uint8_t temp = TC_string[1];
+//        uint16_t t16 = 0;
+//        if(temp & 0x10){
+//            fields |= ABORT_ON_NACK_MASK;
+//        }
+//        else{
+//            fields &= ~(ABORT_ON_NACK_MASK);
+//        }
+//        
+//        // apid
+//        t16 = temp;
+//        t16 = t16 << 4;
+//        fields &= ~(APID_MASK);
+//        fields |= (t16 & APID_MASK);
+//        
+//        // exec_status : default value of exec status
+//        fields &= ~(EXEC_STATUS_MASK);
+//        
+//        // packet seq count
+//        temp = TC_string[0];
+//        t16 = temp;
+//        fields &= ~(PACKET_SEQ_COUNT_MASK);
+//        fields |= (t16 & PACKET_SEQ_COUNT_MASK);
+//    }
+//    
+//    virtual ~Base_tc(){}
+//};
+
+////DERIVED CLASS - SHORT TC
+//class Short_tc : public Base_tc{
+//private:
+//    uint8_t fix_str[TC_SHORT_SIZE];
+//public:
+//    Short_tc(){
+//        TC_string = fix_str;
+//        fields = 0;
+//    }
+//    
+//    ~Short_tc(){}
+//};
+//
+////DERIVED CLASS - LONG TC
+//class Long_tc : public Base_tc{
+//private:
+//    uint8_t fix_str[TC_LONG_SIZE];
+//public:
+//    Long_tc(){
+//        TC_string = fix_str;
+//        fields = 0;
+//    }
+//    
+//    ~Long_tc(){}
+//};
+
+//// TELEMETRY CLASS :
+//
+//// MASKS
+//#define SHORT_LONG_TM_MASK 0x10
+//#define TMID_MASK 0x0F
+//
+//// PARENT CLASS
+//class Base_tm{
+//protected:
+//    uint8_t fields;
+//public:
+//    uint8_t *TM_string;
+//    Base_tm *next_node;
+//    
+    // short = 0, long = 1
+//    bool GETshort_or_long(){
+//        return (fields & SHORT_LONG_TM_MASK);
+//    }
+//    void PUTshort_or_long(bool input){
+//        if(input){
+//            fields |= SHORT_LONG_TM_MASK;
+//        }
+//        else{
+//            fields &= ~(SHORT_LONG_TM_MASK);
+//        }
+//    }
+//    
+//    uint8_t GETtmid(){
+//        return (fields & TMID_MASK);
+//    }
+//    void PUTtmid(uint8_t input){
+//        fields &= ~(TMID_MASK);
+//        fields |= (input & TMID_MASK);
+//    }
+//    
+//    virtual ~Base_tm(){}
+//};
+
+
+//// DERIVED CLASS : Long tc [type 0]
+//// type 0
+//class Long_tm : public Base_tm{
+//private:
+//    uint8_t fix_str[TM_LONG_SIZE];
+//public:
+//    Long_tm(){
+//        TM_string = fix_str;
+//        // type 0
+//        fields = 0;
+//    }
+//    
+//    ~Long_tm(){}
+//};
+//
+//// DERIVED CLASS : Short tc [type 1]
+//// type 1
+//class Short_tm : public Base_tm{
+//private:
+//    uint8_t fix_str[TM_SHORT_SIZE];
+//public:
+//    Short_tm(){
+//        TM_string = fix_str;
+//        // type 1
+//        fields = 0x10;
+//    }
+//    
+//    ~Short_tm(){}
+//};
\ No newline at end of file