![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
hi
Dependencies: FreescaleIAP mbed-rtos mbed
TMTC.cpp@0:bcbd76c86cde, 2015-12-16 (annotated)
- Committer:
- cholletisaik777
- Date:
- Wed Dec 16 09:06:59 2015 +0000
- Revision:
- 0:bcbd76c86cde
nnb
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cholletisaik777 | 0:bcbd76c86cde | 1 | #include "structure.h" |
cholletisaik777 | 0:bcbd76c86cde | 2 | #include "i2c.h" |
cholletisaik777 | 0:bcbd76c86cde | 3 | #include "pinconfig.h" |
cholletisaik777 | 0:bcbd76c86cde | 4 | #include "crc.h" |
cholletisaik777 | 0:bcbd76c86cde | 5 | #include "TMTC.h" |
cholletisaik777 | 0:bcbd76c86cde | 6 | #include "cdms_rtc.h" |
cholletisaik777 | 0:bcbd76c86cde | 7 | #include "cdms_sd.h" |
cholletisaik777 | 0:bcbd76c86cde | 8 | #include "Flash.h" |
cholletisaik777 | 0:bcbd76c86cde | 9 | |
cholletisaik777 | 0:bcbd76c86cde | 10 | DigitalIn tm_status_4m_slv(PIN39); //I2C interrupt to CDMS from BAE |
cholletisaik777 | 0:bcbd76c86cde | 11 | //DigitalIn tm_status_4m_pl(PIN61); //I2C interrupt to CDMS from PL |
cholletisaik777 | 0:bcbd76c86cde | 12 | |
cholletisaik777 | 0:bcbd76c86cde | 13 | uint8_t received = 0; |
cholletisaik777 | 0:bcbd76c86cde | 14 | uint16_t mid1; |
cholletisaik777 | 0:bcbd76c86cde | 15 | uint16_t mid2; |
cholletisaik777 | 0:bcbd76c86cde | 16 | uint16_t Nbytes; |
cholletisaik777 | 0:bcbd76c86cde | 17 | uint32_t Data; |
cholletisaik777 | 0:bcbd76c86cde | 18 | uint16_t nbytes; |
cholletisaik777 | 0:bcbd76c86cde | 19 | uint8_t flash_counter = 0; |
cholletisaik777 | 0:bcbd76c86cde | 20 | uint16_t crc16; |
cholletisaik777 | 0:bcbd76c86cde | 21 | uint16_t mid; |
cholletisaik777 | 0:bcbd76c86cde | 22 | uint32_t block; |
cholletisaik777 | 0:bcbd76c86cde | 23 | |
cholletisaik777 | 0:bcbd76c86cde | 24 | Base_tm *FCTN_CDMS_RLY_TMTC(Base_tc *tc) |
cholletisaik777 | 0:bcbd76c86cde | 25 | { |
cholletisaik777 | 0:bcbd76c86cde | 26 | printf("\rTC execution in progress\r\n"); |
cholletisaik777 | 0:bcbd76c86cde | 27 | Base_tm *tm = new Long_tm; |
cholletisaik777 | 0:bcbd76c86cde | 28 | Base_tm *tm_pointer = tm; |
cholletisaik777 | 0:bcbd76c86cde | 29 | received = 0; |
cholletisaik777 | 0:bcbd76c86cde | 30 | switch(GETapid(tc)) |
cholletisaik777 | 0:bcbd76c86cde | 31 | { |
cholletisaik777 | 0:bcbd76c86cde | 32 | case 1: //apid=01 implies it corresponds to bae |
cholletisaik777 | 0:bcbd76c86cde | 33 | { |
cholletisaik777 | 0:bcbd76c86cde | 34 | printf("Telecommand is for BAE\r\n"); |
cholletisaik777 | 0:bcbd76c86cde | 35 | printf("Sending TC to BAE...\r\n"); //interrupt to be sent to the bae |
cholletisaik777 | 0:bcbd76c86cde | 36 | FCTN_I2C_WRITE((char*)tc->TC_string); |
cholletisaik777 | 0:bcbd76c86cde | 37 | while(1) |
cholletisaik777 | 0:bcbd76c86cde | 38 | { |
cholletisaik777 | 0:bcbd76c86cde | 39 | wait(1); //TimeOut instead of wait |
cholletisaik777 | 0:bcbd76c86cde | 40 | if(tm_status_4m_slv == 1) |
cholletisaik777 | 0:bcbd76c86cde | 41 | { |
cholletisaik777 | 0:bcbd76c86cde | 42 | printf("receiving...\r\n"); |
cholletisaik777 | 0:bcbd76c86cde | 43 | FCTN_I2C_READ((char*)tm_pointer->TM_string); |
cholletisaik777 | 0:bcbd76c86cde | 44 | printf("%s", tm_pointer->TM_string); |
cholletisaik777 | 0:bcbd76c86cde | 45 | received+=1; |
cholletisaik777 | 0:bcbd76c86cde | 46 | tm_pointer = tm_pointer->next_TM; |
cholletisaik777 | 0:bcbd76c86cde | 47 | break; //only for testing purpose |
cholletisaik777 | 0:bcbd76c86cde | 48 | } |
cholletisaik777 | 0:bcbd76c86cde | 49 | else |
cholletisaik777 | 0:bcbd76c86cde | 50 | { |
cholletisaik777 | 0:bcbd76c86cde | 51 | break; |
cholletisaik777 | 0:bcbd76c86cde | 52 | } |
cholletisaik777 | 0:bcbd76c86cde | 53 | } |
cholletisaik777 | 0:bcbd76c86cde | 54 | if(received >= 1 ) |
cholletisaik777 | 0:bcbd76c86cde | 55 | { |
cholletisaik777 | 0:bcbd76c86cde | 56 | printf("Telemetry is received from BAE\r\n"); |
cholletisaik777 | 0:bcbd76c86cde | 57 | Base_tm *tm_print = tm; |
cholletisaik777 | 0:bcbd76c86cde | 58 | for(uint8_t i=0;i<received;i++) |
cholletisaik777 | 0:bcbd76c86cde | 59 | { |
cholletisaik777 | 0:bcbd76c86cde | 60 | printf("%s", tm_print->TM_string); |
cholletisaik777 | 0:bcbd76c86cde | 61 | tm_print = tm_print->next_TM; //for check |
cholletisaik777 | 0:bcbd76c86cde | 62 | } |
cholletisaik777 | 0:bcbd76c86cde | 63 | received = 0; |
cholletisaik777 | 0:bcbd76c86cde | 64 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 65 | } |
cholletisaik777 | 0:bcbd76c86cde | 66 | else |
cholletisaik777 | 0:bcbd76c86cde | 67 | { |
cholletisaik777 | 0:bcbd76c86cde | 68 | printf("Telemetry is not received from BAE\r\n"); |
cholletisaik777 | 0:bcbd76c86cde | 69 | tm_pointer = new Short_tm; |
cholletisaik777 | 0:bcbd76c86cde | 70 | tm_pointer->TM_string[0] = 0xB0; |
cholletisaik777 | 0:bcbd76c86cde | 71 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 72 | tm_pointer->TM_string[2] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 73 | tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided |
cholletisaik777 | 0:bcbd76c86cde | 74 | tm_pointer->TM_string[4] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 75 | for(uint8_t i=0;i<6;i++) |
cholletisaik777 | 0:bcbd76c86cde | 76 | { |
cholletisaik777 | 0:bcbd76c86cde | 77 | tm_pointer->TM_string[i+5] = 0; |
cholletisaik777 | 0:bcbd76c86cde | 78 | } |
cholletisaik777 | 0:bcbd76c86cde | 79 | crc16 = CRC::crc16_gen(tm->TM_string,11); |
cholletisaik777 | 0:bcbd76c86cde | 80 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 81 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 82 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 83 | } |
cholletisaik777 | 0:bcbd76c86cde | 84 | break; |
cholletisaik777 | 0:bcbd76c86cde | 85 | } |
cholletisaik777 | 0:bcbd76c86cde | 86 | case 2: |
cholletisaik777 | 0:bcbd76c86cde | 87 | { |
cholletisaik777 | 0:bcbd76c86cde | 88 | printf("Telecommand is for CDMS\r\n"); //apid = 10 corresponds to cdms |
cholletisaik777 | 0:bcbd76c86cde | 89 | switch(GETservice_type(tc)) |
cholletisaik777 | 0:bcbd76c86cde | 90 | { |
cholletisaik777 | 0:bcbd76c86cde | 91 | case 6: |
cholletisaik777 | 0:bcbd76c86cde | 92 | { |
cholletisaik777 | 0:bcbd76c86cde | 93 | printf("service:MMS\r\n"); |
cholletisaik777 | 0:bcbd76c86cde | 94 | switch(GETservice_subtype(tc)) |
cholletisaik777 | 0:bcbd76c86cde | 95 | { |
cholletisaik777 | 0:bcbd76c86cde | 96 | case 1: |
cholletisaik777 | 0:bcbd76c86cde | 97 | { |
cholletisaik777 | 0:bcbd76c86cde | 98 | printf("sub_service:Read from Memory\r\n"); |
cholletisaik777 | 0:bcbd76c86cde | 99 | if(GETpid(tc) == 2) |
cholletisaik777 | 0:bcbd76c86cde | 100 | { |
cholletisaik777 | 0:bcbd76c86cde | 101 | printf("pid:RD_L_FLASH\r\n"); |
cholletisaik777 | 0:bcbd76c86cde | 102 | mid1 = ((((uint16_t)tc->TC_string[5])<<8)|(uint16_t)(tc->TC_string[6])); |
cholletisaik777 | 0:bcbd76c86cde | 103 | mid2 = ((((uint16_t)tc->TC_string[7])<<8)|(uint16_t)(tc->TC_string[8])); |
cholletisaik777 | 0:bcbd76c86cde | 104 | Nbytes = (((mid2-mid1)*32)/8)+4; |
cholletisaik777 | 0:bcbd76c86cde | 105 | uint8_t data[4*Nbytes]; |
cholletisaik777 | 0:bcbd76c86cde | 106 | for(uint8_t i=0;i<mid2-mid1+1;i++) |
cholletisaik777 | 0:bcbd76c86cde | 107 | { |
cholletisaik777 | 0:bcbd76c86cde | 108 | Data = FCTN_CDMS_RD_FLASH(mid1+i); |
cholletisaik777 | 0:bcbd76c86cde | 109 | data[4*i] = (uint8_t)((Data&0xFF000000)>>24); |
cholletisaik777 | 0:bcbd76c86cde | 110 | data[4*i+1] = (uint8_t)((Data&0xFF000000)>>16); |
cholletisaik777 | 0:bcbd76c86cde | 111 | data[4*i+2] = (uint8_t)((Data&0xFF000000)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 112 | data[4*i+3] = (uint8_t)(Data&0xFF000000); |
cholletisaik777 | 0:bcbd76c86cde | 113 | } |
cholletisaik777 | 0:bcbd76c86cde | 114 | nbytes = Nbytes; |
cholletisaik777 | 0:bcbd76c86cde | 115 | flash_counter = 0; |
cholletisaik777 | 0:bcbd76c86cde | 116 | while(nbytes>=8) |
cholletisaik777 | 0:bcbd76c86cde | 117 | { |
cholletisaik777 | 0:bcbd76c86cde | 118 | tm_pointer = new Long_tm; |
cholletisaik777 | 0:bcbd76c86cde | 119 | tm_pointer->TM_string[0] = 0x30; |
cholletisaik777 | 0:bcbd76c86cde | 120 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 121 | tm_pointer->TM_string[2] = (uint8_t)(flash_counter); |
cholletisaik777 | 0:bcbd76c86cde | 122 | for(uint8_t i=0;i<8;i++) |
cholletisaik777 | 0:bcbd76c86cde | 123 | { |
cholletisaik777 | 0:bcbd76c86cde | 124 | tm_pointer->TM_string[3+i] = data[i+128*flash_counter]; |
cholletisaik777 | 0:bcbd76c86cde | 125 | } |
cholletisaik777 | 0:bcbd76c86cde | 126 | crc16 = CRC::crc16_gen(tm->TM_string,9); |
cholletisaik777 | 0:bcbd76c86cde | 127 | tm_pointer->TM_string[9] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 128 | tm_pointer->TM_string[10] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 129 | tm_pointer = tm_pointer->next_TM; |
cholletisaik777 | 0:bcbd76c86cde | 130 | nbytes-=128; |
cholletisaik777 | 0:bcbd76c86cde | 131 | flash_counter++; |
cholletisaik777 | 0:bcbd76c86cde | 132 | } |
cholletisaik777 | 0:bcbd76c86cde | 133 | if(nbytes>0) |
cholletisaik777 | 0:bcbd76c86cde | 134 | { |
cholletisaik777 | 0:bcbd76c86cde | 135 | tm_pointer->TM_string[0] = 0x30; |
cholletisaik777 | 0:bcbd76c86cde | 136 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 137 | tm_pointer->TM_string[2] = (uint8_t)((flash_counter&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 138 | tm_pointer->TM_string[3] = (uint8_t)(flash_counter&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 139 | for(uint8_t i=0;i<nbytes;i++) |
cholletisaik777 | 0:bcbd76c86cde | 140 | { |
cholletisaik777 | 0:bcbd76c86cde | 141 | tm_pointer->TM_string[4+i] = data[i+128*flash_counter]; |
cholletisaik777 | 0:bcbd76c86cde | 142 | } |
cholletisaik777 | 0:bcbd76c86cde | 143 | for(uint8_t i=nbytes;i<128;i++) |
cholletisaik777 | 0:bcbd76c86cde | 144 | { |
cholletisaik777 | 0:bcbd76c86cde | 145 | tm_pointer->TM_string[4+i] = 0; |
cholletisaik777 | 0:bcbd76c86cde | 146 | } |
cholletisaik777 | 0:bcbd76c86cde | 147 | crc16 = CRC::crc16_gen(tm->TM_string,132); |
cholletisaik777 | 0:bcbd76c86cde | 148 | tm_pointer->TM_string[132] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 149 | tm_pointer->TM_string[133] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 150 | } |
cholletisaik777 | 0:bcbd76c86cde | 151 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 152 | } |
cholletisaik777 | 0:bcbd76c86cde | 153 | else if (GETpid(tc)==0x22) |
cholletisaik777 | 0:bcbd76c86cde | 154 | { |
cholletisaik777 | 0:bcbd76c86cde | 155 | printf("RD_S_FLASH\r\n"); |
cholletisaik777 | 0:bcbd76c86cde | 156 | mid1 = ((((uint16_t)tc->TC_string[5])<<8)|(uint16_t)(tc->TC_string[6])); |
cholletisaik777 | 0:bcbd76c86cde | 157 | mid2 = ((((uint16_t)tc->TC_string[7])<<8)|(uint16_t)(tc->TC_string[8])); |
cholletisaik777 | 0:bcbd76c86cde | 158 | Nbytes = (((mid2-mid1)*32)/8)+4; |
cholletisaik777 | 0:bcbd76c86cde | 159 | uint8_t data[4*Nbytes]; |
cholletisaik777 | 0:bcbd76c86cde | 160 | for(uint8_t i=0;i<mid2-mid1+1;i++) |
cholletisaik777 | 0:bcbd76c86cde | 161 | { |
cholletisaik777 | 0:bcbd76c86cde | 162 | Data = FCTN_CDMS_RD_FLASH(mid1+i); |
cholletisaik777 | 0:bcbd76c86cde | 163 | data[4*i] = (uint8_t)((Data&0xFF000000)>>24); |
cholletisaik777 | 0:bcbd76c86cde | 164 | data[4*i+1] = (uint8_t)((Data&0xFF000000)>>16); |
cholletisaik777 | 0:bcbd76c86cde | 165 | data[4*i+2] = (uint8_t)((Data&0xFF000000)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 166 | data[4*i+3] = (uint8_t)(Data&0xFF000000); |
cholletisaik777 | 0:bcbd76c86cde | 167 | } |
cholletisaik777 | 0:bcbd76c86cde | 168 | nbytes = Nbytes; |
cholletisaik777 | 0:bcbd76c86cde | 169 | flash_counter = 0; |
cholletisaik777 | 0:bcbd76c86cde | 170 | while(nbytes>=8) |
cholletisaik777 | 0:bcbd76c86cde | 171 | { |
cholletisaik777 | 0:bcbd76c86cde | 172 | tm_pointer = new Short_tm; |
cholletisaik777 | 0:bcbd76c86cde | 173 | tm_pointer->TM_string[0] = 0xC0; |
cholletisaik777 | 0:bcbd76c86cde | 174 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 175 | tm_pointer->TM_string[2] = (uint8_t)(flash_counter); |
cholletisaik777 | 0:bcbd76c86cde | 176 | for(uint8_t i=0;i<8;i++) |
cholletisaik777 | 0:bcbd76c86cde | 177 | { |
cholletisaik777 | 0:bcbd76c86cde | 178 | tm_pointer->TM_string[3+i] = data[i+8*flash_counter]; |
cholletisaik777 | 0:bcbd76c86cde | 179 | } |
cholletisaik777 | 0:bcbd76c86cde | 180 | crc16 = CRC::crc16_gen(tm->TM_string,11); |
cholletisaik777 | 0:bcbd76c86cde | 181 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 182 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 183 | tm_pointer = tm_pointer->next_TM; |
cholletisaik777 | 0:bcbd76c86cde | 184 | nbytes-=8; |
cholletisaik777 | 0:bcbd76c86cde | 185 | flash_counter++; |
cholletisaik777 | 0:bcbd76c86cde | 186 | } |
cholletisaik777 | 0:bcbd76c86cde | 187 | if(nbytes>0) |
cholletisaik777 | 0:bcbd76c86cde | 188 | { |
cholletisaik777 | 0:bcbd76c86cde | 189 | tm_pointer->TM_string[0] = 0xC0; |
cholletisaik777 | 0:bcbd76c86cde | 190 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 191 | tm_pointer->TM_string[2] = (uint8_t)(flash_counter); |
cholletisaik777 | 0:bcbd76c86cde | 192 | for(uint8_t i=0;i<nbytes;i++) |
cholletisaik777 | 0:bcbd76c86cde | 193 | { |
cholletisaik777 | 0:bcbd76c86cde | 194 | tm_pointer->TM_string[3+i] = data[i+8*flash_counter]; |
cholletisaik777 | 0:bcbd76c86cde | 195 | } |
cholletisaik777 | 0:bcbd76c86cde | 196 | for(uint8_t i=nbytes;i<128;i++) |
cholletisaik777 | 0:bcbd76c86cde | 197 | { |
cholletisaik777 | 0:bcbd76c86cde | 198 | tm_pointer->TM_string[3+i] = 0; |
cholletisaik777 | 0:bcbd76c86cde | 199 | } |
cholletisaik777 | 0:bcbd76c86cde | 200 | crc16 = CRC::crc16_gen(tm->TM_string,11); |
cholletisaik777 | 0:bcbd76c86cde | 201 | tm_pointer->TM_string[132] = (uint8_t)((crc16&0xFF00)>>2); |
cholletisaik777 | 0:bcbd76c86cde | 202 | tm_pointer->TM_string[133] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 203 | } |
cholletisaik777 | 0:bcbd76c86cde | 204 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 205 | } |
cholletisaik777 | 0:bcbd76c86cde | 206 | else if (GETpid(tc)==0x42) |
cholletisaik777 | 0:bcbd76c86cde | 207 | { |
cholletisaik777 | 0:bcbd76c86cde | 208 | printf("RD_L_RAM\r\r\n"); //to be discussed which RAM variables are to read; |
cholletisaik777 | 0:bcbd76c86cde | 209 | tm_pointer = new Short_tm; //for now sending ACKL234 |
cholletisaik777 | 0:bcbd76c86cde | 210 | tm_pointer->TM_string[0] = 0xB0; |
cholletisaik777 | 0:bcbd76c86cde | 211 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 212 | tm_pointer->TM_string[2] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 213 | tm_pointer->TM_string[3] = ACKCODE; |
cholletisaik777 | 0:bcbd76c86cde | 214 | tm_pointer->TM_string[4] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 215 | for(uint8_t i=0;i<6;i++) |
cholletisaik777 | 0:bcbd76c86cde | 216 | { |
cholletisaik777 | 0:bcbd76c86cde | 217 | tm_pointer->TM_string[i+5] = 0; |
cholletisaik777 | 0:bcbd76c86cde | 218 | } |
cholletisaik777 | 0:bcbd76c86cde | 219 | crc16 = CRC::crc16_gen(tm->TM_string,11); |
cholletisaik777 | 0:bcbd76c86cde | 220 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 221 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 222 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 223 | } |
cholletisaik777 | 0:bcbd76c86cde | 224 | else if (GETpid(tc)==0x62) |
cholletisaik777 | 0:bcbd76c86cde | 225 | { |
cholletisaik777 | 0:bcbd76c86cde | 226 | printf("RD_S_RAM\r\r\n"); //to be discussed which RAM variables are to read; |
cholletisaik777 | 0:bcbd76c86cde | 227 | tm_pointer = new Short_tm; //for now sending ACKL234 |
cholletisaik777 | 0:bcbd76c86cde | 228 | tm_pointer->TM_string[0] = 0xB0; |
cholletisaik777 | 0:bcbd76c86cde | 229 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 230 | tm_pointer->TM_string[2] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 231 | tm_pointer->TM_string[3] = ACKCODE; |
cholletisaik777 | 0:bcbd76c86cde | 232 | tm_pointer->TM_string[4] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 233 | for(uint8_t i=0;i<6;i++) |
cholletisaik777 | 0:bcbd76c86cde | 234 | { |
cholletisaik777 | 0:bcbd76c86cde | 235 | tm_pointer->TM_string[i+5] = 0; |
cholletisaik777 | 0:bcbd76c86cde | 236 | } |
cholletisaik777 | 0:bcbd76c86cde | 237 | crc16 = CRC::crc16_gen(tm->TM_string,11); |
cholletisaik777 | 0:bcbd76c86cde | 238 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 239 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 240 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 241 | } |
cholletisaik777 | 0:bcbd76c86cde | 242 | else |
cholletisaik777 | 0:bcbd76c86cde | 243 | { |
cholletisaik777 | 0:bcbd76c86cde | 244 | printf("INVALID TC\r\n"); //Send Invalid TC Telemetry |
cholletisaik777 | 0:bcbd76c86cde | 245 | tm_pointer = new Short_tm; |
cholletisaik777 | 0:bcbd76c86cde | 246 | tm_pointer->TM_string[0] = 0xB0; |
cholletisaik777 | 0:bcbd76c86cde | 247 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 248 | tm_pointer->TM_string[2] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 249 | tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided |
cholletisaik777 | 0:bcbd76c86cde | 250 | tm_pointer->TM_string[4] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 251 | for(uint8_t i=0;i<6;i++) |
cholletisaik777 | 0:bcbd76c86cde | 252 | { |
cholletisaik777 | 0:bcbd76c86cde | 253 | tm_pointer->TM_string[i+5] = 0; |
cholletisaik777 | 0:bcbd76c86cde | 254 | } |
cholletisaik777 | 0:bcbd76c86cde | 255 | crc16 = CRC::crc16_gen(tm->TM_string,11); |
cholletisaik777 | 0:bcbd76c86cde | 256 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 257 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 258 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 259 | } |
cholletisaik777 | 0:bcbd76c86cde | 260 | break; |
cholletisaik777 | 0:bcbd76c86cde | 261 | } |
cholletisaik777 | 0:bcbd76c86cde | 262 | case 5: |
cholletisaik777 | 0:bcbd76c86cde | 263 | { |
cholletisaik777 | 0:bcbd76c86cde | 264 | printf("WRITE ON MEMORY\r\n"); |
cholletisaik777 | 0:bcbd76c86cde | 265 | switch(GETpid(tc)) |
cholletisaik777 | 0:bcbd76c86cde | 266 | { |
cholletisaik777 | 0:bcbd76c86cde | 267 | case 0: |
cholletisaik777 | 0:bcbd76c86cde | 268 | { |
cholletisaik777 | 0:bcbd76c86cde | 269 | printf("WR_S_FLASH\r\r\n"); |
cholletisaik777 | 0:bcbd76c86cde | 270 | mid = ((uint16_t)tc->TC_string[4]); |
cholletisaik777 | 0:bcbd76c86cde | 271 | block = (((uint32_t)(tc->TC_string[5])<<24)|((uint32_t)(tc->TC_string[5])<<16)|((uint32_t)(tc->TC_string[5])<<8)|((uint32_t)(tc->TC_string[5]))); |
cholletisaik777 | 0:bcbd76c86cde | 272 | FCTN_CDMS_WR_FLASH(mid,block); |
cholletisaik777 | 0:bcbd76c86cde | 273 | tm_pointer = new Short_tm; |
cholletisaik777 | 0:bcbd76c86cde | 274 | tm_pointer->TM_string[0] = 0xB0; |
cholletisaik777 | 0:bcbd76c86cde | 275 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 276 | tm_pointer->TM_string[2] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 277 | tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided |
cholletisaik777 | 0:bcbd76c86cde | 278 | tm_pointer->TM_string[4] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 279 | for(uint8_t i=0;i<6;i++) |
cholletisaik777 | 0:bcbd76c86cde | 280 | { |
cholletisaik777 | 0:bcbd76c86cde | 281 | tm_pointer->TM_string[i+5] = 0; |
cholletisaik777 | 0:bcbd76c86cde | 282 | } |
cholletisaik777 | 0:bcbd76c86cde | 283 | crc16 = CRC::crc16_gen(tm->TM_string,11); |
cholletisaik777 | 0:bcbd76c86cde | 284 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 285 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 286 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 287 | break; |
cholletisaik777 | 0:bcbd76c86cde | 288 | } |
cholletisaik777 | 0:bcbd76c86cde | 289 | case 1: |
cholletisaik777 | 0:bcbd76c86cde | 290 | { |
cholletisaik777 | 0:bcbd76c86cde | 291 | printf("WR_S_RAM\r\r\n"); //RAM variables to be written is to be decided |
cholletisaik777 | 0:bcbd76c86cde | 292 | tm_pointer = new Short_tm; |
cholletisaik777 | 0:bcbd76c86cde | 293 | tm_pointer->TM_string[0] = 0xB0; |
cholletisaik777 | 0:bcbd76c86cde | 294 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 295 | tm_pointer->TM_string[2] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 296 | tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided |
cholletisaik777 | 0:bcbd76c86cde | 297 | tm_pointer->TM_string[4] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 298 | for(uint8_t i=0;i<6;i++) |
cholletisaik777 | 0:bcbd76c86cde | 299 | { |
cholletisaik777 | 0:bcbd76c86cde | 300 | tm_pointer->TM_string[i+5] = 0; |
cholletisaik777 | 0:bcbd76c86cde | 301 | } |
cholletisaik777 | 0:bcbd76c86cde | 302 | crc16 = CRC::crc16_gen(tm->TM_string,11); |
cholletisaik777 | 0:bcbd76c86cde | 303 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 304 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 305 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 306 | break; |
cholletisaik777 | 0:bcbd76c86cde | 307 | } |
cholletisaik777 | 0:bcbd76c86cde | 308 | case 16: |
cholletisaik777 | 0:bcbd76c86cde | 309 | { |
cholletisaik777 | 0:bcbd76c86cde | 310 | printf("WR_L_FLASH\r\n"); |
cholletisaik777 | 0:bcbd76c86cde | 311 | mid = ((uint16_t)tc->TC_string[4]); |
cholletisaik777 | 0:bcbd76c86cde | 312 | for(uint8_t i=0;i<32;i++) |
cholletisaik777 | 0:bcbd76c86cde | 313 | { |
cholletisaik777 | 0:bcbd76c86cde | 314 | block = (((uint32_t)(tc->TC_string[5])<<24)|((uint32_t)(tc->TC_string[5])<<16)|((uint32_t)(tc->TC_string[5])<<8)|((uint32_t)(tc->TC_string[5]))); |
cholletisaik777 | 0:bcbd76c86cde | 315 | FCTN_CDMS_WR_FLASH(mid+i,block); |
cholletisaik777 | 0:bcbd76c86cde | 316 | } |
cholletisaik777 | 0:bcbd76c86cde | 317 | tm_pointer = new Short_tm; |
cholletisaik777 | 0:bcbd76c86cde | 318 | tm_pointer->TM_string[0] = 0xB0; |
cholletisaik777 | 0:bcbd76c86cde | 319 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 320 | tm_pointer->TM_string[2] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 321 | tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided |
cholletisaik777 | 0:bcbd76c86cde | 322 | tm_pointer->TM_string[4] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 323 | for(uint8_t i=0;i<6;i++) |
cholletisaik777 | 0:bcbd76c86cde | 324 | { |
cholletisaik777 | 0:bcbd76c86cde | 325 | tm_pointer->TM_string[i+5] = 0; |
cholletisaik777 | 0:bcbd76c86cde | 326 | } |
cholletisaik777 | 0:bcbd76c86cde | 327 | crc16 = CRC::crc16_gen(tm->TM_string,11); |
cholletisaik777 | 0:bcbd76c86cde | 328 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 329 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 330 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 331 | break; |
cholletisaik777 | 0:bcbd76c86cde | 332 | break; |
cholletisaik777 | 0:bcbd76c86cde | 333 | } |
cholletisaik777 | 0:bcbd76c86cde | 334 | case 17: |
cholletisaik777 | 0:bcbd76c86cde | 335 | { |
cholletisaik777 | 0:bcbd76c86cde | 336 | printf("WR_L_RAM\r\r\n"); //RAM variables to be written is to be decided |
cholletisaik777 | 0:bcbd76c86cde | 337 | tm_pointer = new Short_tm; |
cholletisaik777 | 0:bcbd76c86cde | 338 | tm_pointer->TM_string[0] = 0xB0; |
cholletisaik777 | 0:bcbd76c86cde | 339 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 340 | tm_pointer->TM_string[2] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 341 | tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided |
cholletisaik777 | 0:bcbd76c86cde | 342 | tm_pointer->TM_string[4] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 343 | for(uint8_t i=0;i<6;i++) |
cholletisaik777 | 0:bcbd76c86cde | 344 | { |
cholletisaik777 | 0:bcbd76c86cde | 345 | tm_pointer->TM_string[i+5] = 0; |
cholletisaik777 | 0:bcbd76c86cde | 346 | } |
cholletisaik777 | 0:bcbd76c86cde | 347 | crc16 = CRC::crc16_gen(tm->TM_string,11); |
cholletisaik777 | 0:bcbd76c86cde | 348 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 349 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 350 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 351 | break; |
cholletisaik777 | 0:bcbd76c86cde | 352 | } |
cholletisaik777 | 0:bcbd76c86cde | 353 | default: |
cholletisaik777 | 0:bcbd76c86cde | 354 | { |
cholletisaik777 | 0:bcbd76c86cde | 355 | printf("INVALID TC"); //send invalid TC TM |
cholletisaik777 | 0:bcbd76c86cde | 356 | tm_pointer = new Short_tm; |
cholletisaik777 | 0:bcbd76c86cde | 357 | tm_pointer->TM_string[0] = 0xB0; |
cholletisaik777 | 0:bcbd76c86cde | 358 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 359 | tm_pointer->TM_string[2] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 360 | tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided |
cholletisaik777 | 0:bcbd76c86cde | 361 | tm_pointer->TM_string[4] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 362 | for(uint8_t i=0;i<6;i++) |
cholletisaik777 | 0:bcbd76c86cde | 363 | { |
cholletisaik777 | 0:bcbd76c86cde | 364 | tm_pointer->TM_string[i+5] = 0; |
cholletisaik777 | 0:bcbd76c86cde | 365 | } |
cholletisaik777 | 0:bcbd76c86cde | 366 | crc16 = CRC::crc16_gen(tm->TM_string,11); |
cholletisaik777 | 0:bcbd76c86cde | 367 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 368 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 369 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 370 | break; |
cholletisaik777 | 0:bcbd76c86cde | 371 | } |
cholletisaik777 | 0:bcbd76c86cde | 372 | } |
cholletisaik777 | 0:bcbd76c86cde | 373 | break; |
cholletisaik777 | 0:bcbd76c86cde | 374 | } |
cholletisaik777 | 0:bcbd76c86cde | 375 | // case 6: |
cholletisaik777 | 0:bcbd76c86cde | 376 | // { |
cholletisaik777 | 0:bcbd76c86cde | 377 | // printf("WRITE FROM ONE MEMORY TO ANOTHER\r\r\n"); |
cholletisaik777 | 0:bcbd76c86cde | 378 | // switch(appdata[0]) |
cholletisaik777 | 0:bcbd76c86cde | 379 | // { |
cholletisaik777 | 0:bcbd76c86cde | 380 | // case 0: |
cholletisaik777 | 0:bcbd76c86cde | 381 | // { |
cholletisaik777 | 0:bcbd76c86cde | 382 | // printf("WR_S_FLASH\r\r\n"); |
cholletisaik777 | 0:bcbd76c86cde | 383 | // telemetry_type2[0]=0XB0; |
cholletisaik777 | 0:bcbd76c86cde | 384 | // telemetry_type2[1]=tc_pac_seq_cnt_tm; |
cholletisaik777 | 0:bcbd76c86cde | 385 | // telemetry_type2[2]=tm_pac_seq_cnt_tm; |
cholletisaik777 | 0:bcbd76c86cde | 386 | // telemetry_type2[3]=ackcode_tm; |
cholletisaik777 | 0:bcbd76c86cde | 387 | // for(int i=4;i<11;i++) |
cholletisaik777 | 0:bcbd76c86cde | 388 | // { |
cholletisaik777 | 0:bcbd76c86cde | 389 | // telemetry_type2[i]=0X00; |
cholletisaik777 | 0:bcbd76c86cde | 390 | // } |
cholletisaik777 | 0:bcbd76c86cde | 391 | // break; |
cholletisaik777 | 0:bcbd76c86cde | 392 | // } |
cholletisaik777 | 0:bcbd76c86cde | 393 | // case 1: |
cholletisaik777 | 0:bcbd76c86cde | 394 | // { |
cholletisaik777 | 0:bcbd76c86cde | 395 | // printf("WR_S_RAM\r\r\n"); |
cholletisaik777 | 0:bcbd76c86cde | 396 | // telemetry_type2[0]=0XB0; |
cholletisaik777 | 0:bcbd76c86cde | 397 | // telemetry_type2[1]=tc_pac_seq_cnt_tm; |
cholletisaik777 | 0:bcbd76c86cde | 398 | // telemetry_type2[2]=tm_pac_seq_cnt_tm; |
cholletisaik777 | 0:bcbd76c86cde | 399 | // telemetry_type2[3]=ackcode_tm; |
cholletisaik777 | 0:bcbd76c86cde | 400 | // for(int i=4;i<11;i++) |
cholletisaik777 | 0:bcbd76c86cde | 401 | // { |
cholletisaik777 | 0:bcbd76c86cde | 402 | // telemetry_type2[i]=0X00; |
cholletisaik777 | 0:bcbd76c86cde | 403 | // } |
cholletisaik777 | 0:bcbd76c86cde | 404 | // break; |
cholletisaik777 | 0:bcbd76c86cde | 405 | // } |
cholletisaik777 | 0:bcbd76c86cde | 406 | // case 16: |
cholletisaik777 | 0:bcbd76c86cde | 407 | // { |
cholletisaik777 | 0:bcbd76c86cde | 408 | // printf("WR_L_FLASH\r\r\n"); |
cholletisaik777 | 0:bcbd76c86cde | 409 | // telemetry_type2[0]=0XB0; |
cholletisaik777 | 0:bcbd76c86cde | 410 | // telemetry_type2[1]=tc_pac_seq_cnt_tm; |
cholletisaik777 | 0:bcbd76c86cde | 411 | // telemetry_type2[2]=tm_pac_seq_cnt_tm; |
cholletisaik777 | 0:bcbd76c86cde | 412 | // telemetry_type2[3]=ackcode_tm; |
cholletisaik777 | 0:bcbd76c86cde | 413 | // for(int i=4;i<11;i++) |
cholletisaik777 | 0:bcbd76c86cde | 414 | // { |
cholletisaik777 | 0:bcbd76c86cde | 415 | // telemetry_type2[i]=0X00; |
cholletisaik777 | 0:bcbd76c86cde | 416 | // } |
cholletisaik777 | 0:bcbd76c86cde | 417 | // break; |
cholletisaik777 | 0:bcbd76c86cde | 418 | // } |
cholletisaik777 | 0:bcbd76c86cde | 419 | // case 17: |
cholletisaik777 | 0:bcbd76c86cde | 420 | // { |
cholletisaik777 | 0:bcbd76c86cde | 421 | // printf("WR_L_RAM\r\r\n"); |
cholletisaik777 | 0:bcbd76c86cde | 422 | // telemetry_type2[0]=0XB0; |
cholletisaik777 | 0:bcbd76c86cde | 423 | // telemetry_type2[1]=tc_pac_seq_cnt_tm; |
cholletisaik777 | 0:bcbd76c86cde | 424 | // telemetry_type2[2]=tm_pac_seq_cnt_tm; |
cholletisaik777 | 0:bcbd76c86cde | 425 | // telemetry_type2[3]=ackcode_tm; |
cholletisaik777 | 0:bcbd76c86cde | 426 | // for(int i=4;i<11;i++) |
cholletisaik777 | 0:bcbd76c86cde | 427 | // { |
cholletisaik777 | 0:bcbd76c86cde | 428 | // telemetry_type2[i]=0X00; |
cholletisaik777 | 0:bcbd76c86cde | 429 | // } |
cholletisaik777 | 0:bcbd76c86cde | 430 | // break; |
cholletisaik777 | 0:bcbd76c86cde | 431 | // } |
cholletisaik777 | 0:bcbd76c86cde | 432 | // default: |
cholletisaik777 | 0:bcbd76c86cde | 433 | // { |
cholletisaik777 | 0:bcbd76c86cde | 434 | // printf("INVALID TC"); //send invalid TC TM |
cholletisaik777 | 0:bcbd76c86cde | 435 | // break; |
cholletisaik777 | 0:bcbd76c86cde | 436 | // } |
cholletisaik777 | 0:bcbd76c86cde | 437 | // } |
cholletisaik777 | 0:bcbd76c86cde | 438 | // break; |
cholletisaik777 | 0:bcbd76c86cde | 439 | // } |
cholletisaik777 | 0:bcbd76c86cde | 440 | case 9: |
cholletisaik777 | 0:bcbd76c86cde | 441 | { |
cholletisaik777 | 0:bcbd76c86cde | 442 | printf("SEND CRC OF FLASH MEMORY\r\n"); |
cholletisaik777 | 0:bcbd76c86cde | 443 | if(GETpid(tc)==2) |
cholletisaik777 | 0:bcbd76c86cde | 444 | { |
cholletisaik777 | 0:bcbd76c86cde | 445 | printf("GET_FLASH_CRC\r\n"); |
cholletisaik777 | 0:bcbd76c86cde | 446 | mid1 = ((((uint16_t)tc->TC_string[5])<<8)|(uint16_t)(tc->TC_string[6])); |
cholletisaik777 | 0:bcbd76c86cde | 447 | mid2 = ((((uint16_t)tc->TC_string[7])<<8)|(uint16_t)(tc->TC_string[8])); |
cholletisaik777 | 0:bcbd76c86cde | 448 | Nbytes = (((mid2-mid1)*32)/8)+4; |
cholletisaik777 | 0:bcbd76c86cde | 449 | uint8_t data[4*Nbytes]; |
cholletisaik777 | 0:bcbd76c86cde | 450 | uint8_t flash_counter = 0; |
cholletisaik777 | 0:bcbd76c86cde | 451 | tm_pointer = new Long_tm; |
cholletisaik777 | 0:bcbd76c86cde | 452 | tm_pointer->TM_string[0] = 0x80; |
cholletisaik777 | 0:bcbd76c86cde | 453 | tm_pointer->TM_string[1] = 0x00; //spare |
cholletisaik777 | 0:bcbd76c86cde | 454 | tm_pointer->TM_string[2] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 455 | tm_pointer->TM_string[3] = (uint8_t)(flash_counter); |
cholletisaik777 | 0:bcbd76c86cde | 456 | for(uint8_t i=0;i<mid2-mid1+1;i++) |
cholletisaik777 | 0:bcbd76c86cde | 457 | { |
cholletisaik777 | 0:bcbd76c86cde | 458 | Data = FCTN_CDMS_RD_FLASH(mid1+i); |
cholletisaik777 | 0:bcbd76c86cde | 459 | data[4*i] = (uint8_t)((Data&0xFF000000)>>24); |
cholletisaik777 | 0:bcbd76c86cde | 460 | data[4*i+1] = (uint8_t)((Data&0xFF000000)>>16); |
cholletisaik777 | 0:bcbd76c86cde | 461 | data[4*i+2] = (uint8_t)((Data&0xFF000000)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 462 | data[4*i+3] = (uint8_t)(Data&0xFF000000); |
cholletisaik777 | 0:bcbd76c86cde | 463 | } |
cholletisaik777 | 0:bcbd76c86cde | 464 | nbytes = Nbytes; |
cholletisaik777 | 0:bcbd76c86cde | 465 | while(nbytes>=32) |
cholletisaik777 | 0:bcbd76c86cde | 466 | { |
cholletisaik777 | 0:bcbd76c86cde | 467 | crc16 = CRC::crc16_gen((data+32*flash_counter),32); |
cholletisaik777 | 0:bcbd76c86cde | 468 | tm_pointer->TM_string[11+2*flash_counter] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 469 | tm_pointer->TM_string[12+2*flash_counter] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 470 | nbytes-=32; |
cholletisaik777 | 0:bcbd76c86cde | 471 | flash_counter++; |
cholletisaik777 | 0:bcbd76c86cde | 472 | } |
cholletisaik777 | 0:bcbd76c86cde | 473 | if(nbytes>0) |
cholletisaik777 | 0:bcbd76c86cde | 474 | { |
cholletisaik777 | 0:bcbd76c86cde | 475 | crc16 = CRC::crc16_gen((data+32*flash_counter),nbytes); |
cholletisaik777 | 0:bcbd76c86cde | 476 | tm_pointer->TM_string[11+2*flash_counter] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 477 | tm_pointer->TM_string[12+2*flash_counter] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 478 | } |
cholletisaik777 | 0:bcbd76c86cde | 479 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 480 | } |
cholletisaik777 | 0:bcbd76c86cde | 481 | else |
cholletisaik777 | 0:bcbd76c86cde | 482 | { |
cholletisaik777 | 0:bcbd76c86cde | 483 | printf("INVALID TC"); //Send Invalid TC Telemetry |
cholletisaik777 | 0:bcbd76c86cde | 484 | tm_pointer = new Short_tm; |
cholletisaik777 | 0:bcbd76c86cde | 485 | tm_pointer->TM_string[0] = 0xB0; |
cholletisaik777 | 0:bcbd76c86cde | 486 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 487 | tm_pointer->TM_string[2] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 488 | tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided |
cholletisaik777 | 0:bcbd76c86cde | 489 | tm_pointer->TM_string[4] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 490 | for(uint8_t i=0;i<6;i++) |
cholletisaik777 | 0:bcbd76c86cde | 491 | { |
cholletisaik777 | 0:bcbd76c86cde | 492 | tm_pointer->TM_string[i+5] = 0; |
cholletisaik777 | 0:bcbd76c86cde | 493 | } |
cholletisaik777 | 0:bcbd76c86cde | 494 | crc16 = CRC::crc16_gen(tm->TM_string,11); |
cholletisaik777 | 0:bcbd76c86cde | 495 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 496 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 497 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 498 | } |
cholletisaik777 | 0:bcbd76c86cde | 499 | break; |
cholletisaik777 | 0:bcbd76c86cde | 500 | } |
cholletisaik777 | 0:bcbd76c86cde | 501 | case 8: |
cholletisaik777 | 0:bcbd76c86cde | 502 | { |
cholletisaik777 | 0:bcbd76c86cde | 503 | printf("service:FUNCTION MANAGEMENT SERVICE\r\n"); |
cholletisaik777 | 0:bcbd76c86cde | 504 | if(GETservice_subtype(tc)==1) |
cholletisaik777 | 0:bcbd76c86cde | 505 | { |
cholletisaik777 | 0:bcbd76c86cde | 506 | if((GETpid(tc)&0xF0)==0x00) |
cholletisaik777 | 0:bcbd76c86cde | 507 | { |
cholletisaik777 | 0:bcbd76c86cde | 508 | printf("RUN_PRCS\r\n"); |
cholletisaik777 | 0:bcbd76c86cde | 509 | switch(GETpid(tc)) |
cholletisaik777 | 0:bcbd76c86cde | 510 | { |
cholletisaik777 | 0:bcbd76c86cde | 511 | case 1: |
cholletisaik777 | 0:bcbd76c86cde | 512 | { |
cholletisaik777 | 0:bcbd76c86cde | 513 | printf("P_PL_INIT\r\n"); //call P_PL_INIT using CDMS_RUN_PRCS |
cholletisaik777 | 0:bcbd76c86cde | 514 | tm_pointer = new Short_tm; |
cholletisaik777 | 0:bcbd76c86cde | 515 | tm_pointer->TM_string[0] = 0xB0; |
cholletisaik777 | 0:bcbd76c86cde | 516 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 517 | tm_pointer->TM_string[2] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 518 | tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided |
cholletisaik777 | 0:bcbd76c86cde | 519 | tm_pointer->TM_string[4] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 520 | for(uint8_t i=0;i<6;i++) |
cholletisaik777 | 0:bcbd76c86cde | 521 | { |
cholletisaik777 | 0:bcbd76c86cde | 522 | tm_pointer->TM_string[i+5] = 0; |
cholletisaik777 | 0:bcbd76c86cde | 523 | } |
cholletisaik777 | 0:bcbd76c86cde | 524 | crc16 = CRC::crc16_gen(tm->TM_string,11); |
cholletisaik777 | 0:bcbd76c86cde | 525 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 526 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 527 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 528 | break; |
cholletisaik777 | 0:bcbd76c86cde | 529 | } |
cholletisaik777 | 0:bcbd76c86cde | 530 | case 2: |
cholletisaik777 | 0:bcbd76c86cde | 531 | { |
cholletisaik777 | 0:bcbd76c86cde | 532 | printf("P_PL_MNGR\r\n"); //call P_PL_MNGR using CDMS_RUN_PRCS |
cholletisaik777 | 0:bcbd76c86cde | 533 | tm_pointer = new Short_tm; |
cholletisaik777 | 0:bcbd76c86cde | 534 | tm_pointer->TM_string[0] = 0xB0; |
cholletisaik777 | 0:bcbd76c86cde | 535 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 536 | tm_pointer->TM_string[2] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 537 | tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided |
cholletisaik777 | 0:bcbd76c86cde | 538 | tm_pointer->TM_string[4] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 539 | for(uint8_t i=0;i<6;i++) |
cholletisaik777 | 0:bcbd76c86cde | 540 | { |
cholletisaik777 | 0:bcbd76c86cde | 541 | tm_pointer->TM_string[i+5] = 0; |
cholletisaik777 | 0:bcbd76c86cde | 542 | } |
cholletisaik777 | 0:bcbd76c86cde | 543 | crc16 = CRC::crc16_gen(tm->TM_string,11); |
cholletisaik777 | 0:bcbd76c86cde | 544 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 545 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 546 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 547 | break; |
cholletisaik777 | 0:bcbd76c86cde | 548 | } |
cholletisaik777 | 0:bcbd76c86cde | 549 | case 3: |
cholletisaik777 | 0:bcbd76c86cde | 550 | { |
cholletisaik777 | 0:bcbd76c86cde | 551 | printf("P_COM_INIT\r\n"); //call P_COM_INIT using CDMS_RUN_PRCS |
cholletisaik777 | 0:bcbd76c86cde | 552 | tm_pointer = new Short_tm; |
cholletisaik777 | 0:bcbd76c86cde | 553 | tm_pointer->TM_string[0] = 0xB0; |
cholletisaik777 | 0:bcbd76c86cde | 554 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 555 | tm_pointer->TM_string[2] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 556 | tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided |
cholletisaik777 | 0:bcbd76c86cde | 557 | tm_pointer->TM_string[4] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 558 | for(uint8_t i=0;i<6;i++) |
cholletisaik777 | 0:bcbd76c86cde | 559 | { |
cholletisaik777 | 0:bcbd76c86cde | 560 | tm_pointer->TM_string[i+5] = 0; |
cholletisaik777 | 0:bcbd76c86cde | 561 | } |
cholletisaik777 | 0:bcbd76c86cde | 562 | crc16 = CRC::crc16_gen(tm->TM_string,11); |
cholletisaik777 | 0:bcbd76c86cde | 563 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 564 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 565 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 566 | break; |
cholletisaik777 | 0:bcbd76c86cde | 567 | } |
cholletisaik777 | 0:bcbd76c86cde | 568 | case 4: |
cholletisaik777 | 0:bcbd76c86cde | 569 | { |
cholletisaik777 | 0:bcbd76c86cde | 570 | printf("P_CDMS_HK_MNGR\r\n"); //call P_CDMS_HK_MNGR using CDMS_RUN_PRCS |
cholletisaik777 | 0:bcbd76c86cde | 571 | tm_pointer = new Short_tm; |
cholletisaik777 | 0:bcbd76c86cde | 572 | tm_pointer->TM_string[0] = 0xB0; |
cholletisaik777 | 0:bcbd76c86cde | 573 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 574 | tm_pointer->TM_string[2] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 575 | tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided |
cholletisaik777 | 0:bcbd76c86cde | 576 | tm_pointer->TM_string[4] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 577 | for(uint8_t i=0;i<6;i++) |
cholletisaik777 | 0:bcbd76c86cde | 578 | { |
cholletisaik777 | 0:bcbd76c86cde | 579 | tm_pointer->TM_string[i+5] = 0; |
cholletisaik777 | 0:bcbd76c86cde | 580 | } |
cholletisaik777 | 0:bcbd76c86cde | 581 | crc16 = CRC::crc16_gen(tm->TM_string,11); |
cholletisaik777 | 0:bcbd76c86cde | 582 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 583 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 584 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 585 | break; |
cholletisaik777 | 0:bcbd76c86cde | 586 | } |
cholletisaik777 | 0:bcbd76c86cde | 587 | default: |
cholletisaik777 | 0:bcbd76c86cde | 588 | { |
cholletisaik777 | 0:bcbd76c86cde | 589 | printf("INVALID TC\r\n"); |
cholletisaik777 | 0:bcbd76c86cde | 590 | tm_pointer = new Short_tm; |
cholletisaik777 | 0:bcbd76c86cde | 591 | tm_pointer->TM_string[0] = 0xB0; |
cholletisaik777 | 0:bcbd76c86cde | 592 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 593 | tm_pointer->TM_string[2] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 594 | tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided |
cholletisaik777 | 0:bcbd76c86cde | 595 | tm_pointer->TM_string[4] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 596 | for(uint8_t i=0;i<6;i++) |
cholletisaik777 | 0:bcbd76c86cde | 597 | { |
cholletisaik777 | 0:bcbd76c86cde | 598 | tm_pointer->TM_string[i+5] = 0; |
cholletisaik777 | 0:bcbd76c86cde | 599 | } |
cholletisaik777 | 0:bcbd76c86cde | 600 | crc16 = CRC::crc16_gen(tm->TM_string,11); |
cholletisaik777 | 0:bcbd76c86cde | 601 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 602 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 603 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 604 | break; |
cholletisaik777 | 0:bcbd76c86cde | 605 | } |
cholletisaik777 | 0:bcbd76c86cde | 606 | } |
cholletisaik777 | 0:bcbd76c86cde | 607 | } |
cholletisaik777 | 0:bcbd76c86cde | 608 | else if((GETpid(tc)&0xF0)==0x10) |
cholletisaik777 | 0:bcbd76c86cde | 609 | { |
cholletisaik777 | 0:bcbd76c86cde | 610 | printf("PWR_SWCH_ON\r\n"); // call PWR_SWCH_ON function |
cholletisaik777 | 0:bcbd76c86cde | 611 | tm_pointer = new Short_tm; |
cholletisaik777 | 0:bcbd76c86cde | 612 | tm_pointer->TM_string[0] = 0xB0; |
cholletisaik777 | 0:bcbd76c86cde | 613 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 614 | tm_pointer->TM_string[2] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 615 | tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided |
cholletisaik777 | 0:bcbd76c86cde | 616 | tm_pointer->TM_string[4] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 617 | for(uint8_t i=0;i<6;i++) |
cholletisaik777 | 0:bcbd76c86cde | 618 | { |
cholletisaik777 | 0:bcbd76c86cde | 619 | tm_pointer->TM_string[i+5] = 0; |
cholletisaik777 | 0:bcbd76c86cde | 620 | } |
cholletisaik777 | 0:bcbd76c86cde | 621 | crc16 = CRC::crc16_gen(tm->TM_string,11); |
cholletisaik777 | 0:bcbd76c86cde | 622 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 623 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 624 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 625 | break; |
cholletisaik777 | 0:bcbd76c86cde | 626 | } |
cholletisaik777 | 0:bcbd76c86cde | 627 | else if((GETpid(tc)&0xF0)==0x20) |
cholletisaik777 | 0:bcbd76c86cde | 628 | { |
cholletisaik777 | 0:bcbd76c86cde | 629 | printf("PWR_SWCH_OFF\r\n"); // call PWR_SWCH_OFF function |
cholletisaik777 | 0:bcbd76c86cde | 630 | tm_pointer = new Short_tm; |
cholletisaik777 | 0:bcbd76c86cde | 631 | tm_pointer->TM_string[0] = 0xB0; |
cholletisaik777 | 0:bcbd76c86cde | 632 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 633 | tm_pointer->TM_string[2] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 634 | tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided |
cholletisaik777 | 0:bcbd76c86cde | 635 | tm_pointer->TM_string[4] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 636 | for(uint8_t i=0;i<6;i++) |
cholletisaik777 | 0:bcbd76c86cde | 637 | { |
cholletisaik777 | 0:bcbd76c86cde | 638 | tm_pointer->TM_string[i+5] = 0; |
cholletisaik777 | 0:bcbd76c86cde | 639 | } |
cholletisaik777 | 0:bcbd76c86cde | 640 | crc16 = CRC::crc16_gen(tm->TM_string,11); |
cholletisaik777 | 0:bcbd76c86cde | 641 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 642 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 643 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 644 | break; |
cholletisaik777 | 0:bcbd76c86cde | 645 | } |
cholletisaik777 | 0:bcbd76c86cde | 646 | else if((GETpid(tc)&0xF0)==0x20) |
cholletisaik777 | 0:bcbd76c86cde | 647 | { |
cholletisaik777 | 0:bcbd76c86cde | 648 | printf("PWR_RST\r\n"); // call PWR_RST function |
cholletisaik777 | 0:bcbd76c86cde | 649 | tm_pointer = new Short_tm; |
cholletisaik777 | 0:bcbd76c86cde | 650 | tm_pointer->TM_string[0] = 0xB0; |
cholletisaik777 | 0:bcbd76c86cde | 651 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 652 | tm_pointer->TM_string[2] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 653 | tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided |
cholletisaik777 | 0:bcbd76c86cde | 654 | tm_pointer->TM_string[4] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 655 | for(uint8_t i=0;i<6;i++) |
cholletisaik777 | 0:bcbd76c86cde | 656 | { |
cholletisaik777 | 0:bcbd76c86cde | 657 | tm_pointer->TM_string[i+5] = 0; |
cholletisaik777 | 0:bcbd76c86cde | 658 | } |
cholletisaik777 | 0:bcbd76c86cde | 659 | crc16 = CRC::crc16_gen(tm->TM_string,11); |
cholletisaik777 | 0:bcbd76c86cde | 660 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 661 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 662 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 663 | break; |
cholletisaik777 | 0:bcbd76c86cde | 664 | } |
cholletisaik777 | 0:bcbd76c86cde | 665 | else if((GETpid(tc)&0xF0)==0xE0) |
cholletisaik777 | 0:bcbd76c86cde | 666 | { |
cholletisaik777 | 0:bcbd76c86cde | 667 | printf("RD_RTC\r\n"); //call RD_RTC |
cholletisaik777 | 0:bcbd76c86cde | 668 | tm_pointer = new Short_tm; |
cholletisaik777 | 0:bcbd76c86cde | 669 | tm_pointer->TM_string[0] = 0xD0; |
cholletisaik777 | 0:bcbd76c86cde | 670 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 671 | tm_pointer->TM_string[2] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 672 | uint64_t time = FCTN_CDMS_RD_RTC(); |
cholletisaik777 | 0:bcbd76c86cde | 673 | tm_pointer->TM_string[3] = (uint8_t)((time&0xFF00000000000000)>>56); |
cholletisaik777 | 0:bcbd76c86cde | 674 | tm_pointer->TM_string[4] = (uint8_t)((time&0x00FF000000000000)>>48); |
cholletisaik777 | 0:bcbd76c86cde | 675 | tm_pointer->TM_string[5] = (uint8_t)((time&0x0000FF0000000000)>>40); |
cholletisaik777 | 0:bcbd76c86cde | 676 | tm_pointer->TM_string[6] = (uint8_t)((time&0x000000FF00000000)>>32); |
cholletisaik777 | 0:bcbd76c86cde | 677 | tm_pointer->TM_string[7] = (uint8_t)((time&0x00000000FF000000)>>24); |
cholletisaik777 | 0:bcbd76c86cde | 678 | tm_pointer->TM_string[8] = (uint8_t)((time&0x0000000000FF0000)>>16); |
cholletisaik777 | 0:bcbd76c86cde | 679 | tm_pointer->TM_string[9] = (uint8_t)((time&0x000000000000FF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 680 | tm_pointer->TM_string[10] = (uint8_t)(time&0x00000000000000FF); |
cholletisaik777 | 0:bcbd76c86cde | 681 | crc16 = CRC::crc16_gen(tm->TM_string,11); |
cholletisaik777 | 0:bcbd76c86cde | 682 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 683 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 684 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 685 | } |
cholletisaik777 | 0:bcbd76c86cde | 686 | else if((GETpid(tc)&0xF0)==0xF0) |
cholletisaik777 | 0:bcbd76c86cde | 687 | { |
cholletisaik777 | 0:bcbd76c86cde | 688 | printf("SD_MNGR\r\n"); //call SD_MNGR function and send required information in FMS TM |
cholletisaik777 | 0:bcbd76c86cde | 689 | tm_pointer = new Short_tm; // for now sending ACK L_234 |
cholletisaik777 | 0:bcbd76c86cde | 690 | tm_pointer->TM_string[0] = 0xD0; |
cholletisaik777 | 0:bcbd76c86cde | 691 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 692 | tm_pointer->TM_string[2] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 693 | for(uint8_t i=3;i<11;i++) |
cholletisaik777 | 0:bcbd76c86cde | 694 | { |
cholletisaik777 | 0:bcbd76c86cde | 695 | tm_pointer->TM_string[i] = 0; // for now filling with zeroes instead of SD_MNGR Data |
cholletisaik777 | 0:bcbd76c86cde | 696 | } |
cholletisaik777 | 0:bcbd76c86cde | 697 | crc16 = CRC::crc16_gen(tm->TM_string,11); |
cholletisaik777 | 0:bcbd76c86cde | 698 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 699 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 700 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 701 | } |
cholletisaik777 | 0:bcbd76c86cde | 702 | else |
cholletisaik777 | 0:bcbd76c86cde | 703 | { |
cholletisaik777 | 0:bcbd76c86cde | 704 | printf("INVALID TC\r\n"); |
cholletisaik777 | 0:bcbd76c86cde | 705 | tm_pointer = new Short_tm; |
cholletisaik777 | 0:bcbd76c86cde | 706 | tm_pointer->TM_string[0] = 0xB0; |
cholletisaik777 | 0:bcbd76c86cde | 707 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 708 | tm_pointer->TM_string[2] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 709 | tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided |
cholletisaik777 | 0:bcbd76c86cde | 710 | tm_pointer->TM_string[4] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 711 | for(uint8_t i=0;i<6;i++) |
cholletisaik777 | 0:bcbd76c86cde | 712 | { |
cholletisaik777 | 0:bcbd76c86cde | 713 | tm_pointer->TM_string[i+5] = 0; |
cholletisaik777 | 0:bcbd76c86cde | 714 | } |
cholletisaik777 | 0:bcbd76c86cde | 715 | crc16 = CRC::crc16_gen(tm->TM_string,11); |
cholletisaik777 | 0:bcbd76c86cde | 716 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 717 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 718 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 719 | } |
cholletisaik777 | 0:bcbd76c86cde | 720 | } |
cholletisaik777 | 0:bcbd76c86cde | 721 | default: |
cholletisaik777 | 0:bcbd76c86cde | 722 | { |
cholletisaik777 | 0:bcbd76c86cde | 723 | printf("INVALID TC\r\n"); |
cholletisaik777 | 0:bcbd76c86cde | 724 | tm_pointer = new Short_tm; |
cholletisaik777 | 0:bcbd76c86cde | 725 | tm_pointer->TM_string[0] = 0xB0; |
cholletisaik777 | 0:bcbd76c86cde | 726 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 727 | tm_pointer->TM_string[2] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 728 | tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided |
cholletisaik777 | 0:bcbd76c86cde | 729 | tm_pointer->TM_string[4] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 730 | for(uint8_t i=0;i<6;i++) |
cholletisaik777 | 0:bcbd76c86cde | 731 | { |
cholletisaik777 | 0:bcbd76c86cde | 732 | tm_pointer->TM_string[i+5] = 0; |
cholletisaik777 | 0:bcbd76c86cde | 733 | } |
cholletisaik777 | 0:bcbd76c86cde | 734 | crc16 = CRC::crc16_gen(tm->TM_string,11); |
cholletisaik777 | 0:bcbd76c86cde | 735 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 736 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 737 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 738 | break; |
cholletisaik777 | 0:bcbd76c86cde | 739 | } |
cholletisaik777 | 0:bcbd76c86cde | 740 | break; |
cholletisaik777 | 0:bcbd76c86cde | 741 | } |
cholletisaik777 | 0:bcbd76c86cde | 742 | case 7: |
cholletisaik777 | 0:bcbd76c86cde | 743 | { |
cholletisaik777 | 0:bcbd76c86cde | 744 | printf("service:PAYLOAD MANAGEMENT SERVICE\r\r\n"); //TM is ACKL234 |
cholletisaik777 | 0:bcbd76c86cde | 745 | switch(GETservice_subtype(tc)) |
cholletisaik777 | 0:bcbd76c86cde | 746 | { |
cholletisaik777 | 0:bcbd76c86cde | 747 | case 1: |
cholletisaik777 | 0:bcbd76c86cde | 748 | { |
cholletisaik777 | 0:bcbd76c86cde | 749 | printf("INSERT PL SCHEDULE\r\n"); //should be called PL_MAIN |
cholletisaik777 | 0:bcbd76c86cde | 750 | tm_pointer = new Short_tm; // for now sending dummy ACK L_234 |
cholletisaik777 | 0:bcbd76c86cde | 751 | tm_pointer->TM_string[0] = 0xB0; |
cholletisaik777 | 0:bcbd76c86cde | 752 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 753 | tm_pointer->TM_string[2] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 754 | tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided |
cholletisaik777 | 0:bcbd76c86cde | 755 | tm_pointer->TM_string[4] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 756 | for(uint8_t i=0;i<6;i++) |
cholletisaik777 | 0:bcbd76c86cde | 757 | { |
cholletisaik777 | 0:bcbd76c86cde | 758 | tm_pointer->TM_string[i+5] = 0; |
cholletisaik777 | 0:bcbd76c86cde | 759 | } |
cholletisaik777 | 0:bcbd76c86cde | 760 | crc16 = CRC::crc16_gen(tm->TM_string,11); |
cholletisaik777 | 0:bcbd76c86cde | 761 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 762 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 763 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 764 | break; |
cholletisaik777 | 0:bcbd76c86cde | 765 | } |
cholletisaik777 | 0:bcbd76c86cde | 766 | case 2: |
cholletisaik777 | 0:bcbd76c86cde | 767 | { |
cholletisaik777 | 0:bcbd76c86cde | 768 | printf("DELETE PL SCHEDULE\r\n"); //Should be called PL_MAIN |
cholletisaik777 | 0:bcbd76c86cde | 769 | tm_pointer = new Short_tm; // for now sending dummy ACK L_234 |
cholletisaik777 | 0:bcbd76c86cde | 770 | tm_pointer->TM_string[0] = 0xB0; |
cholletisaik777 | 0:bcbd76c86cde | 771 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 772 | tm_pointer->TM_string[2] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 773 | tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided |
cholletisaik777 | 0:bcbd76c86cde | 774 | tm_pointer->TM_string[4] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 775 | for(uint8_t i=0;i<6;i++) |
cholletisaik777 | 0:bcbd76c86cde | 776 | { |
cholletisaik777 | 0:bcbd76c86cde | 777 | tm_pointer->TM_string[i+5] = 0; |
cholletisaik777 | 0:bcbd76c86cde | 778 | } |
cholletisaik777 | 0:bcbd76c86cde | 779 | crc16 = CRC::crc16_gen(tm->TM_string,11); |
cholletisaik777 | 0:bcbd76c86cde | 780 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 781 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 782 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 783 | break; |
cholletisaik777 | 0:bcbd76c86cde | 784 | } |
cholletisaik777 | 0:bcbd76c86cde | 785 | case 3: |
cholletisaik777 | 0:bcbd76c86cde | 786 | { |
cholletisaik777 | 0:bcbd76c86cde | 787 | printf("REPORT PL SCHEDULE\r\n"); //Data is taken by calling PL_MAIN |
cholletisaik777 | 0:bcbd76c86cde | 788 | tm_pointer = new Long_tm; //for now sending dummy PMS |
cholletisaik777 | 0:bcbd76c86cde | 789 | tm_pointer->TM_string[0] = 0x48; |
cholletisaik777 | 0:bcbd76c86cde | 790 | tm_pointer->TM_string[1] = 0x00; //spare 8 bits |
cholletisaik777 | 0:bcbd76c86cde | 791 | tm_pointer->TM_string[2] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 792 | tm_pointer->TM_string[3] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 793 | for(uint8_t i=4;i<132;i++) |
cholletisaik777 | 0:bcbd76c86cde | 794 | { |
cholletisaik777 | 0:bcbd76c86cde | 795 | tm_pointer->TM_string[i] = 0; // for now filling with zeros instead of PL_SCHEDULE |
cholletisaik777 | 0:bcbd76c86cde | 796 | } |
cholletisaik777 | 0:bcbd76c86cde | 797 | crc16 = CRC::crc16_gen(tm->TM_string,11); |
cholletisaik777 | 0:bcbd76c86cde | 798 | tm_pointer->TM_string[132] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 799 | tm_pointer->TM_string[133] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 800 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 801 | break; |
cholletisaik777 | 0:bcbd76c86cde | 802 | } |
cholletisaik777 | 0:bcbd76c86cde | 803 | default: |
cholletisaik777 | 0:bcbd76c86cde | 804 | { |
cholletisaik777 | 0:bcbd76c86cde | 805 | printf("INVALID TC"); //send invalid TC TM |
cholletisaik777 | 0:bcbd76c86cde | 806 | tm_pointer = new Short_tm; |
cholletisaik777 | 0:bcbd76c86cde | 807 | tm_pointer->TM_string[0] = 0xB0; |
cholletisaik777 | 0:bcbd76c86cde | 808 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 809 | tm_pointer->TM_string[2] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 810 | tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided |
cholletisaik777 | 0:bcbd76c86cde | 811 | tm_pointer->TM_string[4] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 812 | for(uint8_t i=0;i<6;i++) |
cholletisaik777 | 0:bcbd76c86cde | 813 | { |
cholletisaik777 | 0:bcbd76c86cde | 814 | tm_pointer->TM_string[i+5] = 0; |
cholletisaik777 | 0:bcbd76c86cde | 815 | } |
cholletisaik777 | 0:bcbd76c86cde | 816 | crc16 = CRC::crc16_gen(tm->TM_string,11); |
cholletisaik777 | 0:bcbd76c86cde | 817 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 818 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 819 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 820 | break; |
cholletisaik777 | 0:bcbd76c86cde | 821 | } |
cholletisaik777 | 0:bcbd76c86cde | 822 | } |
cholletisaik777 | 0:bcbd76c86cde | 823 | break; |
cholletisaik777 | 0:bcbd76c86cde | 824 | } |
cholletisaik777 | 0:bcbd76c86cde | 825 | } |
cholletisaik777 | 0:bcbd76c86cde | 826 | break; |
cholletisaik777 | 0:bcbd76c86cde | 827 | } |
cholletisaik777 | 0:bcbd76c86cde | 828 | default: |
cholletisaik777 | 0:bcbd76c86cde | 829 | { |
cholletisaik777 | 0:bcbd76c86cde | 830 | printf("INVALID TC"); //send invalid TC TM |
cholletisaik777 | 0:bcbd76c86cde | 831 | tm_pointer = new Short_tm; |
cholletisaik777 | 0:bcbd76c86cde | 832 | tm_pointer->TM_string[0] = 0xB0; |
cholletisaik777 | 0:bcbd76c86cde | 833 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 834 | tm_pointer->TM_string[2] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 835 | tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided |
cholletisaik777 | 0:bcbd76c86cde | 836 | tm_pointer->TM_string[4] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 837 | for(uint8_t i=0;i<6;i++) |
cholletisaik777 | 0:bcbd76c86cde | 838 | { |
cholletisaik777 | 0:bcbd76c86cde | 839 | tm_pointer->TM_string[i+5] = 0; |
cholletisaik777 | 0:bcbd76c86cde | 840 | } |
cholletisaik777 | 0:bcbd76c86cde | 841 | crc16 = CRC::crc16_gen(tm->TM_string,11); |
cholletisaik777 | 0:bcbd76c86cde | 842 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 843 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 844 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 845 | break; |
cholletisaik777 | 0:bcbd76c86cde | 846 | } |
cholletisaik777 | 0:bcbd76c86cde | 847 | } |
cholletisaik777 | 0:bcbd76c86cde | 848 | } |
cholletisaik777 | 0:bcbd76c86cde | 849 | case 3: |
cholletisaik777 | 0:bcbd76c86cde | 850 | { |
cholletisaik777 | 0:bcbd76c86cde | 851 | printf("Telecommand is for PL\r\n"); |
cholletisaik777 | 0:bcbd76c86cde | 852 | // printf("Informing PL about TC using I2C\r\n"); //interrupt to be sent to the bae |
cholletisaik777 | 0:bcbd76c86cde | 853 | // FCTN_I2C_WRITE((char*)tc->TC_string); |
cholletisaik777 | 0:bcbd76c86cde | 854 | // printf("sent the Telecommand to BAE\r\n"); //packet along with crc will be sent when bae is ready |
cholletisaik777 | 0:bcbd76c86cde | 855 | // wait(1); //wait time is to be optimised |
cholletisaik777 | 0:bcbd76c86cde | 856 | // if(tm_status_4m_slv == 1) |
cholletisaik777 | 0:bcbd76c86cde | 857 | // { |
cholletisaik777 | 0:bcbd76c86cde | 858 | // FCTN_I2C_READ((char*)tm->TM_string); |
cholletisaik777 | 0:bcbd76c86cde | 859 | // received = 1; |
cholletisaik777 | 0:bcbd76c86cde | 860 | // } |
cholletisaik777 | 0:bcbd76c86cde | 861 | // if(received == 1 ) |
cholletisaik777 | 0:bcbd76c86cde | 862 | // { |
cholletisaik777 | 0:bcbd76c86cde | 863 | // printf("Telemetry is received from BAE\r\n"); |
cholletisaik777 | 0:bcbd76c86cde | 864 | // printf("%s", tm->TM_string); |
cholletisaik777 | 0:bcbd76c86cde | 865 | // received = 0; |
cholletisaik777 | 0:bcbd76c86cde | 866 | // } // similar to BAE functions |
cholletisaik777 | 0:bcbd76c86cde | 867 | break; |
cholletisaik777 | 0:bcbd76c86cde | 868 | } |
cholletisaik777 | 0:bcbd76c86cde | 869 | default: //invalid TC |
cholletisaik777 | 0:bcbd76c86cde | 870 | { |
cholletisaik777 | 0:bcbd76c86cde | 871 | printf("INVALID TC\r\n"); |
cholletisaik777 | 0:bcbd76c86cde | 872 | tm_pointer = new Short_tm; |
cholletisaik777 | 0:bcbd76c86cde | 873 | tm_pointer->TM_string[0] = 0xB0; |
cholletisaik777 | 0:bcbd76c86cde | 874 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc); |
cholletisaik777 | 0:bcbd76c86cde | 875 | tm_pointer->TM_string[2] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 876 | tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided |
cholletisaik777 | 0:bcbd76c86cde | 877 | tm_pointer->TM_string[4] = 0x01; |
cholletisaik777 | 0:bcbd76c86cde | 878 | for(uint8_t i=0;i<6;i++) |
cholletisaik777 | 0:bcbd76c86cde | 879 | { |
cholletisaik777 | 0:bcbd76c86cde | 880 | tm_pointer->TM_string[i+5] = 0; |
cholletisaik777 | 0:bcbd76c86cde | 881 | } |
cholletisaik777 | 0:bcbd76c86cde | 882 | crc16 = CRC::crc16_gen(tm->TM_string,11); |
cholletisaik777 | 0:bcbd76c86cde | 883 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
cholletisaik777 | 0:bcbd76c86cde | 884 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
cholletisaik777 | 0:bcbd76c86cde | 885 | return tm; |
cholletisaik777 | 0:bcbd76c86cde | 886 | break; |
cholletisaik777 | 0:bcbd76c86cde | 887 | } |
cholletisaik777 | 0:bcbd76c86cde | 888 | } |
cholletisaik777 | 0:bcbd76c86cde | 889 | } |