things are working

Dependencies:   FreescaleIAP mbed-rtos mbed

Fork of CDMS_DEC_2016_jan by Team Fox

Committer:
cholletisaik777
Date:
Sat Jan 23 11:33:47 2016 +0000
Revision:
4:560716ec8414
Parent:
1:ad3b8a8032e2
things are working

Who changed what in which revision?

UserRevisionLine numberNew 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
pradeepvk2208 1:ad3b8a8032e2 10
cholletisaik777 0:bcbd76c86cde 11 DigitalIn tm_status_4m_slv(PIN39); //I2C interrupt to CDMS from BAE
cholletisaik777 0:bcbd76c86cde 12 //DigitalIn tm_status_4m_pl(PIN61); //I2C interrupt to CDMS from PL
cholletisaik777 0:bcbd76c86cde 13
cholletisaik777 0:bcbd76c86cde 14 uint8_t received = 0;
cholletisaik777 0:bcbd76c86cde 15 uint16_t mid1;
cholletisaik777 0:bcbd76c86cde 16 uint16_t mid2;
cholletisaik777 0:bcbd76c86cde 17 uint16_t Nbytes;
pradeepvk2208 1:ad3b8a8032e2 18 uint32_t Data[2];
cholletisaik777 0:bcbd76c86cde 19 uint16_t nbytes;
cholletisaik777 0:bcbd76c86cde 20 uint8_t flash_counter = 0;
cholletisaik777 0:bcbd76c86cde 21 uint16_t crc16;
cholletisaik777 0:bcbd76c86cde 22 uint16_t mid;
cholletisaik777 0:bcbd76c86cde 23 uint32_t block;
cholletisaik777 0:bcbd76c86cde 24
cholletisaik777 0:bcbd76c86cde 25 Base_tm *FCTN_CDMS_RLY_TMTC(Base_tc *tc)
cholletisaik777 0:bcbd76c86cde 26 {
cholletisaik777 0:bcbd76c86cde 27 printf("\rTC execution in progress\r\n");
cholletisaik777 0:bcbd76c86cde 28 Base_tm *tm = new Long_tm;
cholletisaik777 0:bcbd76c86cde 29 Base_tm *tm_pointer = tm;
cholletisaik777 0:bcbd76c86cde 30 received = 0;
cholletisaik777 0:bcbd76c86cde 31 switch(GETapid(tc))
cholletisaik777 0:bcbd76c86cde 32 {
cholletisaik777 0:bcbd76c86cde 33 case 1: //apid=01 implies it corresponds to bae
cholletisaik777 0:bcbd76c86cde 34 {
cholletisaik777 0:bcbd76c86cde 35 printf("Telecommand is for BAE\r\n");
cholletisaik777 0:bcbd76c86cde 36 printf("Sending TC to BAE...\r\n"); //interrupt to be sent to the bae
cholletisaik777 0:bcbd76c86cde 37 FCTN_I2C_WRITE((char*)tc->TC_string);
cholletisaik777 0:bcbd76c86cde 38 while(1)
cholletisaik777 0:bcbd76c86cde 39 {
cholletisaik777 4:560716ec8414 40 wait(1.5); //TimeOut instead of wait
cholletisaik777 0:bcbd76c86cde 41 if(tm_status_4m_slv == 1)
cholletisaik777 0:bcbd76c86cde 42 {
cholletisaik777 0:bcbd76c86cde 43 printf("receiving...\r\n");
cholletisaik777 4:560716ec8414 44 FCTN_I2C_READ((char*)tm_pointer->TM_string,134);
pradeepvk2208 1:ad3b8a8032e2 45 //printf("%s", tm_pointer->TM_string);
cholletisaik777 0:bcbd76c86cde 46 received+=1;
cholletisaik777 0:bcbd76c86cde 47 tm_pointer = tm_pointer->next_TM;
cholletisaik777 0:bcbd76c86cde 48 break; //only for testing purpose
cholletisaik777 0:bcbd76c86cde 49 }
cholletisaik777 0:bcbd76c86cde 50 else
cholletisaik777 0:bcbd76c86cde 51 {
cholletisaik777 0:bcbd76c86cde 52 break;
cholletisaik777 0:bcbd76c86cde 53 }
cholletisaik777 0:bcbd76c86cde 54 }
cholletisaik777 0:bcbd76c86cde 55 if(received >= 1 )
cholletisaik777 0:bcbd76c86cde 56 {
cholletisaik777 0:bcbd76c86cde 57 printf("Telemetry is received from BAE\r\n");
cholletisaik777 0:bcbd76c86cde 58 Base_tm *tm_print = tm;
cholletisaik777 0:bcbd76c86cde 59 for(uint8_t i=0;i<received;i++)
cholletisaik777 0:bcbd76c86cde 60 {
cholletisaik777 0:bcbd76c86cde 61 printf("%s", tm_print->TM_string);
cholletisaik777 0:bcbd76c86cde 62 tm_print = tm_print->next_TM; //for check
cholletisaik777 0:bcbd76c86cde 63 }
cholletisaik777 0:bcbd76c86cde 64 received = 0;
cholletisaik777 0:bcbd76c86cde 65 return tm;
cholletisaik777 0:bcbd76c86cde 66 }
cholletisaik777 0:bcbd76c86cde 67 else
cholletisaik777 0:bcbd76c86cde 68 {
cholletisaik777 0:bcbd76c86cde 69 printf("Telemetry is not received from BAE\r\n");
cholletisaik777 0:bcbd76c86cde 70 tm_pointer = new Short_tm;
cholletisaik777 0:bcbd76c86cde 71 tm_pointer->TM_string[0] = 0xB0;
cholletisaik777 0:bcbd76c86cde 72 tm_pointer->TM_string[1] = GETpacket_seq_count(tc);
cholletisaik777 0:bcbd76c86cde 73 tm_pointer->TM_string[2] = 0x01;
cholletisaik777 0:bcbd76c86cde 74 tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided
cholletisaik777 0:bcbd76c86cde 75 tm_pointer->TM_string[4] = 0x01;
cholletisaik777 0:bcbd76c86cde 76 for(uint8_t i=0;i<6;i++)
cholletisaik777 0:bcbd76c86cde 77 {
cholletisaik777 0:bcbd76c86cde 78 tm_pointer->TM_string[i+5] = 0;
cholletisaik777 0:bcbd76c86cde 79 }
cholletisaik777 0:bcbd76c86cde 80 crc16 = CRC::crc16_gen(tm->TM_string,11);
cholletisaik777 0:bcbd76c86cde 81 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
cholletisaik777 0:bcbd76c86cde 82 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
cholletisaik777 0:bcbd76c86cde 83 return tm;
cholletisaik777 0:bcbd76c86cde 84 }
cholletisaik777 0:bcbd76c86cde 85 break;
cholletisaik777 0:bcbd76c86cde 86 }
cholletisaik777 0:bcbd76c86cde 87 case 2:
cholletisaik777 0:bcbd76c86cde 88 {
cholletisaik777 0:bcbd76c86cde 89 printf("Telecommand is for CDMS\r\n"); //apid = 10 corresponds to cdms
cholletisaik777 0:bcbd76c86cde 90 switch(GETservice_type(tc))
cholletisaik777 0:bcbd76c86cde 91 {
pradeepvk2208 1:ad3b8a8032e2 92 case 0x60:
cholletisaik777 0:bcbd76c86cde 93 {
pradeepvk2208 1:ad3b8a8032e2 94 printf("service:MMS\r\n");
pradeepvk2208 1:ad3b8a8032e2 95 switch(GETservice_subtype(tc))
cholletisaik777 0:bcbd76c86cde 96 {
pradeepvk2208 1:ad3b8a8032e2 97 case 0x1:
pradeepvk2208 1:ad3b8a8032e2 98 {
pradeepvk2208 1:ad3b8a8032e2 99 printf("sub_service:Read from RAM_Memory\r\n");
pradeepvk2208 1:ad3b8a8032e2 100 mid=(uint16_t)(tc->TC_string[3]<<4)+(uint16_t)(tc->TC_string[4]);
pradeepvk2208 1:ad3b8a8032e2 101
pradeepvk2208 1:ad3b8a8032e2 102
pradeepvk2208 1:ad3b8a8032e2 103
pradeepvk2208 1:ad3b8a8032e2 104 Data[0] = FCTN_CDMS_RD_FLASH(0);
pradeepvk2208 1:ad3b8a8032e2 105 Data[1] = FCTN_CDMS_RD_FLASH(1);
cholletisaik777 0:bcbd76c86cde 106 tm_pointer = new Long_tm;
cholletisaik777 0:bcbd76c86cde 107 tm_pointer->TM_string[0] = 0x30;
cholletisaik777 0:bcbd76c86cde 108 tm_pointer->TM_string[1] = GETpacket_seq_count(tc);
cholletisaik777 0:bcbd76c86cde 109 tm_pointer->TM_string[2] = (uint8_t)(flash_counter);
pradeepvk2208 1:ad3b8a8032e2 110 for(uint8_t i=0;i<4;i++)
cholletisaik777 0:bcbd76c86cde 111 {
pradeepvk2208 1:ad3b8a8032e2 112 tm_pointer->TM_string[3+i] = (uint8_t)((Data[0]>>(8*i))&0x00FF);
pradeepvk2208 1:ad3b8a8032e2 113 }
pradeepvk2208 1:ad3b8a8032e2 114 for(uint8_t i=4;i<8;i++)
pradeepvk2208 1:ad3b8a8032e2 115 {
pradeepvk2208 1:ad3b8a8032e2 116 tm_pointer->TM_string[3+i] = (uint8_t)((Data[1]>>(8*i))&0x00FF);
cholletisaik777 0:bcbd76c86cde 117 }
cholletisaik777 0:bcbd76c86cde 118 crc16 = CRC::crc16_gen(tm->TM_string,9);
pradeepvk2208 1:ad3b8a8032e2 119 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
pradeepvk2208 1:ad3b8a8032e2 120 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
pradeepvk2208 1:ad3b8a8032e2 121 return tm;
pradeepvk2208 1:ad3b8a8032e2 122 }
pradeepvk2208 1:ad3b8a8032e2 123
pradeepvk2208 1:ad3b8a8032e2 124 case 0x2:
pradeepvk2208 1:ad3b8a8032e2 125 {
pradeepvk2208 1:ad3b8a8032e2 126 printf("sub_service:Read from Flash_Memory\r\n");
pradeepvk2208 1:ad3b8a8032e2 127 mid=(uint16_t)(tc->TC_string[3]<<4)+(uint16_t)(tc->TC_string[4]);
pradeepvk2208 1:ad3b8a8032e2 128
pradeepvk2208 1:ad3b8a8032e2 129
pradeepvk2208 1:ad3b8a8032e2 130
pradeepvk2208 1:ad3b8a8032e2 131
pradeepvk2208 1:ad3b8a8032e2 132 Data[0] = FCTN_CDMS_RD_FLASH(0);
pradeepvk2208 1:ad3b8a8032e2 133 Data[1] = FCTN_CDMS_RD_FLASH(1);
pradeepvk2208 1:ad3b8a8032e2 134
pradeepvk2208 1:ad3b8a8032e2 135
pradeepvk2208 1:ad3b8a8032e2 136
pradeepvk2208 1:ad3b8a8032e2 137 tm_pointer = new Long_tm;
cholletisaik777 0:bcbd76c86cde 138 tm_pointer->TM_string[0] = 0x30;
cholletisaik777 0:bcbd76c86cde 139 tm_pointer->TM_string[1] = GETpacket_seq_count(tc);
pradeepvk2208 1:ad3b8a8032e2 140 tm_pointer->TM_string[2] = (uint8_t)(flash_counter);
pradeepvk2208 1:ad3b8a8032e2 141 for(uint8_t i=0;i<4;i++)
cholletisaik777 0:bcbd76c86cde 142 {
pradeepvk2208 1:ad3b8a8032e2 143 tm_pointer->TM_string[3+i] = (uint8_t)((Data[0]>>(8*i))&0x00FF);
cholletisaik777 0:bcbd76c86cde 144 }
pradeepvk2208 1:ad3b8a8032e2 145 for(uint8_t i=4;i<8;i++)
cholletisaik777 0:bcbd76c86cde 146 {
pradeepvk2208 1:ad3b8a8032e2 147 tm_pointer->TM_string[3+i] = (uint8_t)((Data[1]>>(8*i))&0x00FF);
cholletisaik777 0:bcbd76c86cde 148 }
pradeepvk2208 1:ad3b8a8032e2 149 crc16 = CRC::crc16_gen(tm->TM_string,9);
pradeepvk2208 1:ad3b8a8032e2 150 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
pradeepvk2208 1:ad3b8a8032e2 151 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
cholletisaik777 0:bcbd76c86cde 152 return tm;
pradeepvk2208 1:ad3b8a8032e2 153
pradeepvk2208 1:ad3b8a8032e2 154 }
pradeepvk2208 1:ad3b8a8032e2 155
pradeepvk2208 1:ad3b8a8032e2 156 case 0x5:
cholletisaik777 0:bcbd76c86cde 157 {
pradeepvk2208 1:ad3b8a8032e2 158 printf("WRITE ON FLASH_MEMORY\r\n");
pradeepvk2208 1:ad3b8a8032e2 159
pradeepvk2208 1:ad3b8a8032e2 160 mid=(uint16_t)(tc->TC_string[3]<<4)+(uint16_t)(tc->TC_string[4]);
pradeepvk2208 1:ad3b8a8032e2 161
pradeepvk2208 1:ad3b8a8032e2 162 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])));
pradeepvk2208 1:ad3b8a8032e2 163 FCTN_CDMS_WR_FLASH(mid,block);
cholletisaik777 0:bcbd76c86cde 164 tm_pointer = new Short_tm;
pradeepvk2208 1:ad3b8a8032e2 165 tm_pointer->TM_string[0] = 0xB0;
cholletisaik777 0:bcbd76c86cde 166 tm_pointer->TM_string[1] = GETpacket_seq_count(tc);
pradeepvk2208 1:ad3b8a8032e2 167 tm_pointer->TM_string[2] = 0x01;
pradeepvk2208 1:ad3b8a8032e2 168 tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided
pradeepvk2208 1:ad3b8a8032e2 169 tm_pointer->TM_string[4] = 0x01;
pradeepvk2208 1:ad3b8a8032e2 170 for(uint8_t i=0;i<6;i++)
cholletisaik777 0:bcbd76c86cde 171 {
pradeepvk2208 1:ad3b8a8032e2 172 tm_pointer->TM_string[i+5] = 0;
cholletisaik777 0:bcbd76c86cde 173 }
cholletisaik777 0:bcbd76c86cde 174 crc16 = CRC::crc16_gen(tm->TM_string,11);
cholletisaik777 0:bcbd76c86cde 175 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
cholletisaik777 0:bcbd76c86cde 176 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
pradeepvk2208 1:ad3b8a8032e2 177 return tm;
pradeepvk2208 1:ad3b8a8032e2 178 break;
cholletisaik777 0:bcbd76c86cde 179 }
pradeepvk2208 1:ad3b8a8032e2 180
pradeepvk2208 1:ad3b8a8032e2 181
pradeepvk2208 1:ad3b8a8032e2 182 default:
cholletisaik777 0:bcbd76c86cde 183 {
cholletisaik777 0:bcbd76c86cde 184 printf("INVALID TC\r\n"); //Send Invalid TC Telemetry
cholletisaik777 0:bcbd76c86cde 185 tm_pointer = new Short_tm;
cholletisaik777 0:bcbd76c86cde 186 tm_pointer->TM_string[0] = 0xB0;
cholletisaik777 0:bcbd76c86cde 187 tm_pointer->TM_string[1] = GETpacket_seq_count(tc);
cholletisaik777 0:bcbd76c86cde 188 tm_pointer->TM_string[2] = 0x01;
cholletisaik777 0:bcbd76c86cde 189 tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided
cholletisaik777 0:bcbd76c86cde 190 tm_pointer->TM_string[4] = 0x01;
cholletisaik777 0:bcbd76c86cde 191 for(uint8_t i=0;i<6;i++)
cholletisaik777 0:bcbd76c86cde 192 {
cholletisaik777 0:bcbd76c86cde 193 tm_pointer->TM_string[i+5] = 0;
cholletisaik777 0:bcbd76c86cde 194 }
cholletisaik777 0:bcbd76c86cde 195 crc16 = CRC::crc16_gen(tm->TM_string,11);
cholletisaik777 0:bcbd76c86cde 196 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
cholletisaik777 0:bcbd76c86cde 197 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
cholletisaik777 0:bcbd76c86cde 198 return tm;
cholletisaik777 0:bcbd76c86cde 199 }
cholletisaik777 0:bcbd76c86cde 200 break;
pradeepvk2208 1:ad3b8a8032e2 201
pradeepvk2208 1:ad3b8a8032e2 202 }
pradeepvk2208 1:ad3b8a8032e2 203
pradeepvk2208 1:ad3b8a8032e2 204
pradeepvk2208 1:ad3b8a8032e2 205
pradeepvk2208 1:ad3b8a8032e2 206 case 0x8:
pradeepvk2208 1:ad3b8a8032e2 207 {
pradeepvk2208 1:ad3b8a8032e2 208 printf("service:FUNCTION MANAGEMENT SERVICE\r\n");
pradeepvk2208 1:ad3b8a8032e2 209 if(GETservice_subtype(tc)==0x1)
cholletisaik777 0:bcbd76c86cde 210 {
pradeepvk2208 1:ad3b8a8032e2 211
pradeepvk2208 1:ad3b8a8032e2 212 if(GETpid(tc)==0x01)
cholletisaik777 0:bcbd76c86cde 213 {
pradeepvk2208 1:ad3b8a8032e2 214 printf("TC_PL_INIT\r\n"); // call PWR_SWCH_ON function
pradeepvk2208 1:ad3b8a8032e2 215 tm_pointer = new Short_tm;
pradeepvk2208 1:ad3b8a8032e2 216 tm_pointer->TM_string[0] = 0xB0;
pradeepvk2208 1:ad3b8a8032e2 217 tm_pointer->TM_string[1] = GETpacket_seq_count(tc);
pradeepvk2208 1:ad3b8a8032e2 218 tm_pointer->TM_string[2] = ACKCODE;
pradeepvk2208 1:ad3b8a8032e2 219
pradeepvk2208 1:ad3b8a8032e2 220 for(uint8_t i=3;i<11;i++)
cholletisaik777 0:bcbd76c86cde 221 {
pradeepvk2208 1:ad3b8a8032e2 222 tm_pointer->TM_string[i] = 0;
cholletisaik777 0:bcbd76c86cde 223 }
cholletisaik777 0:bcbd76c86cde 224 crc16 = CRC::crc16_gen(tm->TM_string,11);
cholletisaik777 0:bcbd76c86cde 225 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
cholletisaik777 0:bcbd76c86cde 226 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
cholletisaik777 0:bcbd76c86cde 227 return tm;
cholletisaik777 0:bcbd76c86cde 228 break;
cholletisaik777 0:bcbd76c86cde 229 }
pradeepvk2208 1:ad3b8a8032e2 230
pradeepvk2208 1:ad3b8a8032e2 231 else if(GETpid(tc)==0x02)
cholletisaik777 0:bcbd76c86cde 232 {
pradeepvk2208 1:ad3b8a8032e2 233 printf("TC_PL_MAIN\r\n"); // call PWR_SWCH_ON function
cholletisaik777 0:bcbd76c86cde 234 tm_pointer = new Short_tm;
cholletisaik777 0:bcbd76c86cde 235 tm_pointer->TM_string[0] = 0xB0;
pradeepvk2208 1:ad3b8a8032e2 236 tm_pointer->TM_string[1] = GETpacket_seq_count(tc);
pradeepvk2208 1:ad3b8a8032e2 237 tm_pointer->TM_string[2] = ACKCODE;
pradeepvk2208 1:ad3b8a8032e2 238
pradeepvk2208 1:ad3b8a8032e2 239 for(uint8_t i=3;i<11;i++)
cholletisaik777 0:bcbd76c86cde 240 {
pradeepvk2208 1:ad3b8a8032e2 241 tm_pointer->TM_string[i] = 0;
pradeepvk2208 1:ad3b8a8032e2 242 }
pradeepvk2208 1:ad3b8a8032e2 243 crc16 = CRC::crc16_gen(tm->TM_string,11);
pradeepvk2208 1:ad3b8a8032e2 244 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
pradeepvk2208 1:ad3b8a8032e2 245 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
pradeepvk2208 1:ad3b8a8032e2 246 return tm;
pradeepvk2208 1:ad3b8a8032e2 247 break;
pradeepvk2208 1:ad3b8a8032e2 248 }
pradeepvk2208 1:ad3b8a8032e2 249 else if(GETpid(tc)==0x03)
pradeepvk2208 1:ad3b8a8032e2 250 {
pradeepvk2208 1:ad3b8a8032e2 251 printf("TC_COM_INIT\r\n"); // call PWR_SWCH_ON function
pradeepvk2208 1:ad3b8a8032e2 252 tm_pointer = new Short_tm;
pradeepvk2208 1:ad3b8a8032e2 253 tm_pointer->TM_string[0] = 0xB0;
pradeepvk2208 1:ad3b8a8032e2 254 tm_pointer->TM_string[1] = GETpacket_seq_count(tc);
pradeepvk2208 1:ad3b8a8032e2 255 tm_pointer->TM_string[2] = ACKCODE;
pradeepvk2208 1:ad3b8a8032e2 256
pradeepvk2208 1:ad3b8a8032e2 257 for(uint8_t i=3;i<11;i++)
pradeepvk2208 1:ad3b8a8032e2 258 {
pradeepvk2208 1:ad3b8a8032e2 259 tm_pointer->TM_string[i] = 0;
cholletisaik777 0:bcbd76c86cde 260 }
cholletisaik777 0:bcbd76c86cde 261 crc16 = CRC::crc16_gen(tm->TM_string,11);
cholletisaik777 0:bcbd76c86cde 262 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
cholletisaik777 0:bcbd76c86cde 263 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
cholletisaik777 0:bcbd76c86cde 264 return tm;
cholletisaik777 0:bcbd76c86cde 265 break;
cholletisaik777 0:bcbd76c86cde 266 }
pradeepvk2208 1:ad3b8a8032e2 267 else if(GETpid(tc)==0x04)
cholletisaik777 0:bcbd76c86cde 268 {
pradeepvk2208 1:ad3b8a8032e2 269 printf("TC_CDMS_HK_MAIN\r\n"); // call PWR_SWCH_ON function
pradeepvk2208 1:ad3b8a8032e2 270 tm_pointer = new Short_tm;
pradeepvk2208 1:ad3b8a8032e2 271 tm_pointer->TM_string[0] = 0xB0;
pradeepvk2208 1:ad3b8a8032e2 272 tm_pointer->TM_string[1] = GETpacket_seq_count(tc);
pradeepvk2208 1:ad3b8a8032e2 273 tm_pointer->TM_string[2] = ACKCODE;
pradeepvk2208 1:ad3b8a8032e2 274
pradeepvk2208 1:ad3b8a8032e2 275 for(uint8_t i=3;i<11;i++)
cholletisaik777 0:bcbd76c86cde 276 {
pradeepvk2208 1:ad3b8a8032e2 277 tm_pointer->TM_string[i] = 0;
cholletisaik777 0:bcbd76c86cde 278 }
cholletisaik777 0:bcbd76c86cde 279 crc16 = CRC::crc16_gen(tm->TM_string,11);
cholletisaik777 0:bcbd76c86cde 280 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
cholletisaik777 0:bcbd76c86cde 281 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
cholletisaik777 0:bcbd76c86cde 282 return tm;
cholletisaik777 0:bcbd76c86cde 283 break;
pradeepvk2208 1:ad3b8a8032e2 284
cholletisaik777 0:bcbd76c86cde 285 }
pradeepvk2208 1:ad3b8a8032e2 286 else if(GETpid(tc)==0x11)
cholletisaik777 0:bcbd76c86cde 287 {
pradeepvk2208 1:ad3b8a8032e2 288 printf("TC_SW_ON_SD\r\n"); // call PWR_SWCH_ON function
cholletisaik777 0:bcbd76c86cde 289 tm_pointer = new Short_tm;
cholletisaik777 0:bcbd76c86cde 290 tm_pointer->TM_string[0] = 0xB0;
pradeepvk2208 1:ad3b8a8032e2 291 tm_pointer->TM_string[1] = GETpacket_seq_count(tc);
pradeepvk2208 1:ad3b8a8032e2 292 tm_pointer->TM_string[2] = ACKCODE;
pradeepvk2208 1:ad3b8a8032e2 293
pradeepvk2208 1:ad3b8a8032e2 294 for(uint8_t i=3;i<11;i++)
cholletisaik777 0:bcbd76c86cde 295 {
pradeepvk2208 1:ad3b8a8032e2 296 tm_pointer->TM_string[i] = 0;
cholletisaik777 0:bcbd76c86cde 297 }
cholletisaik777 0:bcbd76c86cde 298 crc16 = CRC::crc16_gen(tm->TM_string,11);
cholletisaik777 0:bcbd76c86cde 299 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
cholletisaik777 0:bcbd76c86cde 300 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
cholletisaik777 0:bcbd76c86cde 301 return tm;
cholletisaik777 0:bcbd76c86cde 302 break;
cholletisaik777 0:bcbd76c86cde 303 }
pradeepvk2208 1:ad3b8a8032e2 304 else if(GETpid(tc)==0x12)
cholletisaik777 0:bcbd76c86cde 305 {
pradeepvk2208 1:ad3b8a8032e2 306 printf("TC_SW_ON_RTC\r\n"); // call PWR_SWCH_ON function
pradeepvk2208 1:ad3b8a8032e2 307 tm_pointer = new Short_tm;
pradeepvk2208 1:ad3b8a8032e2 308 tm_pointer->TM_string[0] = 0xB0;
pradeepvk2208 1:ad3b8a8032e2 309 tm_pointer->TM_string[1] = GETpacket_seq_count(tc);
pradeepvk2208 1:ad3b8a8032e2 310 tm_pointer->TM_string[2] = ACKCODE;
pradeepvk2208 1:ad3b8a8032e2 311
pradeepvk2208 1:ad3b8a8032e2 312 for(uint8_t i=3;i<11;i++)
pradeepvk2208 1:ad3b8a8032e2 313 {
pradeepvk2208 1:ad3b8a8032e2 314 tm_pointer->TM_string[i] = 0;
pradeepvk2208 1:ad3b8a8032e2 315 }
pradeepvk2208 1:ad3b8a8032e2 316 crc16 = CRC::crc16_gen(tm->TM_string,11);
pradeepvk2208 1:ad3b8a8032e2 317 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
pradeepvk2208 1:ad3b8a8032e2 318 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
pradeepvk2208 1:ad3b8a8032e2 319 return tm;
pradeepvk2208 1:ad3b8a8032e2 320 break;
pradeepvk2208 1:ad3b8a8032e2 321 }
pradeepvk2208 1:ad3b8a8032e2 322 else if(GETpid(tc)==0x13)
pradeepvk2208 1:ad3b8a8032e2 323 {
pradeepvk2208 1:ad3b8a8032e2 324 printf("TC_SW_ON_BAE\r\n"); // call PWR_SWCH_ON function
cholletisaik777 0:bcbd76c86cde 325 tm_pointer = new Short_tm;
cholletisaik777 0:bcbd76c86cde 326 tm_pointer->TM_string[0] = 0xB0;
pradeepvk2208 1:ad3b8a8032e2 327 tm_pointer->TM_string[1] = GETpacket_seq_count(tc);
pradeepvk2208 1:ad3b8a8032e2 328 tm_pointer->TM_string[2] = ACKCODE;
pradeepvk2208 1:ad3b8a8032e2 329
pradeepvk2208 1:ad3b8a8032e2 330 for(uint8_t i=3;i<11;i++)
cholletisaik777 0:bcbd76c86cde 331 {
pradeepvk2208 1:ad3b8a8032e2 332 tm_pointer->TM_string[i] = 0;
pradeepvk2208 1:ad3b8a8032e2 333 }
pradeepvk2208 1:ad3b8a8032e2 334 crc16 = CRC::crc16_gen(tm->TM_string,11);
pradeepvk2208 1:ad3b8a8032e2 335 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
pradeepvk2208 1:ad3b8a8032e2 336 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
pradeepvk2208 1:ad3b8a8032e2 337 return tm;
pradeepvk2208 1:ad3b8a8032e2 338 break;
pradeepvk2208 1:ad3b8a8032e2 339 }
pradeepvk2208 1:ad3b8a8032e2 340 else if(GETpid(tc)==0x14)
pradeepvk2208 1:ad3b8a8032e2 341 {
pradeepvk2208 1:ad3b8a8032e2 342 printf("TC_SW_ON_PL_DL\r\n"); // call PWR_SWCH_ON function
pradeepvk2208 1:ad3b8a8032e2 343 tm_pointer = new Short_tm;
pradeepvk2208 1:ad3b8a8032e2 344 tm_pointer->TM_string[0] = 0xB0;
pradeepvk2208 1:ad3b8a8032e2 345 tm_pointer->TM_string[1] = GETpacket_seq_count(tc);
pradeepvk2208 1:ad3b8a8032e2 346 tm_pointer->TM_string[2] = ACKCODE;
pradeepvk2208 1:ad3b8a8032e2 347
pradeepvk2208 1:ad3b8a8032e2 348 for(uint8_t i=3;i<11;i++)
pradeepvk2208 1:ad3b8a8032e2 349 {
pradeepvk2208 1:ad3b8a8032e2 350 tm_pointer->TM_string[i] = 0;
pradeepvk2208 1:ad3b8a8032e2 351 }
pradeepvk2208 1:ad3b8a8032e2 352 crc16 = CRC::crc16_gen(tm->TM_string,11);
pradeepvk2208 1:ad3b8a8032e2 353 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
pradeepvk2208 1:ad3b8a8032e2 354 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
pradeepvk2208 1:ad3b8a8032e2 355 return tm;
pradeepvk2208 1:ad3b8a8032e2 356 break;
pradeepvk2208 1:ad3b8a8032e2 357 }
pradeepvk2208 1:ad3b8a8032e2 358 else if(GETpid(tc)==0x15)
pradeepvk2208 1:ad3b8a8032e2 359 {
pradeepvk2208 1:ad3b8a8032e2 360 printf("TC_SW_ON_PL_AG_HV\r\n"); // call PWR_SWCH_ON function
pradeepvk2208 1:ad3b8a8032e2 361 tm_pointer = new Short_tm;
pradeepvk2208 1:ad3b8a8032e2 362 tm_pointer->TM_string[0] = 0xB0;
pradeepvk2208 1:ad3b8a8032e2 363 tm_pointer->TM_string[1] = GETpacket_seq_count(tc);
pradeepvk2208 1:ad3b8a8032e2 364 tm_pointer->TM_string[2] = ACKCODE;
pradeepvk2208 1:ad3b8a8032e2 365
pradeepvk2208 1:ad3b8a8032e2 366 for(uint8_t i=3;i<11;i++)
pradeepvk2208 1:ad3b8a8032e2 367 {
pradeepvk2208 1:ad3b8a8032e2 368 tm_pointer->TM_string[i] = 0;
cholletisaik777 0:bcbd76c86cde 369 }
cholletisaik777 0:bcbd76c86cde 370 crc16 = CRC::crc16_gen(tm->TM_string,11);
cholletisaik777 0:bcbd76c86cde 371 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
cholletisaik777 0:bcbd76c86cde 372 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
cholletisaik777 0:bcbd76c86cde 373 return tm;
cholletisaik777 0:bcbd76c86cde 374 break;
cholletisaik777 0:bcbd76c86cde 375 }
pradeepvk2208 1:ad3b8a8032e2 376 else if(GETpid(tc)==0x16)
cholletisaik777 0:bcbd76c86cde 377 {
pradeepvk2208 1:ad3b8a8032e2 378 printf("TC_SW_ON_V_A_EN\r\n"); // call PWR_SWCH_ON function
pradeepvk2208 1:ad3b8a8032e2 379 tm_pointer = new Short_tm;
pradeepvk2208 1:ad3b8a8032e2 380 tm_pointer->TM_string[0] = 0xB0;
pradeepvk2208 1:ad3b8a8032e2 381 tm_pointer->TM_string[1] = GETpacket_seq_count(tc);
pradeepvk2208 1:ad3b8a8032e2 382 tm_pointer->TM_string[2] = ACKCODE;
pradeepvk2208 1:ad3b8a8032e2 383
pradeepvk2208 1:ad3b8a8032e2 384 for(uint8_t i=3;i<11;i++)
cholletisaik777 0:bcbd76c86cde 385 {
pradeepvk2208 1:ad3b8a8032e2 386 tm_pointer->TM_string[i] = 0;
cholletisaik777 0:bcbd76c86cde 387 }
pradeepvk2208 1:ad3b8a8032e2 388 crc16 = CRC::crc16_gen(tm->TM_string,11);
pradeepvk2208 1:ad3b8a8032e2 389 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
pradeepvk2208 1:ad3b8a8032e2 390 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
pradeepvk2208 1:ad3b8a8032e2 391 return tm;
pradeepvk2208 1:ad3b8a8032e2 392 break;
pradeepvk2208 1:ad3b8a8032e2 393
cholletisaik777 0:bcbd76c86cde 394 }
pradeepvk2208 1:ad3b8a8032e2 395 else if(GETpid(tc)==0x21)
cholletisaik777 0:bcbd76c86cde 396 {
pradeepvk2208 1:ad3b8a8032e2 397 printf("TC_SW_OFF_SD\r\n"); // call PWR_SWCH_ON function
pradeepvk2208 1:ad3b8a8032e2 398 tm_pointer = new Short_tm;
pradeepvk2208 1:ad3b8a8032e2 399 tm_pointer->TM_string[0] = 0xB0;
pradeepvk2208 1:ad3b8a8032e2 400 tm_pointer->TM_string[1] = GETpacket_seq_count(tc);
pradeepvk2208 1:ad3b8a8032e2 401 tm_pointer->TM_string[2] = ACKCODE;
pradeepvk2208 1:ad3b8a8032e2 402
pradeepvk2208 1:ad3b8a8032e2 403 for(uint8_t i=3;i<11;i++)
pradeepvk2208 1:ad3b8a8032e2 404 {
pradeepvk2208 1:ad3b8a8032e2 405 tm_pointer->TM_string[i] = 0;
pradeepvk2208 1:ad3b8a8032e2 406 }
pradeepvk2208 1:ad3b8a8032e2 407 crc16 = CRC::crc16_gen(tm->TM_string,11);
pradeepvk2208 1:ad3b8a8032e2 408 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
pradeepvk2208 1:ad3b8a8032e2 409 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
pradeepvk2208 1:ad3b8a8032e2 410 return tm;
pradeepvk2208 1:ad3b8a8032e2 411 break;
pradeepvk2208 1:ad3b8a8032e2 412 }
pradeepvk2208 1:ad3b8a8032e2 413 else if(GETpid(tc)==0x22)
pradeepvk2208 1:ad3b8a8032e2 414 {
pradeepvk2208 1:ad3b8a8032e2 415 printf("TC_SW_OFF_RTC\r\n"); // call PWR_SWCH_ON function
cholletisaik777 0:bcbd76c86cde 416 tm_pointer = new Short_tm;
cholletisaik777 0:bcbd76c86cde 417 tm_pointer->TM_string[0] = 0xB0;
cholletisaik777 0:bcbd76c86cde 418 tm_pointer->TM_string[1] = GETpacket_seq_count(tc);
pradeepvk2208 1:ad3b8a8032e2 419 tm_pointer->TM_string[2] = ACKCODE;
pradeepvk2208 1:ad3b8a8032e2 420
pradeepvk2208 1:ad3b8a8032e2 421 for(uint8_t i=3;i<11;i++)
pradeepvk2208 1:ad3b8a8032e2 422 {
pradeepvk2208 1:ad3b8a8032e2 423 tm_pointer->TM_string[i] = 0;
pradeepvk2208 1:ad3b8a8032e2 424 }
pradeepvk2208 1:ad3b8a8032e2 425 crc16 = CRC::crc16_gen(tm->TM_string,11);
pradeepvk2208 1:ad3b8a8032e2 426 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
pradeepvk2208 1:ad3b8a8032e2 427 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
pradeepvk2208 1:ad3b8a8032e2 428 return tm;
pradeepvk2208 1:ad3b8a8032e2 429 break;
pradeepvk2208 1:ad3b8a8032e2 430 }
pradeepvk2208 1:ad3b8a8032e2 431 else if(GETpid(tc)==0x23)
pradeepvk2208 1:ad3b8a8032e2 432 {
pradeepvk2208 1:ad3b8a8032e2 433 printf("TC_SW_OFF_BAE\r\n"); // call PWR_SWCH_ON function
pradeepvk2208 1:ad3b8a8032e2 434 tm_pointer = new Short_tm;
pradeepvk2208 1:ad3b8a8032e2 435 tm_pointer->TM_string[0] = 0xB0;
pradeepvk2208 1:ad3b8a8032e2 436 tm_pointer->TM_string[1] = GETpacket_seq_count(tc);
pradeepvk2208 1:ad3b8a8032e2 437 tm_pointer->TM_string[2] = ACKCODE;
pradeepvk2208 1:ad3b8a8032e2 438
pradeepvk2208 1:ad3b8a8032e2 439 for(uint8_t i=3;i<11;i++)
cholletisaik777 0:bcbd76c86cde 440 {
pradeepvk2208 1:ad3b8a8032e2 441 tm_pointer->TM_string[i] = 0;
pradeepvk2208 1:ad3b8a8032e2 442 }
pradeepvk2208 1:ad3b8a8032e2 443 crc16 = CRC::crc16_gen(tm->TM_string,11);
pradeepvk2208 1:ad3b8a8032e2 444 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
pradeepvk2208 1:ad3b8a8032e2 445 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
pradeepvk2208 1:ad3b8a8032e2 446 return tm;
pradeepvk2208 1:ad3b8a8032e2 447 break;
pradeepvk2208 1:ad3b8a8032e2 448 }
pradeepvk2208 1:ad3b8a8032e2 449 else if(GETpid(tc)==0x24)
pradeepvk2208 1:ad3b8a8032e2 450 {
pradeepvk2208 1:ad3b8a8032e2 451 printf("TC_SW_OFF_PL_DL\r\n"); // call PWR_SWCH_ON function
pradeepvk2208 1:ad3b8a8032e2 452 tm_pointer = new Short_tm;
pradeepvk2208 1:ad3b8a8032e2 453 tm_pointer->TM_string[0] = 0xB0;
pradeepvk2208 1:ad3b8a8032e2 454 tm_pointer->TM_string[1] = GETpacket_seq_count(tc);
pradeepvk2208 1:ad3b8a8032e2 455 tm_pointer->TM_string[2] = ACKCODE;
pradeepvk2208 1:ad3b8a8032e2 456
pradeepvk2208 1:ad3b8a8032e2 457 for(uint8_t i=3;i<11;i++)
pradeepvk2208 1:ad3b8a8032e2 458 {
pradeepvk2208 1:ad3b8a8032e2 459 tm_pointer->TM_string[i] = 0;
pradeepvk2208 1:ad3b8a8032e2 460 }
pradeepvk2208 1:ad3b8a8032e2 461 crc16 = CRC::crc16_gen(tm->TM_string,11);
pradeepvk2208 1:ad3b8a8032e2 462 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
pradeepvk2208 1:ad3b8a8032e2 463 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
pradeepvk2208 1:ad3b8a8032e2 464 return tm;
pradeepvk2208 1:ad3b8a8032e2 465 break;
pradeepvk2208 1:ad3b8a8032e2 466 }
pradeepvk2208 1:ad3b8a8032e2 467 else if(GETpid(tc)==0x25)
pradeepvk2208 1:ad3b8a8032e2 468 {
pradeepvk2208 1:ad3b8a8032e2 469 printf("TC_SW_OFF_PL_AG_HV\r\n"); // call PWR_SWCH_ON function
pradeepvk2208 1:ad3b8a8032e2 470 tm_pointer = new Short_tm;
pradeepvk2208 1:ad3b8a8032e2 471 tm_pointer->TM_string[0] = 0xB0;
pradeepvk2208 1:ad3b8a8032e2 472 tm_pointer->TM_string[1] = GETpacket_seq_count(tc);
pradeepvk2208 1:ad3b8a8032e2 473 tm_pointer->TM_string[2] = ACKCODE;
pradeepvk2208 1:ad3b8a8032e2 474
pradeepvk2208 1:ad3b8a8032e2 475 for(uint8_t i=3;i<11;i++)
pradeepvk2208 1:ad3b8a8032e2 476 {
pradeepvk2208 1:ad3b8a8032e2 477 tm_pointer->TM_string[i] = 0;
cholletisaik777 0:bcbd76c86cde 478 }
cholletisaik777 0:bcbd76c86cde 479 crc16 = CRC::crc16_gen(tm->TM_string,11);
cholletisaik777 0:bcbd76c86cde 480 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
cholletisaik777 0:bcbd76c86cde 481 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
cholletisaik777 0:bcbd76c86cde 482 return tm;
cholletisaik777 0:bcbd76c86cde 483 break;
cholletisaik777 0:bcbd76c86cde 484 }
pradeepvk2208 1:ad3b8a8032e2 485 else if(GETpid(tc)==0x26)
cholletisaik777 0:bcbd76c86cde 486 {
pradeepvk2208 1:ad3b8a8032e2 487 printf("TC_SW_OFF_V_A_EN\r\n"); // call PWR_SWCH_ON function
pradeepvk2208 1:ad3b8a8032e2 488 tm_pointer = new Short_tm;
pradeepvk2208 1:ad3b8a8032e2 489 tm_pointer->TM_string[0] = 0xB0;
pradeepvk2208 1:ad3b8a8032e2 490 tm_pointer->TM_string[1] = GETpacket_seq_count(tc);
pradeepvk2208 1:ad3b8a8032e2 491 tm_pointer->TM_string[2] = ACKCODE;
pradeepvk2208 1:ad3b8a8032e2 492
pradeepvk2208 1:ad3b8a8032e2 493 for(uint8_t i=3;i<11;i++)
pradeepvk2208 1:ad3b8a8032e2 494 {
pradeepvk2208 1:ad3b8a8032e2 495 tm_pointer->TM_string[i] = 0;
pradeepvk2208 1:ad3b8a8032e2 496 }
pradeepvk2208 1:ad3b8a8032e2 497 crc16 = CRC::crc16_gen(tm->TM_string,11);
pradeepvk2208 1:ad3b8a8032e2 498 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
pradeepvk2208 1:ad3b8a8032e2 499 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
pradeepvk2208 1:ad3b8a8032e2 500 return tm;
pradeepvk2208 1:ad3b8a8032e2 501 break;
pradeepvk2208 1:ad3b8a8032e2 502 }
pradeepvk2208 1:ad3b8a8032e2 503 else if(GETpid(tc)==0x31)
pradeepvk2208 1:ad3b8a8032e2 504 {
pradeepvk2208 1:ad3b8a8032e2 505 printf("TC_RST_SD\r\n"); // call PWR_SWCH_ON function
cholletisaik777 0:bcbd76c86cde 506 tm_pointer = new Short_tm;
cholletisaik777 0:bcbd76c86cde 507 tm_pointer->TM_string[0] = 0xB0;
cholletisaik777 0:bcbd76c86cde 508 tm_pointer->TM_string[1] = GETpacket_seq_count(tc);
pradeepvk2208 1:ad3b8a8032e2 509 tm_pointer->TM_string[2] = ACKCODE;
pradeepvk2208 1:ad3b8a8032e2 510
pradeepvk2208 1:ad3b8a8032e2 511 for(uint8_t i=3;i<11;i++)
cholletisaik777 0:bcbd76c86cde 512 {
pradeepvk2208 1:ad3b8a8032e2 513 tm_pointer->TM_string[i] = 0;
pradeepvk2208 1:ad3b8a8032e2 514 }
pradeepvk2208 1:ad3b8a8032e2 515 crc16 = CRC::crc16_gen(tm->TM_string,11);
pradeepvk2208 1:ad3b8a8032e2 516 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
pradeepvk2208 1:ad3b8a8032e2 517 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
pradeepvk2208 1:ad3b8a8032e2 518 return tm;
pradeepvk2208 1:ad3b8a8032e2 519 break;
pradeepvk2208 1:ad3b8a8032e2 520 }
pradeepvk2208 1:ad3b8a8032e2 521 else if(GETpid(tc)==0x32)
pradeepvk2208 1:ad3b8a8032e2 522 {
pradeepvk2208 1:ad3b8a8032e2 523 printf("TC_RST_RTC\r\n"); // call PWR_SWCH_ON function
pradeepvk2208 1:ad3b8a8032e2 524 tm_pointer = new Short_tm;
pradeepvk2208 1:ad3b8a8032e2 525 tm_pointer->TM_string[0] = 0xB0;
pradeepvk2208 1:ad3b8a8032e2 526 tm_pointer->TM_string[1] = GETpacket_seq_count(tc);
pradeepvk2208 1:ad3b8a8032e2 527 tm_pointer->TM_string[2] = ACKCODE;
pradeepvk2208 1:ad3b8a8032e2 528
pradeepvk2208 1:ad3b8a8032e2 529 for(uint8_t i=3;i<11;i++)
pradeepvk2208 1:ad3b8a8032e2 530 {
pradeepvk2208 1:ad3b8a8032e2 531 tm_pointer->TM_string[i] = 0;
cholletisaik777 0:bcbd76c86cde 532 }
cholletisaik777 0:bcbd76c86cde 533 crc16 = CRC::crc16_gen(tm->TM_string,11);
cholletisaik777 0:bcbd76c86cde 534 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
cholletisaik777 0:bcbd76c86cde 535 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
cholletisaik777 0:bcbd76c86cde 536 return tm;
cholletisaik777 0:bcbd76c86cde 537 break;
cholletisaik777 0:bcbd76c86cde 538 }
pradeepvk2208 1:ad3b8a8032e2 539 else if(GETpid(tc)==0x33)
cholletisaik777 0:bcbd76c86cde 540 {
pradeepvk2208 1:ad3b8a8032e2 541 printf("TC_RST_BAE\r\n"); // call PWR_SWCH_ON function
cholletisaik777 0:bcbd76c86cde 542 tm_pointer = new Short_tm;
cholletisaik777 0:bcbd76c86cde 543 tm_pointer->TM_string[0] = 0xB0;
cholletisaik777 0:bcbd76c86cde 544 tm_pointer->TM_string[1] = GETpacket_seq_count(tc);
pradeepvk2208 1:ad3b8a8032e2 545 tm_pointer->TM_string[2] = ACKCODE;
pradeepvk2208 1:ad3b8a8032e2 546
pradeepvk2208 1:ad3b8a8032e2 547 for(uint8_t i=3;i<11;i++)
cholletisaik777 0:bcbd76c86cde 548 {
pradeepvk2208 1:ad3b8a8032e2 549 tm_pointer->TM_string[i] = 0;
cholletisaik777 0:bcbd76c86cde 550 }
cholletisaik777 0:bcbd76c86cde 551 crc16 = CRC::crc16_gen(tm->TM_string,11);
cholletisaik777 0:bcbd76c86cde 552 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
cholletisaik777 0:bcbd76c86cde 553 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
cholletisaik777 0:bcbd76c86cde 554 return tm;
cholletisaik777 0:bcbd76c86cde 555 break;
cholletisaik777 0:bcbd76c86cde 556 }
pradeepvk2208 1:ad3b8a8032e2 557 else if(GETpid(tc)==0x34)
pradeepvk2208 1:ad3b8a8032e2 558 {
pradeepvk2208 1:ad3b8a8032e2 559 printf("TC_RST_PL_DL\r\n"); // call PWR_SWCH_ON function
pradeepvk2208 1:ad3b8a8032e2 560 tm_pointer = new Short_tm;
pradeepvk2208 1:ad3b8a8032e2 561 tm_pointer->TM_string[0] = 0xB0;
pradeepvk2208 1:ad3b8a8032e2 562 tm_pointer->TM_string[1] = GETpacket_seq_count(tc);
pradeepvk2208 1:ad3b8a8032e2 563 tm_pointer->TM_string[2] = ACKCODE;
pradeepvk2208 1:ad3b8a8032e2 564
pradeepvk2208 1:ad3b8a8032e2 565 for(uint8_t i=3;i<11;i++)
pradeepvk2208 1:ad3b8a8032e2 566 {
pradeepvk2208 1:ad3b8a8032e2 567 tm_pointer->TM_string[i] = 0;
pradeepvk2208 1:ad3b8a8032e2 568 }
pradeepvk2208 1:ad3b8a8032e2 569 crc16 = CRC::crc16_gen(tm->TM_string,11);
pradeepvk2208 1:ad3b8a8032e2 570 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
pradeepvk2208 1:ad3b8a8032e2 571 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
pradeepvk2208 1:ad3b8a8032e2 572 return tm;
pradeepvk2208 1:ad3b8a8032e2 573 break;
pradeepvk2208 1:ad3b8a8032e2 574
pradeepvk2208 1:ad3b8a8032e2 575 }
pradeepvk2208 1:ad3b8a8032e2 576 else if(GETpid(tc)==0xC1)
pradeepvk2208 1:ad3b8a8032e2 577 {
pradeepvk2208 1:ad3b8a8032e2 578 printf("RESET_HK_COUNTER\r\n"); // call PWR_SWCH_ON function
pradeepvk2208 1:ad3b8a8032e2 579 tm_pointer = new Short_tm;
pradeepvk2208 1:ad3b8a8032e2 580 tm_pointer->TM_string[0] = 0xB0;
pradeepvk2208 1:ad3b8a8032e2 581 tm_pointer->TM_string[1] = GETpacket_seq_count(tc);
pradeepvk2208 1:ad3b8a8032e2 582 tm_pointer->TM_string[2] = ACKCODE;
pradeepvk2208 1:ad3b8a8032e2 583
pradeepvk2208 1:ad3b8a8032e2 584 for(uint8_t i=3;i<11;i++)
pradeepvk2208 1:ad3b8a8032e2 585 {
pradeepvk2208 1:ad3b8a8032e2 586 tm_pointer->TM_string[i] = 0;
pradeepvk2208 1:ad3b8a8032e2 587 }
pradeepvk2208 1:ad3b8a8032e2 588 crc16 = CRC::crc16_gen(tm->TM_string,11);
pradeepvk2208 1:ad3b8a8032e2 589 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
pradeepvk2208 1:ad3b8a8032e2 590 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
pradeepvk2208 1:ad3b8a8032e2 591 return tm;
pradeepvk2208 1:ad3b8a8032e2 592 break;
pradeepvk2208 1:ad3b8a8032e2 593 }
pradeepvk2208 1:ad3b8a8032e2 594 else if(GETpid(tc)==0xF1)
cholletisaik777 0:bcbd76c86cde 595 {
cholletisaik777 0:bcbd76c86cde 596 printf("RD_RTC\r\n"); //call RD_RTC
cholletisaik777 0:bcbd76c86cde 597 tm_pointer = new Short_tm;
cholletisaik777 0:bcbd76c86cde 598 tm_pointer->TM_string[0] = 0xD0;
cholletisaik777 0:bcbd76c86cde 599 tm_pointer->TM_string[1] = GETpacket_seq_count(tc);
cholletisaik777 0:bcbd76c86cde 600 tm_pointer->TM_string[2] = 0x01;
cholletisaik777 0:bcbd76c86cde 601 uint64_t time = FCTN_CDMS_RD_RTC();
cholletisaik777 0:bcbd76c86cde 602 tm_pointer->TM_string[3] = (uint8_t)((time&0xFF00000000000000)>>56);
cholletisaik777 0:bcbd76c86cde 603 tm_pointer->TM_string[4] = (uint8_t)((time&0x00FF000000000000)>>48);
cholletisaik777 0:bcbd76c86cde 604 tm_pointer->TM_string[5] = (uint8_t)((time&0x0000FF0000000000)>>40);
cholletisaik777 0:bcbd76c86cde 605 tm_pointer->TM_string[6] = (uint8_t)((time&0x000000FF00000000)>>32);
cholletisaik777 0:bcbd76c86cde 606 tm_pointer->TM_string[7] = (uint8_t)((time&0x00000000FF000000)>>24);
cholletisaik777 0:bcbd76c86cde 607 tm_pointer->TM_string[8] = (uint8_t)((time&0x0000000000FF0000)>>16);
cholletisaik777 0:bcbd76c86cde 608 tm_pointer->TM_string[9] = (uint8_t)((time&0x000000000000FF00)>>8);
cholletisaik777 0:bcbd76c86cde 609 tm_pointer->TM_string[10] = (uint8_t)(time&0x00000000000000FF);
cholletisaik777 0:bcbd76c86cde 610 crc16 = CRC::crc16_gen(tm->TM_string,11);
cholletisaik777 0:bcbd76c86cde 611 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
cholletisaik777 0:bcbd76c86cde 612 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
cholletisaik777 0:bcbd76c86cde 613 return tm;
cholletisaik777 0:bcbd76c86cde 614 }
pradeepvk2208 1:ad3b8a8032e2 615
cholletisaik777 0:bcbd76c86cde 616 else
cholletisaik777 0:bcbd76c86cde 617 {
cholletisaik777 0:bcbd76c86cde 618 printf("INVALID TC\r\n");
cholletisaik777 0:bcbd76c86cde 619 tm_pointer = new Short_tm;
cholletisaik777 0:bcbd76c86cde 620 tm_pointer->TM_string[0] = 0xB0;
cholletisaik777 0:bcbd76c86cde 621 tm_pointer->TM_string[1] = GETpacket_seq_count(tc);
cholletisaik777 0:bcbd76c86cde 622 tm_pointer->TM_string[2] = 0x01;
cholletisaik777 0:bcbd76c86cde 623 tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided
cholletisaik777 0:bcbd76c86cde 624 tm_pointer->TM_string[4] = 0x01;
cholletisaik777 0:bcbd76c86cde 625 for(uint8_t i=0;i<6;i++)
cholletisaik777 0:bcbd76c86cde 626 {
cholletisaik777 0:bcbd76c86cde 627 tm_pointer->TM_string[i+5] = 0;
cholletisaik777 0:bcbd76c86cde 628 }
cholletisaik777 0:bcbd76c86cde 629 crc16 = CRC::crc16_gen(tm->TM_string,11);
cholletisaik777 0:bcbd76c86cde 630 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
cholletisaik777 0:bcbd76c86cde 631 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
cholletisaik777 0:bcbd76c86cde 632 return tm;
cholletisaik777 0:bcbd76c86cde 633 }
cholletisaik777 0:bcbd76c86cde 634 }
pradeepvk2208 1:ad3b8a8032e2 635
cholletisaik777 0:bcbd76c86cde 636 }
pradeepvk2208 1:ad3b8a8032e2 637
pradeepvk2208 1:ad3b8a8032e2 638
pradeepvk2208 1:ad3b8a8032e2 639
pradeepvk2208 1:ad3b8a8032e2 640
cholletisaik777 0:bcbd76c86cde 641 default:
cholletisaik777 0:bcbd76c86cde 642 {
cholletisaik777 0:bcbd76c86cde 643 printf("INVALID TC"); //send invalid TC TM
cholletisaik777 0:bcbd76c86cde 644 tm_pointer = new Short_tm;
cholletisaik777 0:bcbd76c86cde 645 tm_pointer->TM_string[0] = 0xB0;
cholletisaik777 0:bcbd76c86cde 646 tm_pointer->TM_string[1] = GETpacket_seq_count(tc);
cholletisaik777 0:bcbd76c86cde 647 tm_pointer->TM_string[2] = 0x01;
cholletisaik777 0:bcbd76c86cde 648 tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided
cholletisaik777 0:bcbd76c86cde 649 tm_pointer->TM_string[4] = 0x01;
cholletisaik777 0:bcbd76c86cde 650 for(uint8_t i=0;i<6;i++)
cholletisaik777 0:bcbd76c86cde 651 {
cholletisaik777 0:bcbd76c86cde 652 tm_pointer->TM_string[i+5] = 0;
cholletisaik777 0:bcbd76c86cde 653 }
cholletisaik777 0:bcbd76c86cde 654 crc16 = CRC::crc16_gen(tm->TM_string,11);
cholletisaik777 0:bcbd76c86cde 655 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
cholletisaik777 0:bcbd76c86cde 656 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
cholletisaik777 0:bcbd76c86cde 657 return tm;
cholletisaik777 0:bcbd76c86cde 658 break;
cholletisaik777 0:bcbd76c86cde 659 }
cholletisaik777 0:bcbd76c86cde 660 }
cholletisaik777 0:bcbd76c86cde 661 }
cholletisaik777 0:bcbd76c86cde 662 case 3:
cholletisaik777 0:bcbd76c86cde 663 {
cholletisaik777 0:bcbd76c86cde 664 printf("Telecommand is for PL\r\n");
cholletisaik777 0:bcbd76c86cde 665 // printf("Informing PL about TC using I2C\r\n"); //interrupt to be sent to the bae
cholletisaik777 0:bcbd76c86cde 666 // FCTN_I2C_WRITE((char*)tc->TC_string);
cholletisaik777 0:bcbd76c86cde 667 // printf("sent the Telecommand to BAE\r\n"); //packet along with crc will be sent when bae is ready
cholletisaik777 0:bcbd76c86cde 668 // wait(1); //wait time is to be optimised
cholletisaik777 0:bcbd76c86cde 669 // if(tm_status_4m_slv == 1)
cholletisaik777 0:bcbd76c86cde 670 // {
cholletisaik777 0:bcbd76c86cde 671 // FCTN_I2C_READ((char*)tm->TM_string);
cholletisaik777 0:bcbd76c86cde 672 // received = 1;
cholletisaik777 0:bcbd76c86cde 673 // }
cholletisaik777 0:bcbd76c86cde 674 // if(received == 1 )
cholletisaik777 0:bcbd76c86cde 675 // {
cholletisaik777 0:bcbd76c86cde 676 // printf("Telemetry is received from BAE\r\n");
cholletisaik777 0:bcbd76c86cde 677 // printf("%s", tm->TM_string);
cholletisaik777 0:bcbd76c86cde 678 // received = 0;
cholletisaik777 0:bcbd76c86cde 679 // } // similar to BAE functions
cholletisaik777 0:bcbd76c86cde 680 break;
cholletisaik777 0:bcbd76c86cde 681 }
pradeepvk2208 1:ad3b8a8032e2 682
cholletisaik777 0:bcbd76c86cde 683 default: //invalid TC
cholletisaik777 0:bcbd76c86cde 684 {
cholletisaik777 0:bcbd76c86cde 685 printf("INVALID TC\r\n");
cholletisaik777 0:bcbd76c86cde 686 tm_pointer = new Short_tm;
cholletisaik777 0:bcbd76c86cde 687 tm_pointer->TM_string[0] = 0xB0;
cholletisaik777 0:bcbd76c86cde 688 tm_pointer->TM_string[1] = GETpacket_seq_count(tc);
cholletisaik777 0:bcbd76c86cde 689 tm_pointer->TM_string[2] = 0x01;
cholletisaik777 0:bcbd76c86cde 690 tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided
cholletisaik777 0:bcbd76c86cde 691 tm_pointer->TM_string[4] = 0x01;
cholletisaik777 0:bcbd76c86cde 692 for(uint8_t i=0;i<6;i++)
cholletisaik777 0:bcbd76c86cde 693 {
cholletisaik777 0:bcbd76c86cde 694 tm_pointer->TM_string[i+5] = 0;
cholletisaik777 0:bcbd76c86cde 695 }
cholletisaik777 0:bcbd76c86cde 696 crc16 = CRC::crc16_gen(tm->TM_string,11);
cholletisaik777 0:bcbd76c86cde 697 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
cholletisaik777 0:bcbd76c86cde 698 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
cholletisaik777 0:bcbd76c86cde 699 return tm;
cholletisaik777 0:bcbd76c86cde 700 break;
pradeepvk2208 1:ad3b8a8032e2 701 }
pradeepvk2208 1:ad3b8a8032e2 702
pradeepvk2208 1:ad3b8a8032e2 703
pradeepvk2208 1:ad3b8a8032e2 704 }
pradeepvk2208 1:ad3b8a8032e2 705 }
cholletisaik777 0:bcbd76c86cde 706 }