![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Repository for testing ADF code of COM_TMTC_SIMPLE
Fork of COM_MNG_TMTC_SIMPLE by
COM_SND_TM.h@2:2caf2a9a13aa, 2015-12-22 (annotated)
- Committer:
- shreeshas95
- Date:
- Tue Dec 22 06:09:48 2015 +0000
- Revision:
- 2:2caf2a9a13aa
- Parent:
- 1:a0055b3280c8
- Child:
- 4:e37674541504
Before updating for science compression
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shreeshas95 | 1:a0055b3280c8 | 1 | void adf_not_SDcard(); |
shreeshas95 | 1:a0055b3280c8 | 2 | |
shreeshas95 | 1:a0055b3280c8 | 3 | #define S_FRAME_SIZE 48 |
shreeshas95 | 1:a0055b3280c8 | 4 | #define ISR 30 |
shreeshas95 | 1:a0055b3280c8 | 5 | #define TM_FRAME_SIZE 134 //in bytes |
shreeshas95 | 1:a0055b3280c8 | 6 | #define T_FRAME_SIZE 159 |
shreeshas95 | 1:a0055b3280c8 | 7 | #define EOS_SIZE 120 |
shreeshas95 | 1:a0055b3280c8 | 8 | #define MAX_ADF_LEN 65535 |
shreeshas95 | 1:a0055b3280c8 | 9 | |
shreeshas95 | 1:a0055b3280c8 | 10 | const unsigned char S_frame[] = {0x46,0x9D,0xFB,0xF0,0xD2,0xBA,0x89,0xE4,0x46,0x9D,0xFB,0xF0,0xD2,0xBA,0x89,0xE4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; |
shreeshas95 | 1:a0055b3280c8 | 11 | const unsigned char EoS[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x1A,0x77,0xEF,0xC3,0x4A,0xEA,0x27,0x91,0x1A,0x77,0xEF,0xC3,0x4A,0xEA,0x27,0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x1A,0x77,0xEF,0xC3,0x4A,0xEA,0x27,0x91,0x1A,0x77,0xEF,0xC3,0x4A,0xEA,0x27,0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; |
shreeshas95 | 1:a0055b3280c8 | 12 | const unsigned char FCCH80[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; |
shreeshas95 | 1:a0055b3280c8 | 13 | const unsigned char SCH40[] = {0x0a,0x3f,0x46,0xb4,0x00}; |
shreeshas95 | 1:a0055b3280c8 | 14 | |
shreeshas95 | 1:a0055b3280c8 | 15 | class SND_TM{ |
shreeshas95 | 1:a0055b3280c8 | 16 | |
shreeshas95 | 1:a0055b3280c8 | 17 | Base_tm * head_ptr; |
shreeshas95 | 1:a0055b3280c8 | 18 | |
shreeshas95 | 1:a0055b3280c8 | 19 | // transmit data variables |
shreeshas95 | 1:a0055b3280c8 | 20 | unsigned char Tframe_c; //_c represents counter, counts Tframe written in a segment |
shreeshas95 | 1:a0055b3280c8 | 21 | unsigned char EOS_c; //count no of bytes of eos have been weitten in the rolling buffer |
shreeshas95 | 1:a0055b3280c8 | 22 | unsigned char Sframe_c; //count no of bytes of Sframe have been weitten in the rolling buffer |
shreeshas95 | 1:a0055b3280c8 | 23 | unsigned char SCH40_c; //count no of bytes of SCH40 have been weitten in the rolling buffer |
shreeshas95 | 1:a0055b3280c8 | 24 | unsigned char data_c; |
shreeshas95 | 1:a0055b3280c8 | 25 | unsigned char FCCH80_c; |
shreeshas95 | 1:a0055b3280c8 | 26 | unsigned char RB_c; //rolling buffer counter |
shreeshas95 | 1:a0055b3280c8 | 27 | unsigned char segment_c; //counts the numver of segments sent |
shreeshas95 | 1:a0055b3280c8 | 28 | unsigned char MAX_SEGMENT; |
shreeshas95 | 1:a0055b3280c8 | 29 | bool Sframe; //Sframe = 1bit of CF1 |
shreeshas95 | 1:a0055b3280c8 | 30 | bool SCH40_f; |
shreeshas95 | 1:a0055b3280c8 | 31 | bool FCCH80_f; |
shreeshas95 | 1:a0055b3280c8 | 32 | bool data_f; |
shreeshas95 | 1:a0055b3280c8 | 33 | bool transmit_data_f; |
shreeshas95 | 1:a0055b3280c8 | 34 | bool eos_f; |
shreeshas95 | 1:a0055b3280c8 | 35 | bool junk_f; |
shreeshas95 | 1:a0055b3280c8 | 36 | |
shreeshas95 | 1:a0055b3280c8 | 37 | |
shreeshas95 | 1:a0055b3280c8 | 38 | // type 1 frame |
shreeshas95 | 1:a0055b3280c8 | 39 | |
shreeshas95 | 1:a0055b3280c8 | 40 | Base_tm *T0F_pointer ; |
shreeshas95 | 1:a0055b3280c8 | 41 | |
shreeshas95 | 1:a0055b3280c8 | 42 | int diff_prev; |
shreeshas95 | 1:a0055b3280c8 | 43 | void differential_encode(unsigned char* ptr, int length){ |
shreeshas95 | 1:a0055b3280c8 | 44 | for(int i=0; i<length;i++){ |
shreeshas95 | 1:a0055b3280c8 | 45 | unsigned char s = ptr[i] , t; |
shreeshas95 | 1:a0055b3280c8 | 46 | t = s ^ (s >> 1); |
shreeshas95 | 1:a0055b3280c8 | 47 | (diff_prev == 0) ? t=t^0x00 : t=t^0x80 ; |
shreeshas95 | 1:a0055b3280c8 | 48 | diff_prev = int(s & 0x01); |
shreeshas95 | 1:a0055b3280c8 | 49 | ptr[i] = t; |
shreeshas95 | 1:a0055b3280c8 | 50 | } |
shreeshas95 | 1:a0055b3280c8 | 51 | } |
shreeshas95 | 1:a0055b3280c8 | 52 | |
shreeshas95 | 1:a0055b3280c8 | 53 | int type0_no; //number of type zero frames |
shreeshas95 | 1:a0055b3280c8 | 54 | int type1_no; |
shreeshas95 | 1:a0055b3280c8 | 55 | int total_frames; //number of type one packe (TMP) |
shreeshas95 | 1:a0055b3280c8 | 56 | int SEGMENT_NO; //number of type one packe (TMP) |
shreeshas95 | 1:a0055b3280c8 | 57 | void inline data_number(){ |
shreeshas95 | 1:a0055b3280c8 | 58 | int type1_frame_no; |
shreeshas95 | 1:a0055b3280c8 | 59 | Base_tm*head = head_ptr; |
shreeshas95 | 1:a0055b3280c8 | 60 | type0_no = 0; |
shreeshas95 | 1:a0055b3280c8 | 61 | type1_no = 0; |
shreeshas95 | 1:a0055b3280c8 | 62 | while(head != NULL){ |
shreeshas95 | 1:a0055b3280c8 | 63 | switch( GETshort_or_long_tm(head->fields) ){ |
shreeshas95 | 1:a0055b3280c8 | 64 | case 0: |
shreeshas95 | 1:a0055b3280c8 | 65 | type0_no++; |
shreeshas95 | 1:a0055b3280c8 | 66 | break; |
shreeshas95 | 1:a0055b3280c8 | 67 | case 1: |
shreeshas95 | 1:a0055b3280c8 | 68 | type1_no++; |
shreeshas95 | 1:a0055b3280c8 | 69 | break; |
shreeshas95 | 1:a0055b3280c8 | 70 | } |
shreeshas95 | 1:a0055b3280c8 | 71 | head=head->next_TM; |
shreeshas95 | 1:a0055b3280c8 | 72 | } |
shreeshas95 | 1:a0055b3280c8 | 73 | type1_frame_no = ( type1_no % 10 == 0 )? (type1_no / 10) : ( (type1_no / 10) + 1); |
shreeshas95 | 1:a0055b3280c8 | 74 | total_frames = type0_no + type1_frame_no ; |
shreeshas95 | 1:a0055b3280c8 | 75 | SEGMENT_NO = (total_frames*2 % (ISR) == 0) ? ( total_frames*2/(ISR) ) : (total_frames*2/(ISR) + 1); //subtracting 1 since the last SCH40_f is not detected |
shreeshas95 | 1:a0055b3280c8 | 76 | } |
shreeshas95 | 1:a0055b3280c8 | 77 | |
shreeshas95 | 1:a0055b3280c8 | 78 | #define next_type_structure(ptr){\ |
shreeshas95 | 1:a0055b3280c8 | 79 | unsigned char temp = GETshort_or_long_tm(ptr->fields);\ |
shreeshas95 | 1:a0055b3280c8 | 80 | if((temp == 0) && (ptr->next_TM != NULL) ){\ |
shreeshas95 | 1:a0055b3280c8 | 81 | do{\ |
shreeshas95 | 1:a0055b3280c8 | 82 | ptr = ptr->next_TM;\ |
shreeshas95 | 1:a0055b3280c8 | 83 | temp = GETshort_or_long_tm(ptr->fields);\ |
shreeshas95 | 1:a0055b3280c8 | 84 | }\ |
shreeshas95 | 1:a0055b3280c8 | 85 | while(temp == 1 && ptr->next_TM != NULL);\ |
shreeshas95 | 1:a0055b3280c8 | 86 | if(temp == 1){\ |
shreeshas95 | 1:a0055b3280c8 | 87 | ptr = NULL;\ |
shreeshas95 | 1:a0055b3280c8 | 88 | break;\ |
shreeshas95 | 1:a0055b3280c8 | 89 | }\ |
shreeshas95 | 1:a0055b3280c8 | 90 | }\ |
shreeshas95 | 1:a0055b3280c8 | 91 | else if((temp == 1) && (ptr->next_TM != NULL)){\ |
shreeshas95 | 1:a0055b3280c8 | 92 | do{\ |
shreeshas95 | 1:a0055b3280c8 | 93 | ptr = ptr->next_TM;\ |
shreeshas95 | 1:a0055b3280c8 | 94 | temp = GETshort_or_long_tm(ptr->fields);\ |
shreeshas95 | 1:a0055b3280c8 | 95 | }\ |
shreeshas95 | 1:a0055b3280c8 | 96 | while(temp == 0 && ptr->next_TM != NULL);\ |
shreeshas95 | 1:a0055b3280c8 | 97 | if(temp == 0){\ |
shreeshas95 | 1:a0055b3280c8 | 98 | ptr NULL;\ |
shreeshas95 | 1:a0055b3280c8 | 99 | break;\ |
shreeshas95 | 1:a0055b3280c8 | 100 | }\ |
shreeshas95 | 1:a0055b3280c8 | 101 | }\ |
shreeshas95 | 1:a0055b3280c8 | 102 | else{\ |
shreeshas95 | 1:a0055b3280c8 | 103 | ptr NULL;\ |
shreeshas95 | 1:a0055b3280c8 | 104 | }\ |
shreeshas95 | 1:a0055b3280c8 | 105 | } |
shreeshas95 | 1:a0055b3280c8 | 106 | |
shreeshas95 | 1:a0055b3280c8 | 107 | /* |
shreeshas95 | 1:a0055b3280c8 | 108 | brief: take input type 0 or 1 and return the address of the first node in the list that have that type |
shreeshas95 | 1:a0055b3280c8 | 109 | parameter: type 0 or 1 |
shreeshas95 | 1:a0055b3280c8 | 110 | return: pointer of the first node having same type |
shreeshas95 | 1:a0055b3280c8 | 111 | */ |
shreeshas95 | 1:a0055b3280c8 | 112 | // Base_tm* first_type_structure(int type){ |
shreeshas95 | 1:a0055b3280c8 | 113 | // Base_tm* temp_ptr = head_ptr; |
shreeshas95 | 1:a0055b3280c8 | 114 | // if(type == 0){ |
shreeshas95 | 1:a0055b3280c8 | 115 | // while(GETshort_or_long_tm(temp_ptr->fields) == 1){ |
shreeshas95 | 1:a0055b3280c8 | 116 | // temp_ptr = temp_ptr->next_TM; |
shreeshas95 | 1:a0055b3280c8 | 117 | // if(temp_ptr == NULL){ |
shreeshas95 | 1:a0055b3280c8 | 118 | // return NULL ; |
shreeshas95 | 1:a0055b3280c8 | 119 | // } |
shreeshas95 | 1:a0055b3280c8 | 120 | // } |
shreeshas95 | 1:a0055b3280c8 | 121 | // } |
shreeshas95 | 1:a0055b3280c8 | 122 | // else if(type == 1){ |
shreeshas95 | 1:a0055b3280c8 | 123 | // while(GETshort_or_long_tm(temp_ptr->fields) == 0){ |
shreeshas95 | 1:a0055b3280c8 | 124 | // temp_ptr = temp_ptr->next_TM; |
shreeshas95 | 1:a0055b3280c8 | 125 | // if(temp_ptr == NULL){ |
shreeshas95 | 1:a0055b3280c8 | 126 | // return NULL; |
shreeshas95 | 1:a0055b3280c8 | 127 | // } |
shreeshas95 | 1:a0055b3280c8 | 128 | // } |
shreeshas95 | 1:a0055b3280c8 | 129 | // } |
shreeshas95 | 1:a0055b3280c8 | 130 | // return temp_ptr; |
shreeshas95 | 1:a0055b3280c8 | 131 | // } |
shreeshas95 | 1:a0055b3280c8 | 132 | |
shreeshas95 | 1:a0055b3280c8 | 133 | |
shreeshas95 | 1:a0055b3280c8 | 134 | #define first_type_structure( type,return_ptr) {\ |
shreeshas95 | 1:a0055b3280c8 | 135 | Base_tm* temp_ptr = head_ptr;\ |
shreeshas95 | 1:a0055b3280c8 | 136 | if(type == 0){\ |
shreeshas95 | 1:a0055b3280c8 | 137 | while(GETshort_or_long_tm(temp_ptr->fields) == 1){\ |
shreeshas95 | 1:a0055b3280c8 | 138 | temp_ptr = temp_ptr->next_TM;\ |
shreeshas95 | 1:a0055b3280c8 | 139 | if(temp_ptr == NULL){\ |
shreeshas95 | 1:a0055b3280c8 | 140 | return_ptr = NULL ;\ |
shreeshas95 | 1:a0055b3280c8 | 141 | }\ |
shreeshas95 | 1:a0055b3280c8 | 142 | }\ |
shreeshas95 | 1:a0055b3280c8 | 143 | }\ |
shreeshas95 | 1:a0055b3280c8 | 144 | else if(type == 1){\ |
shreeshas95 | 1:a0055b3280c8 | 145 | while(GETshort_or_long_tm(temp_ptr->fields) == 0){\ |
shreeshas95 | 1:a0055b3280c8 | 146 | temp_ptr = temp_ptr->next_TM;\ |
shreeshas95 | 1:a0055b3280c8 | 147 | if(temp_ptr == NULL){\ |
shreeshas95 | 1:a0055b3280c8 | 148 | return_ptr = NULL;\ |
shreeshas95 | 1:a0055b3280c8 | 149 | }\ |
shreeshas95 | 1:a0055b3280c8 | 150 | }\ |
shreeshas95 | 1:a0055b3280c8 | 151 | }\ |
shreeshas95 | 1:a0055b3280c8 | 152 | return_ptr = temp_ptr;\ |
shreeshas95 | 1:a0055b3280c8 | 153 | } |
shreeshas95 | 1:a0055b3280c8 | 154 | |
shreeshas95 | 1:a0055b3280c8 | 155 | |
shreeshas95 | 1:a0055b3280c8 | 156 | |
shreeshas95 | 1:a0055b3280c8 | 157 | Base_tm *T1F_pointer ; |
shreeshas95 | 1:a0055b3280c8 | 158 | int T1F_counter; |
shreeshas95 | 1:a0055b3280c8 | 159 | unsigned char TMframe_type1[TM_FRAME_SIZE]; |
shreeshas95 | 1:a0055b3280c8 | 160 | bool type1_frame_flag; //should be true for every new list |
shreeshas95 | 1:a0055b3280c8 | 161 | |
shreeshas95 | 1:a0055b3280c8 | 162 | #define type1_frame(ptr){\ |
shreeshas95 | 1:a0055b3280c8 | 163 | int i=4;\ |
shreeshas95 | 1:a0055b3280c8 | 164 | if(type1_frame_flag){\ |
shreeshas95 | 1:a0055b3280c8 | 165 | first_type_structure(1,T1F_pointer);\ |
shreeshas95 | 1:a0055b3280c8 | 166 | T1F_counter = 0;\ |
shreeshas95 | 1:a0055b3280c8 | 167 | type1_frame_flag = false;\ |
shreeshas95 | 1:a0055b3280c8 | 168 | }\ |
shreeshas95 | 1:a0055b3280c8 | 169 | for(i = 4 ; (i < 134) && (T1F_pointer != NULL) ; i++){\ |
shreeshas95 | 1:a0055b3280c8 | 170 | TMframe_type1[i] = T1F_pointer->TM_string[T1F_counter];\ |
shreeshas95 | 1:a0055b3280c8 | 171 | if(T1F_counter++ == 12){\ |
shreeshas95 | 1:a0055b3280c8 | 172 | T1F_counter = 0;\ |
shreeshas95 | 1:a0055b3280c8 | 173 | next_type_structure(T1F_pointer);\ |
shreeshas95 | 1:a0055b3280c8 | 174 | }\ |
shreeshas95 | 1:a0055b3280c8 | 175 | }\ |
shreeshas95 | 1:a0055b3280c8 | 176 | TMframe_type1[0] = 1<<7 + ( (i-4)/10 )<<3;\ |
shreeshas95 | 1:a0055b3280c8 | 177 | TMframe_type1[3] = crc16_gen(TMframe_type1,3);\ |
shreeshas95 | 1:a0055b3280c8 | 178 | if(T1F_pointer == NULL && i>12){\ |
shreeshas95 | 1:a0055b3280c8 | 179 | for( ; i < 134 ; i++){\ |
shreeshas95 | 1:a0055b3280c8 | 180 | TMframe_type1[i] = TMframe_type1[i-13];\ |
shreeshas95 | 1:a0055b3280c8 | 181 | }\ |
shreeshas95 | 1:a0055b3280c8 | 182 | }\ |
shreeshas95 | 1:a0055b3280c8 | 183 | } |
shreeshas95 | 1:a0055b3280c8 | 184 | |
shreeshas95 | 1:a0055b3280c8 | 185 | |
shreeshas95 | 1:a0055b3280c8 | 186 | // unsigned char * type1_frame(){ |
shreeshas95 | 1:a0055b3280c8 | 187 | // int i=4; |
shreeshas95 | 1:a0055b3280c8 | 188 | // if(type1_frame_flag){ |
shreeshas95 | 1:a0055b3280c8 | 189 | // T1F_pointer = first_type_structure(1); |
shreeshas95 | 1:a0055b3280c8 | 190 | // T1F_counter = 0; |
shreeshas95 | 1:a0055b3280c8 | 191 | // type1_frame_flag = false; |
shreeshas95 | 1:a0055b3280c8 | 192 | // } |
shreeshas95 | 1:a0055b3280c8 | 193 | // for(i = 4 ; (i < 134) && (T1F_pointer != NULL) ; i++){ |
shreeshas95 | 1:a0055b3280c8 | 194 | // TMframe_type1[i] = T1F_pointer->TM_string[T1F_counter]; |
shreeshas95 | 1:a0055b3280c8 | 195 | // if(T1F_counter++ == 12){ |
shreeshas95 | 1:a0055b3280c8 | 196 | // T1F_counter = 0; |
shreeshas95 | 1:a0055b3280c8 | 197 | // T1F_pointer = next_type_structure(T1F_pointer); |
shreeshas95 | 1:a0055b3280c8 | 198 | // } |
shreeshas95 | 1:a0055b3280c8 | 199 | // } |
shreeshas95 | 1:a0055b3280c8 | 200 | // // header |
shreeshas95 | 1:a0055b3280c8 | 201 | // TMframe_type1[0] = 1<<7 + ( (i-4)/10 )<<3; //( (i-4)/10 ) gives number of packets in the frame |
shreeshas95 | 1:a0055b3280c8 | 202 | // //insert time ; |
shreeshas95 | 1:a0055b3280c8 | 203 | // TMframe_type1[3] = CRC::crc16_gen(TMframe_type1,3); |
shreeshas95 | 1:a0055b3280c8 | 204 | // //end header |
shreeshas95 | 1:a0055b3280c8 | 205 | // if(T1F_pointer == NULL && i>12){ |
shreeshas95 | 1:a0055b3280c8 | 206 | // for( ; i < 134 ; i++){ //repeating ;ast packet to fill up the extra space |
shreeshas95 | 1:a0055b3280c8 | 207 | // TMframe_type1[i] = TMframe_type1[i-13]; |
shreeshas95 | 1:a0055b3280c8 | 208 | // } |
shreeshas95 | 1:a0055b3280c8 | 209 | // } |
shreeshas95 | 1:a0055b3280c8 | 210 | // return TMframe_type1; |
shreeshas95 | 1:a0055b3280c8 | 211 | // } |
shreeshas95 | 1:a0055b3280c8 | 212 | |
shreeshas95 | 1:a0055b3280c8 | 213 | bool type0_frame_flag; |
shreeshas95 | 1:a0055b3280c8 | 214 | |
shreeshas95 | 1:a0055b3280c8 | 215 | |
shreeshas95 | 1:a0055b3280c8 | 216 | #define type0_frame(ptr){\ |
shreeshas95 | 1:a0055b3280c8 | 217 | if(type0_frame_flag){\ |
shreeshas95 | 1:a0055b3280c8 | 218 | first_type_structure(0,T0F_pointer);\ |
shreeshas95 | 1:a0055b3280c8 | 219 | type0_frame_flag = false;\ |
shreeshas95 | 1:a0055b3280c8 | 220 | }\ |
shreeshas95 | 1:a0055b3280c8 | 221 | else {\ |
shreeshas95 | 1:a0055b3280c8 | 222 | next_type_structure(T0F_pointer);\ |
shreeshas95 | 1:a0055b3280c8 | 223 | }\ |
shreeshas95 | 1:a0055b3280c8 | 224 | ptr = T0F_pointer->TM_string;\ |
shreeshas95 | 1:a0055b3280c8 | 225 | } |
shreeshas95 | 1:a0055b3280c8 | 226 | |
shreeshas95 | 1:a0055b3280c8 | 227 | |
shreeshas95 | 1:a0055b3280c8 | 228 | // unsigned char* type0_frame(){ |
shreeshas95 | 1:a0055b3280c8 | 229 | // if(type0_frame_flag){ |
shreeshas95 | 1:a0055b3280c8 | 230 | // T0F_pointer = first_type_structure(0); |
shreeshas95 | 1:a0055b3280c8 | 231 | // type0_frame_flag = false; |
shreeshas95 | 1:a0055b3280c8 | 232 | // } |
shreeshas95 | 1:a0055b3280c8 | 233 | // else { |
shreeshas95 | 1:a0055b3280c8 | 234 | // T0F_pointer = next_type_structure(T0F_pointer); |
shreeshas95 | 1:a0055b3280c8 | 235 | // } |
shreeshas95 | 1:a0055b3280c8 | 236 | // return T0F_pointer->TM_string; |
shreeshas95 | 1:a0055b3280c8 | 237 | // } |
shreeshas95 | 1:a0055b3280c8 | 238 | |
shreeshas95 | 1:a0055b3280c8 | 239 | unsigned char convoluted_frame[270]; |
shreeshas95 | 1:a0055b3280c8 | 240 | Convolution ConvObj2; |
shreeshas95 | 1:a0055b3280c8 | 241 | void convolution (unsigned char * ptr){ |
shreeshas95 | 1:a0055b3280c8 | 242 | ConvObj2.convolutionEncode(ptr, convoluted_frame); |
shreeshas95 | 1:a0055b3280c8 | 243 | ConvObj2.convolutionEncode(ptr + 67, convoluted_frame + 135); |
shreeshas95 | 1:a0055b3280c8 | 244 | } |
shreeshas95 | 1:a0055b3280c8 | 245 | |
shreeshas95 | 1:a0055b3280c8 | 246 | |
shreeshas95 | 1:a0055b3280c8 | 247 | unsigned char interleave_data[2][144]; |
shreeshas95 | 1:a0055b3280c8 | 248 | unsigned char DS_index; |
shreeshas95 | 1:a0055b3280c8 | 249 | bool DS_state; |
shreeshas95 | 1:a0055b3280c8 | 250 | int DS_counter; |
shreeshas95 | 1:a0055b3280c8 | 251 | bool DS_f; |
shreeshas95 | 1:a0055b3280c8 | 252 | bool make_DataStream_f; |
shreeshas95 | 1:a0055b3280c8 | 253 | // #define make_DataStream {\ |
shreeshas95 | 1:a0055b3280c8 | 254 | // unsigned char* ptr;\ |
shreeshas95 | 1:a0055b3280c8 | 255 | // if(make_DataStream_f == true){\ |
shreeshas95 | 1:a0055b3280c8 | 256 | // DS_state = true;\ |
shreeshas95 | 1:a0055b3280c8 | 257 | // DS_counter = 0;\ |
shreeshas95 | 1:a0055b3280c8 | 258 | // DS_f = false;\ |
shreeshas95 | 1:a0055b3280c8 | 259 | // make_DataStream_f = false;\ |
shreeshas95 | 1:a0055b3280c8 | 260 | // }\ |
shreeshas95 | 1:a0055b3280c8 | 261 | // if(DS_state){\ |
shreeshas95 | 1:a0055b3280c8 | 262 | // if(DS_counter < total_frames-type0_no){\ |
shreeshas95 | 1:a0055b3280c8 | 263 | // type1_frame(ptr); \ |
shreeshas95 | 1:a0055b3280c8 | 264 | // DS_f = true;\ |
shreeshas95 | 1:a0055b3280c8 | 265 | // }\ |
shreeshas95 | 1:a0055b3280c8 | 266 | // else if(DS_counter < total_frames ){\ |
shreeshas95 | 1:a0055b3280c8 | 267 | // type0_frame(ptr);\ |
shreeshas95 | 1:a0055b3280c8 | 268 | // DS_f = true;\ |
shreeshas95 | 1:a0055b3280c8 | 269 | // }\ |
shreeshas95 | 1:a0055b3280c8 | 270 | // DS_counter++;\ |
shreeshas95 | 1:a0055b3280c8 | 271 | // }\ |
shreeshas95 | 1:a0055b3280c8 | 272 | // DS_state = !DS_state;\ |
shreeshas95 | 1:a0055b3280c8 | 273 | // if (DS_f){\ |
shreeshas95 | 1:a0055b3280c8 | 274 | // DS_f = false;\ |
shreeshas95 | 1:a0055b3280c8 | 275 | // convolution(ptr);\ |
shreeshas95 | 1:a0055b3280c8 | 276 | // interleave(convoluted_frame,interleave_data[0]);\ |
shreeshas95 | 1:a0055b3280c8 | 277 | // interleave(convoluted_frame+ 135,interleave_data[1]);\ |
shreeshas95 | 1:a0055b3280c8 | 278 | // }\ |
shreeshas95 | 1:a0055b3280c8 | 279 | // DS_index = (DS_state==true)?1:0;\ |
shreeshas95 | 1:a0055b3280c8 | 280 | // } |
shreeshas95 | 1:a0055b3280c8 | 281 | |
shreeshas95 | 1:a0055b3280c8 | 282 | public: |
shreeshas95 | 1:a0055b3280c8 | 283 | |
shreeshas95 | 1:a0055b3280c8 | 284 | bool reset_adf; |
shreeshas95 | 1:a0055b3280c8 | 285 | SND_TM(){ |
shreeshas95 | 1:a0055b3280c8 | 286 | MAX_SEGMENT = (MAX_ADF_LEN-T_FRAME_SIZE)/( S_FRAME_SIZE + ISR*T_FRAME_SIZE); //(max length - eos size)/(sframe length + tFrameLength*ISR) |
shreeshas95 | 1:a0055b3280c8 | 287 | // cout<<int(MAX_SEGMENT)<<endl; |
shreeshas95 | 1:a0055b3280c8 | 288 | } |
shreeshas95 | 1:a0055b3280c8 | 289 | |
shreeshas95 | 1:a0055b3280c8 | 290 | |
shreeshas95 | 1:a0055b3280c8 | 291 | |
shreeshas95 | 1:a0055b3280c8 | 292 | void head_pointer(Base_tm* ptr){ |
shreeshas95 | 1:a0055b3280c8 | 293 | head_ptr = ptr ; |
shreeshas95 | 1:a0055b3280c8 | 294 | type1_frame_flag = true; |
shreeshas95 | 1:a0055b3280c8 | 295 | type0_frame_flag = true; |
shreeshas95 | 1:a0055b3280c8 | 296 | make_DataStream_f = true; |
shreeshas95 | 1:a0055b3280c8 | 297 | transmit_data_f = true; |
shreeshas95 | 1:a0055b3280c8 | 298 | diff_prev = 0; |
shreeshas95 | 1:a0055b3280c8 | 299 | data_number(); |
shreeshas95 | 1:a0055b3280c8 | 300 | // make_DataStream; |
shreeshas95 | 2:2caf2a9a13aa | 301 | gPC.putc('z'); |
shreeshas95 | 1:a0055b3280c8 | 302 | } |
shreeshas95 | 1:a0055b3280c8 | 303 | |
shreeshas95 | 1:a0055b3280c8 | 304 | |
shreeshas95 | 1:a0055b3280c8 | 305 | void inline transmit_data(unsigned char * transmit , bool * last_buffer){ |
shreeshas95 | 1:a0055b3280c8 | 306 | if(transmit_data_f){ |
shreeshas95 | 1:a0055b3280c8 | 307 | RB_c = 0; |
shreeshas95 | 1:a0055b3280c8 | 308 | Sframe_c = 0; |
shreeshas95 | 1:a0055b3280c8 | 309 | SCH40_c = 0; |
shreeshas95 | 1:a0055b3280c8 | 310 | FCCH80_c = 0; |
shreeshas95 | 1:a0055b3280c8 | 311 | Tframe_c = 0; |
shreeshas95 | 1:a0055b3280c8 | 312 | EOS_c = 0; |
shreeshas95 | 1:a0055b3280c8 | 313 | segment_c = 0; |
shreeshas95 | 1:a0055b3280c8 | 314 | data_c = 0; |
shreeshas95 | 1:a0055b3280c8 | 315 | |
shreeshas95 | 1:a0055b3280c8 | 316 | Sframe = true; |
shreeshas95 | 1:a0055b3280c8 | 317 | SCH40_f = false; |
shreeshas95 | 1:a0055b3280c8 | 318 | data_f = false; |
shreeshas95 | 1:a0055b3280c8 | 319 | FCCH80_f = false; |
shreeshas95 | 1:a0055b3280c8 | 320 | transmit_data_f = false; |
shreeshas95 | 1:a0055b3280c8 | 321 | reset_adf = false; |
shreeshas95 | 1:a0055b3280c8 | 322 | *last_buffer = false; |
shreeshas95 | 1:a0055b3280c8 | 323 | } |
shreeshas95 | 1:a0055b3280c8 | 324 | |
shreeshas95 | 1:a0055b3280c8 | 325 | for(RB_c = 0 ; RB_c<112 ; RB_c++){ |
shreeshas95 | 1:a0055b3280c8 | 326 | |
shreeshas95 | 1:a0055b3280c8 | 327 | if(junk_f){ |
shreeshas95 | 1:a0055b3280c8 | 328 | transmit[RB_c] = 0xaa; |
shreeshas95 | 1:a0055b3280c8 | 329 | } |
shreeshas95 | 1:a0055b3280c8 | 330 | |
shreeshas95 | 1:a0055b3280c8 | 331 | if(Sframe){ |
shreeshas95 | 1:a0055b3280c8 | 332 | transmit[RB_c] = S_frame[Sframe_c++]; |
shreeshas95 | 1:a0055b3280c8 | 333 | if(Sframe_c == 48){ |
shreeshas95 | 1:a0055b3280c8 | 334 | // printf("exit s frame\n"); |
shreeshas95 | 1:a0055b3280c8 | 335 | Sframe_c = 0; |
shreeshas95 | 1:a0055b3280c8 | 336 | Sframe = false; |
shreeshas95 | 1:a0055b3280c8 | 337 | SCH40_f =true; |
shreeshas95 | 1:a0055b3280c8 | 338 | } |
shreeshas95 | 1:a0055b3280c8 | 339 | continue; |
shreeshas95 | 1:a0055b3280c8 | 340 | } |
shreeshas95 | 1:a0055b3280c8 | 341 | // |
shreeshas95 | 1:a0055b3280c8 | 342 | if(SCH40_f){ |
shreeshas95 | 1:a0055b3280c8 | 343 | transmit[RB_c] = SCH40[SCH40_c++]; |
shreeshas95 | 1:a0055b3280c8 | 344 | if(SCH40_c == 5 ){ |
shreeshas95 | 1:a0055b3280c8 | 345 | SCH40_c = 0; |
shreeshas95 | 1:a0055b3280c8 | 346 | SCH40_f = false; |
shreeshas95 | 1:a0055b3280c8 | 347 | data_f = true; |
shreeshas95 | 1:a0055b3280c8 | 348 | // printf("exit SCH40 frame\n"); |
shreeshas95 | 1:a0055b3280c8 | 349 | } |
shreeshas95 | 1:a0055b3280c8 | 350 | continue; |
shreeshas95 | 1:a0055b3280c8 | 351 | } |
shreeshas95 | 1:a0055b3280c8 | 352 | // |
shreeshas95 | 1:a0055b3280c8 | 353 | if(data_f){ |
shreeshas95 | 1:a0055b3280c8 | 354 | transmit[RB_c] = interleave_data[DS_index][data_c++]; |
shreeshas95 | 1:a0055b3280c8 | 355 | if(data_c == 144){ |
shreeshas95 | 1:a0055b3280c8 | 356 | // make_DataStream; |
shreeshas95 | 1:a0055b3280c8 | 357 | data_c = 0; |
shreeshas95 | 1:a0055b3280c8 | 358 | FCCH80_f = true; |
shreeshas95 | 1:a0055b3280c8 | 359 | data_f = false; |
shreeshas95 | 1:a0055b3280c8 | 360 | // printf("exit Data\n"); |
shreeshas95 | 1:a0055b3280c8 | 361 | } |
shreeshas95 | 1:a0055b3280c8 | 362 | continue; |
shreeshas95 | 1:a0055b3280c8 | 363 | } |
shreeshas95 | 1:a0055b3280c8 | 364 | |
shreeshas95 | 1:a0055b3280c8 | 365 | if(FCCH80_f){ |
shreeshas95 | 1:a0055b3280c8 | 366 | transmit[RB_c] = FCCH80[FCCH80_c++]; |
shreeshas95 | 1:a0055b3280c8 | 367 | if(FCCH80_c == 10){ |
shreeshas95 | 1:a0055b3280c8 | 368 | FCCH80_c = 0; |
shreeshas95 | 1:a0055b3280c8 | 369 | FCCH80_f = false; |
shreeshas95 | 1:a0055b3280c8 | 370 | // printf("exit FCCH80\n"); |
shreeshas95 | 1:a0055b3280c8 | 371 | if(++Tframe_c != ISR) |
shreeshas95 | 1:a0055b3280c8 | 372 | SCH40_f = true; |
shreeshas95 | 1:a0055b3280c8 | 373 | else{ |
shreeshas95 | 1:a0055b3280c8 | 374 | Tframe_c = 0; |
shreeshas95 | 1:a0055b3280c8 | 375 | segment_c++; |
shreeshas95 | 1:a0055b3280c8 | 376 | if(segment_c == SEGMENT_NO||segment_c == MAX_SEGMENT) |
shreeshas95 | 1:a0055b3280c8 | 377 | {eos_f = true;} |
shreeshas95 | 1:a0055b3280c8 | 378 | else{ |
shreeshas95 | 1:a0055b3280c8 | 379 | Sframe = true; |
shreeshas95 | 1:a0055b3280c8 | 380 | } |
shreeshas95 | 1:a0055b3280c8 | 381 | } |
shreeshas95 | 1:a0055b3280c8 | 382 | } |
shreeshas95 | 1:a0055b3280c8 | 383 | continue; |
shreeshas95 | 1:a0055b3280c8 | 384 | } |
shreeshas95 | 1:a0055b3280c8 | 385 | |
shreeshas95 | 1:a0055b3280c8 | 386 | if(eos_f){ |
shreeshas95 | 1:a0055b3280c8 | 387 | transmit[RB_c] = EoS[EOS_c++]; |
shreeshas95 | 1:a0055b3280c8 | 388 | if(EOS_c == EOS_SIZE){ |
shreeshas95 | 1:a0055b3280c8 | 389 | EOS_c = 0; |
shreeshas95 | 1:a0055b3280c8 | 390 | eos_f = false; |
shreeshas95 | 1:a0055b3280c8 | 391 | // printf("exit EOS\n"); |
shreeshas95 | 1:a0055b3280c8 | 392 | if(segment_c == MAX_SEGMENT){ |
shreeshas95 | 1:a0055b3280c8 | 393 | segment_c = 0; |
shreeshas95 | 1:a0055b3280c8 | 394 | SEGMENT_NO = SEGMENT_NO - MAX_SEGMENT; |
shreeshas95 | 1:a0055b3280c8 | 395 | reset_adf = true; |
shreeshas95 | 1:a0055b3280c8 | 396 | Sframe = true; |
shreeshas95 | 1:a0055b3280c8 | 397 | }else{ |
shreeshas95 | 1:a0055b3280c8 | 398 | *last_buffer = true; |
shreeshas95 | 1:a0055b3280c8 | 399 | } |
shreeshas95 | 1:a0055b3280c8 | 400 | junk_f = true; |
shreeshas95 | 1:a0055b3280c8 | 401 | } |
shreeshas95 | 1:a0055b3280c8 | 402 | continue; |
shreeshas95 | 1:a0055b3280c8 | 403 | } |
shreeshas95 | 1:a0055b3280c8 | 404 | } |
shreeshas95 | 1:a0055b3280c8 | 405 | |
shreeshas95 | 1:a0055b3280c8 | 406 | differential_encode(transmit,112); |
shreeshas95 | 1:a0055b3280c8 | 407 | if(reset_adf == true){ |
shreeshas95 | 1:a0055b3280c8 | 408 | diff_prev = 0; |
shreeshas95 | 1:a0055b3280c8 | 409 | junk_f = false; |
shreeshas95 | 1:a0055b3280c8 | 410 | } |
shreeshas95 | 1:a0055b3280c8 | 411 | |
shreeshas95 | 1:a0055b3280c8 | 412 | } |
shreeshas95 | 1:a0055b3280c8 | 413 | |
shreeshas95 | 1:a0055b3280c8 | 414 | }; |
shreeshas95 | 1:a0055b3280c8 | 415 | SND_TM snd_tm; |