publishing to check changes in cdms code

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE_samp_23SEP_DMA_flag by samp Srinivasan

Committer:
ee12b079
Date:
Fri Jul 01 07:55:06 2016 +0000
Revision:
201:3410fc4d80f0
Parent:
200:05ff11766d9a
Child:
202:8700a3e6324c
works for other ackcodes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ee12b079 86:a26f5f22631d 1 // problem in check pa and valid sid not sending anything in one for loop
ee12b079 86:a26f5f22631d 2
ee12b079 86:a26f5f22631d 3
ee12b079 86:a26f5f22631d 4
ee12b079 86:a26f5f22631d 5 // no error case 2 ackl234new->TM_string[2] = (101_0000) = 0x_0; spare = 0 10100000 = 0xA0
ee12b079 86:a26f5f22631d 6 // Hardware failure Case 4 ackl234new->TM_string[2] = (100_0101) = 0x_5; spare = 0 10000101 = 0x85 comes from cdms ask pradeep
ee12b079 86:a26f5f22631d 7 // Invalid FSC Case 4 ackl234new->TM_string[2] = (100_0110) = 0x_6; spare = 0 10000110 = 0x86 Invalid FSC
ee12b079 86:a26f5f22631d 8 // Illegal TC Case 3 ackl234new->TM_string[2] = (000_0010) = 0x_2; spare = 0 00000010 = 0x02 invalid SID
ee12b079 86:a26f5f22631d 9
ee12b079 86:a26f5f22631d 10 #define TMID_ACK_L234 0xB
krishanprajapat 149:827e23febfdf 11 #define T_frames_in_segment 40
ee12b079 86:a26f5f22631d 12
ee12b079 86:a26f5f22631d 13 using namespace std;
ee12b079 142:83f48d1a1bc5 14 Base_tc *current_obsrs_tc = NULL;
krishanprajapat 121:bd7263168ee4 15 Base_tm *callsign = NULL;
ee12b079 86:a26f5f22631d 16 bool send_EoS_and_stop = false;
ee12b079 86:a26f5f22631d 17 bool adf_limit = false;
ee12b079 86:a26f5f22631d 18 bool stop = false;
ee12b079 86:a26f5f22631d 19 bool PA_HOT=0;
ee12b079 86:a26f5f22631d 20 bool short_TC;
ee12b079 86:a26f5f22631d 21 bool valid_SID = true;
ee12b079 86:a26f5f22631d 22 bool enable_call_sign = true;
ee12b079 86:a26f5f22631d 23 bool enable_new_segment=true;
ee12b079 86:a26f5f22631d 24 bool enable_S_frame = true;
ee12b079 86:a26f5f22631d 25 bool enable_read_block = false;
ee12b079 86:a26f5f22631d 26 bool enable_T_frame = false;
ee12b079 86:a26f5f22631d 27 bool enable_Ack_andcallsign = false;
ee12b079 86:a26f5f22631d 28 bool enable_ackandcallsign = false;
ee12b079 86:a26f5f22631d 29 bool new_session =true;
ee12b079 86:a26f5f22631d 30 bool enable_EoS=false;
ee12b079 86:a26f5f22631d 31 bool create_Ack_andcallsign = true;
ee12b079 86:a26f5f22631d 32 bool Ack_andcallsign_over = false;
ee12b079 86:a26f5f22631d 33 bool repeat_last_2T_frames = false;
ee12b079 86:a26f5f22631d 34 bool last_block = false;
ee12b079 86:a26f5f22631d 35 bool last_buffer = false;
ee12b079 86:a26f5f22631d 36 bool new_OBSRS_TC = true;
ee12b079 86:a26f5f22631d 37 bool enable_SCH = true;
ee12b079 86:a26f5f22631d 38 bool enable_FCCH = false;
ee12b079 86:a26f5f22631d 39 bool enable_DS = false;
krishanprajapat 119:2b5632bc78ab 40 bool half_buffer = 0;
ee12b079 143:d81df402a016 41 bool TM_sent = false;
krishanprajapat 127:8a7bee7b8e8b 42 //bool session_over = gFLAGS & COM_SESSION_TIMEOUT_FLAG;
ee12b079 86:a26f5f22631d 43
ee12b079 86:a26f5f22631d 44 uint8_t SID ;
ee12b079 86:a26f5f22631d 45 unsigned char buffer_112[112];
ee12b079 92:bce22b38c440 46 uint32_t FSC;
ee12b079 199:9f03d6ca94c9 47 uint16_t read_success = false;
ee12b079 86:a26f5f22631d 48 uint16_t counter_buffer_112=0, counter_EoS=0,T_frames_sent=0;
krishanprajapat 123:457d6fd9ac37 49 uint16_t counter_interleavedata=0;
ee12b079 86:a26f5f22631d 50 uint16_t counter_buffer_512=0;
ee12b079 86:a26f5f22631d 51 uint16_t max_segments = 65415/(48+T_frames_in_segment*159);
ee12b079 199:9f03d6ca94c9 52 uint16_t ack_code = 0xA0;
krishanprajapat 123:457d6fd9ac37 53 uint8_t segments_sent = 0;
ee12b079 86:a26f5f22631d 54 uint8_t counter_SCH40 = 0;
ee12b079 86:a26f5f22631d 55 uint8_t counter_FCCH80 = 0;
ee12b079 86:a26f5f22631d 56 uint8_t counter_S_frame = 0;
krishanprajapat 123:457d6fd9ac37 57 uint8_t T_frame_Ack_andcallsign_sent = 0;
ee12b079 143:d81df402a016 58 uint8_t T_frame_in_Ackandcallsign ; // needs to get from sukhdeep depends on size of Ack_L1
krishanprajapat 123:457d6fd9ac37 59 uint32_t block_counter = 0;
ee12b079 88:b9beee1a7a3e 60 uint8_t no_of_frames =0;
ee12b079 86:a26f5f22631d 61
ee12b079 86:a26f5f22631d 62 //#define max_segments = 65415/(48+T_frames_in_segment*159)
ee12b079 86:a26f5f22631d 63 // data 288 byte with convolution without xoring 0x38,0x90,0x7B,0x40,0x01,0x56,0x45,0xE0,0x3C,0xA0,0x7A,0x90,0x3D,0xE6,0x3E,0x70,0x21,0x42,0x43,0x3C,0x0C,0x20,0x00,0x4C,0x83,0x12,0x67,0xF0,0x8F,0x36,0x60,0x3C,0x86,0x24,0x06,0x80,0x20,0x54,0x22,0x9C,0x07,0x2A,0x00,0x8C,0x0F,0x7A,0x25,0x50,0x88,0x50,0x5F,0x8C,0xAB,0x0A,0x7A,0xCC,0x10,0xC4,0x25,0x10,0xB3,0xCE,0x5F,0x40,0xA1,0x8A,0x05,0xD0,0x90,0x14,0x7E,0x00,0x09,0xCA,0x7F,0xA0,0x1B,0xDE,0x00,0x70,0x12,0x14,0x7D,0x50,0x2A,0xC0,0x7D,0x20,0x14,0x30,0x04,0x4C,0x3C,0xF0,0x02,0xEC,0x28,0x60,0x45,0xA0,0x04,0x04,0x47,0x1C,0x22,0x70,0x02,0xE0,0x26,0xF4,0x41,0xFC,0x04,0x84,0x04,0x9C,0x0A,0xB0,0x41,0x40,0x25,0x0C,0xBF,0x9C,0x2F,0x3C,0xF8,0x5C,0x0A,0x18,0x4A,0xC0,0x21,0x00,0xB2,0x80,0x58,0x9C,0x8A,0x00,0x79,0xBC,0x7D,0x00,0x10,0x28,0x3E,0x3C,0x46,0x94,0x7D,0xB8,0x21,0x20,0x42,0x04,0x77,0xB4,0xB7,0x84,0x53,0x94,0x03,0xA0,0x20,0x08,0xF4,0x00,0x47,0x34,0xF7,0x60,0x63,0x3C,0x01,0xC0,0x24,0x08,0xF3,0xA0,0x11,0xA0,0xF3,0x60,0x68,0x48,0x08,0xB8,0x7D,0xE8,0x0D,0xF8,0x14,0xE0,0x83,0xC0,0x48,0x00,0x8E,0xB8,0x91,0xC8,0x05,0x40,0xD8,0xC8,0x8B,0xF8,0xC9,0x00,0x0D,0x38,0x04,0x68,0x86,0x80,0x9A,0x11,0x7B,0xB8,0x9F,0x79,0xF8,0x38,0x05,0x38,0x99,0x80,0xD2,0x01,0x69,0x80,0x24,0x71,0x14,0x80,0xF6,0x30,0xFE,0x80,0x72,0x41,0xE9,0x00,0x01,0x19,0x17,0x80,0xE6,0x81,0xEA,0x40,0x67,0xD8,0xFD,0xC0,0x81,0x48,0x1E,0xF0,0x34,0x81,0x13,0x30,0x09,0x19,0x8D,0xC8,0xBD,0x88,0x84,0xF8,0x9C,0x90,0x1C,0x00,0x00,0x41,0x8C,0x78,0x39,0xA9,0x12,0x30,0x19,0xF8,0x87,0x48
ee12b079 86:a26f5f22631d 64 // actual data 0x18,0x00,0x00,0x00,0x1C,0x44,0x10,0x04,0x01,0xE0,0x44,0x10,0x04,0x01,0xE0,0x44,0x10,0x04,0x01,0xE0,0x44,0x10,0x04,0x01,0xE0,0x44,0x10,0x04,0x01,0xE0,0x44,0x10,0x40,0x00,0x00,0x00,0x00,0x01,0x40,0x82,0x41,0x20,0x10,0x08,0x04,0x02,0x01,0xE4,0x3A,0x28,0x22,0x3A,0x28,0x22,0x3A,0x28,0x22,0x41,0x10,0x04,0x01,0xE4,0x40,0x20,0x10,0x08,0x04,0x01,0xE4,0x41,0x10,0x04,0x01,0xE4,0x41,0x10,0x04,0x01,0xE4,0x41,0x10,0x04,0x01,0xE4,0x41,0x10,0x04,0x01,0xE4,0x41,0x10,0x04,0x01,0xE4,0x41,0x10,0x40,0x00,0x00,0x00,0x00,0x01,0x48,0x82,0x41,0x20,0x10,0x08,0x04,0x02,0x01,0xE8,0x04,0x28,0x22,0x04,0x28,0x22,0x04,0x28,0x22,0x42,0x10,0x04,0x01,0xE8,0x40,0x20,0x10,0x08,0x04,0x01,0x00,0x00,
ee12b079 86:a26f5f22631d 65 //const unsigned char S_frame[] = {0x46,0x9D,0xFB,0xF0,0xD2,0xBA,0x89,0xE4,0x46,0x9D,0xFB,0xF0,0xD2,0xBA,0x89,0xE4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
ee12b079 86:a26f5f22631d 66 //const unsigned char EoS[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x1A,0x77,0xEF,0xC3,0x4A,0xEA,0x27,0x91,0x1A,0x77,0xEF,0xC3,0x4A,0xEA,0x27,0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x1A,0x77,0xEF,0xC3,0x4A,0xEA,0x27,0x91,0x1A,0x77,0xEF,0xC3,0x4A,0xEA,0x27,0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
krishanprajapat 119:2b5632bc78ab 67 //unsigned char call_sign_buffer[318]={0x0A,0x3F,0x46,0xB4,0x00,0x38,0x90,0x7B,0x40,0x01,0x56,0x45,0xE0,0x3C,0xA0,0x7A,0x90,0x3D,0xE6,0x3E,0x70,0x21,0x42,0x43,0x3C,0x0C,0x20,0x00,0x4C,0x83,0x12,0x67,0xF0,0x8F,0x36,0x60,0x3C,0x86,0x24,0x06,0x80,0x20,0x54,0x22,0x9C,0x07,0x2A,0x00,0x8C,0x0F,0x7A,0x25,0x50,0x88,0x50,0x5F,0x8C,0xAB,0x0A,0x7A,0xCC,0x10,0xC4,0x25,0x10,0xB3,0xCE,0x5F,0x40,0xA1,0x8A,0x05,0xD0,0x90,0x14,0x7E,0x00,0x09,0xCA,0x7F,0xA0,0x1B,0xDE,0x00,0x70,0x12,0x14,0x7D,0x50,0x2A,0xC0,0x7D,0x20,0x14,0x30,0x04,0x4C,0x3C,0xF0,0x02,0xEC,0x28,0x60,0x45,0xA0,0x04,0x04,0x47,0x1C,0x22,0x70,0x02,0xE0,0x26,0xF4,0x41,0xFC,0x04,0x84,0x04,0x9C,0x0A,0xB0,0x41,0x40,0x25,0x0C,0xBF,0x9C,0x2F,0x3C,0xF8,0x5C,0x0A,0x18,0x4A,0xC0,0x21,0x00,0xB2,0x80,0x58,0x9C,0x8A,0x00,0x79,0xBC,0x7D,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0A,0x3F,0x46,0xB4,0x00,0x10,0x28,0x3E,0x3C,0x46,0x94,0x7D,0xB8,0x21,0x20,0x42,0x04,0x77,0xB4,0xB7,0x84,0x53,0x94,0x03,0xA0,0x20,0x08,0xF4,0x00,0x47,0x34,0xF7,0x60,0x63,0x3C,0x01,0xC0,0x24,0x08,0xF3,0xA0,0x11,0xA0,0xF3,0x60,0x68,0x48,0x08,0xB8,0x7D,0xE8,0x0D,0xF8,0x14,0xE0,0x83,0xC0,0x48,0x00,0x8E,0xB8,0x91,0xC8,0x05,0x40,0xD8,0xC8,0x8B,0xF8,0xC9,0x00,0x0D,0x38,0x04,0x68,0x86,0x80,0x9A,0x11,0x7B,0xB8,0x9F,0x79,0xF8,0x38,0x05,0x38,0x99,0x80,0xD2,0x01,0x69,0x80,0x24,0x71,0x14,0x80,0xF6,0x30,0xFE,0x80,0x72,0x41,0xE9,0x00,0x01,0x19,0x17,0x80,0xE6,0x81,0xEA,0x40,0x67,0xD8,0xFD,0xC0,0x81,0x48,0x1E,0xF0,0x34,0x81,0x13,0x30,0x09,0x19,0x8D,0xC8,0xBD,0x88,0x84,0xF8,0x9C,0x90,0x1C,0x00,0x00,0x41,0x8C,0x78,0x39,0xA9,0x12,0x30,0x19,0xF8,0x87,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
ee12b079 86:a26f5f22631d 68 //0x00,0x0A,0x3F,0x46,0xB4,0x00,0x38,0x90,0x7B,0x40,0x01,0x56,0x45,0xE0,0x3C,0xA0,0x7A,0x90,0x3D,0xE6,0x3E,0x70,0x21,0x42,0x43,0x3C,0x0C,0x20,0x00,0x4C,0x83,0x12,0x67,0xF0,0x8F,0x36,0x60,0x3C,0x86,0x24,0x06,0x80,0x20,0x54,0x22,0x9C,0x07,0x2A,0x00,0x8C,0x0F,0x7A,0x25,0x50,0x88,0x50,0x5F,0x8C,0xAB,0x0A,0x7A,0xCC,0x10,0xC4,0x25,0x10,0xB3,0xCE,0x5F,0x40,0xA1,0x8A,0x05,0xD0,0x90,0x14,0x7E,0x00,0x09,0xCA,0x7F,0xA0,0x1B,0xDE,0x00,0x70,0x12,0x14,0x7D,0x50,0x2A,0xC0,0x7D,0x20,0x14,0x30,0x04,0x4C,0x3C,0xF0,0x02,0xEC,0x28,0x60,0x45,0xA0,0x04,0x04,0x47,0x1C,0x22,0x70,0x02,0xE0,0x26,0xF4,0x41,0xFC,0x04,0x84,0x04,0x9C,0x0A,0xB0,0x41,0x40,0x25,0x0C,0xBF,0x9C,0x2F,0x3C,0xF8,0x5C,0x0A,0x18,0x4A,0xC0,0x21,0x00,0xB2,0x80,0x58,0x9C,0x8A,0x00,0x79,0xBC,0x7D,0x00,0x10,0x28,0x3E,0x3C,0x46,0x94,0x7D,0xB8,0x21,0x20,0x42,0x04,0x77,0xB4,0xB7,0x84,0x53,0x94,0x03,0xA0,0x20,0x08,0xF4,0x00,0x47,0x34,0xF7,0x60,0x63,0x3C,0x01,0xC0,0x24,0x08,0xF3,0xA0,0x11,0xA0,0xF3,0x60,0x68,0x48,0x08,0xB8,0x7D,0xE8,0x0D,0xF8,0x14,0xE0,0x83,0xC0,0x48,0x00,0x8E,0xB8,0x91,0xC8,0x05,0x40,0xD8,0xC8,0x8B,0xF8,0xC9,0x00,0x0D,0x38,0x04,0x68,0x86,0x80,0x9A,0x11,0x7B,0xB8,0x9F,0x79,0xF8,0x38,0x05,0x38,0x99,0x80,0xD2,0x01,0x69,0x80,0x24,0x71,0x14,0x80,0xF6,0x30,0xFE,0x80,0x72,0x41,0xE9,0x00,0x01,0x19,0x17,0x80,0xE6,0x81,0xEA,0x40,0x67,0xD8,0xFD,0xC0,0x81,0x48,0x1E,0xF0,0x34,0x81,0x13,0x30,0x09,0x19,0x8D,0xC8,0xBD,0x88,0x84,0xF8,0x9C,0x90,0x1C,0x00,0x00,0x41,0x8C,0x78,0x39,0xA9,0x12,0x30,0x19,0xF8,0x87,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
ee12b079 86:a26f5f22631d 69 uint8_t buffer_512[512];
krishanprajapat 123:457d6fd9ac37 70 //unsigned char Ack_andcallsign[318]={0x0A,0x3F,0x46,0xB4,0x00,0x38,0x90,0x7B,0x40,0x01,0x56,0x45,0xE0,0x3C,0xA0,0x7A,0x90,0x3D,0xE6,0x3E,0x70,0x21,0x42,0x43,0x3C,0x0C,0x20,0x00,0x4C,0x83,0x12,0x67,0xF0,0x8F,0x36,0x60,0x3C,0x86,0x24,0x06,0x80,0x20,0x54,0x22,0x9C,0x07,0x2A,0x00,0x8C,0x0F,0x7A,0x25,0x50,0x88,0x50,0x5F,0x8C,0xAB,0x0A,0x7A,0xCC,0x10,0xC4,0x25,0x10,0xB3,0xCE,0x5F,0x40,0xA1,0x8A,0x05,0xD0,0x90,0x14,0x7E,0x00,0x09,0xCA,0x7F,0xA0,0x1B,0xDE,0x00,0x70,0x12,0x14,0x7D,0x50,0x2A,0xC0,0x7D,0x20,0x14,0x30,0x04,0x4C,0x3C,0xF0,0x02,0xEC,0x28,0x60,0x45,0xA0,0x04,0x04,0x47,0x1C,0x22,0x70,0x02,0xE0,0x26,0xF4,0x41,0xFC,0x04,0x84,0x04,0x9C,0x0A,0xB0,0x41,0x40,0x25,0x0C,0xBF,0x9C,0x2F,0x3C,0xF8,0x5C,0x0A,0x18,0x4A,0xC0,0x21,0x00,0xB2,0x80,0x58,0x9C,0x8A,0x00,0x79,0xBC,0x7D,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0A,0x3F,0x46,0xB4,0x00,0x10,0x28,0x3E,0x3C,0x46,0x94,0x7D,0xB8,0x21,0x20,0x42,0x04,0x77,0xB4,0xB7,0x84,0x53,0x94,0x03,0xA0,0x20,0x08,0xF4,0x00,0x47,0x34,0xF7,0x60,0x63,0x3C,0x01,0xC0,0x24,0x08,0xF3,0xA0,0x11,0xA0,0xF3,0x60,0x68,0x48,0x08,0xB8,0x7D,0xE8,0x0D,0xF8,0x14,0xE0,0x83,0xC0,0x48,0x00,0x8E,0xB8,0x91,0xC8,0x05,0x40,0xD8,0xC8,0x8B,0xF8,0xC9,0x00,0x0D,0x38,0x04,0x68,0x86,0x80,0x9A,0x11,0x7B,0xB8,0x9F,0x79,0xF8,0x38,0x05,0x38,0x99,0x80,0xD2,0x01,0x69,0x80,0x24,0x71,0x14,0x80,0xF6,0x30,0xFE,0x80,0x72,0x41,0xE9,0x00,0x01,0x19,0x17,0x80,0xE6,0x81,0xEA,0x40,0x67,0xD8,0xFD,0xC0,0x81,0x48,0x1E,0xF0,0x34,0x81,0x13,0x30,0x09,0x19,0x8D,0xC8,0xBD,0x88,0x84,0xF8,0x9C,0x90,0x1C,0x00,0x00,0x41,0x8C,0x78,0x39,0xA9,0x12,0x30,0x19,0xF8,0x87,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
ee12b079 86:a26f5f22631d 71 uint32_t list_of_FSC[43]={0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x40,0x41,0x42,0x43};
ee12b079 142:83f48d1a1bc5 72 uint8_t write_buffer[512] = {0x38,0x90,0x7B,0x40,0x01,0x56,0x45,0xE0,0x3C,0xA0,0x7A,0x90,0x3D,0xE6,0x3E,0x70,0x21,0x42,0x43,0x3C,0x0C,0x20,0x00,0x4C,0x83,0x12,0x67,0xF0,0x8F,0x36,0x60,0x3C,0x86,0x24,0x06,0x80,0x20,0x54,0x22,0x9C,0x07,0x2A,0x00,0x8C,0x0F,0x7A,0x25,0x50,0x88,0x50,0x5F,0x8C,0xAB,0x0A,0x7A,0xCC,0x10,0xC4,0x25,0x10,0xB3,0xCE,0x5F,0x40,0xA1,0x8A,0x05,0xD0,0x90,0x14,0x7E,0x00,0x09,0xCA,0x7F,0xA0,0x1B,0xDE,0x00,0x70,0x12,0x14,0x7D,0x50,0x2A,0xC0,0x7D,0x20,0x14,0x30,0x04,0x4C,0x3C,0xF0,0x02,0xEC,0x28,0x60,0x45,0xA0,0x04,0x04,0x47,0x1C,0x22,0x70,0x02,0xE0,0x26,0xF4,0x41,0xFC,0x04,0x84,0x04,0x9C,0x0A,0xB0,0x41,0x40,0x25,0x0C,0xBF,0x9C,0x2F,0x3C,0xF8,0x5C,0x0A,0x18,0x4A,0xC0,0x21,0x00,0xB2,0x80,0x58,0x9C,0x8A,0x00,0x79,0xBC,0x7D,0x00,0x10,0x28,0x3E,0x3C,0x46,0x94,0x7D,0xB8,0x21,0x20,0x42,0x04,0x77,0xB4,0xB7,0x84,0x53,0x94,0x03,0xA0,0x20,0x08,0xF4,0x00,0x47,0x34,0xF7,0x60,0x63,0x3C,0x01,0xC0,0x24,0x08,0xF3,0xA0,0x11,0xA0,0xF3,0x60,0x68,0x48,0x08,0xB8,0x7D,0xE8,0x0D,0xF8,0x14,0xE0,0x83,0xC0,0x48,0x00,0x8E,0xB8,0x91,0xC8,0x05,0x40,0xD8,0xC8,0x8B,0xF8,0xC9,0x00,0x0D,0x38,0x04,0x68,0x86,0x80,0x9A,0x11,0x7B,0xB8,0x9F,0x79,0xF8,0x38,0x05,0x38,0x99,0x80,0xD2,0x01,0x69,0x80,0x24,0x71,0x14,0x80,0xF6,0x30,0xFE,0x80,0x72,0x41,0xE9,0x00,0x01,0x19,0x17,0x80,0xE6,0x81,0xEA,0x40,0x67,0xD8,0xFD,0xC0,0x81,0x48,0x1E,0xF0,0x34,0x81,0x13,0x30,0x09,0x19,0x8D,0xC8,0xBD,0x88,0x84,0xF8,0x9C,0x90,0x1C,0x00,0x00,0x41,0x8C,0x78,0x39,0xA9,0x12,0x30,0x19,0xF8,0x87,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
ee12b079 86:a26f5f22631d 73 //const unsigned char EXOR_SEQ[] = {0x55,0xF1,0x51,0x3D,0xA7,0x42,0xAE,0x2E,0x2E,0x28,0x76,0x80,0x62,0x41,0xC4,0x75,0x4D,0x87,0xDB,0xE1,0x02,0x61,0x60,0x96,0x9C,0xCB,0x8A,0xBD,0x37,0xE4,0x72,0x5D,0xF2,0x19,0x62,0x06,0x9A,0xF9,0x38,0xB0,0x49,0x75,0xD0,0x17,0x1B,0xCC,0x0B,0xEB,0x1B,0x50,0xA2,0x2A,0x8E,0xFA,0x4D,0x6F,0x1B,0xF8,0x0F,0x97,0x39,0x25,0x60,0x55,0x9A,0xDF,0x1D,0x10,0x7F,0xBD,0x3E,0xBF,0xE5,0x68,0x02,0xD1,0x99,0x0D,0xDF,0x84,0x2E,0x15,0xE3,0x08,0xD7,0x44,0x10,0x41,0xCE,0x93,0xF6,0x59,0x71,0xD2,0xF7,0x1C,0x4A,0x44,0x2D,0xA9,0x44,0x98,0x3A,0x00,0x71,0xCC,0x2A,0x35,0xC1,0x81,0xCF,0x44,0xF7,0x6A,0x0E,0xE4,0xF2,0xFC,0xD6,0x0B,0xA8,0x95,0x7B,0x86,0xB5,0xF8,0x33,0xE9,0xBF,0x6A,0x0E,0xE6,0x53,0x82};
ee12b079 86:a26f5f22631d 74 //const unsigned char FCCH80[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
ee12b079 86:a26f5f22631d 75 //const unsigned char SCH40[] = {0x0a,0x3f,0x46,0xb4,0x00};
ee12b079 86:a26f5f22631d 76
ee12b079 86:a26f5f22631d 77
krishanprajapat 127:8a7bee7b8e8b 78 #define get_ack_l234( tm_ptr ) {\
ee12b079 86:a26f5f22631d 79 Base_tm *ackl234new = new Short_tm;\
ee12b079 86:a26f5f22631d 80 ackl234new->next_TM = NULL;\
krishanprajapat 127:8a7bee7b8e8b 81 tm_ptr = ackl234new;\
ee12b079 86:a26f5f22631d 82 /*return telemetry pointer here*/\
ee12b079 86:a26f5f22631d 83 ackl234new->TM_string[0] = TMID_ACK_L234 << 4;\
krishanprajapat 127:8a7bee7b8e8b 84 ackl234new->TM_string[1] = GETpacket_seq_count(current_obsrs_tc);\
ee12b079 86:a26f5f22631d 85 ackl234new->TM_string[2] = ack_code; /* Ack code ....to be chnaged accordind to situation */\
ee12b079 86:a26f5f22631d 86 for(int i = 3; i < 11; ++i){\
ee12b079 86:a26f5f22631d 87 ackl234new->TM_string[i] = 0x00;\
ee12b079 86:a26f5f22631d 88 }\
ee12b079 86:a26f5f22631d 89 uint16_t crc = crc16_gen(ackl234new->TM_string, TM_SHORT_SIZE-2);\
ee12b079 86:a26f5f22631d 90 ackl234new->TM_string[11] = (crc & 0xFF00) >> 8;\
ee12b079 142:83f48d1a1bc5 91 ackl234new->TM_string[12] = crc & 0x00FF;\
ee12b079 86:a26f5f22631d 92 }
ee12b079 86:a26f5f22631d 93
ee12b079 86:a26f5f22631d 94 void restart_adf(){
ee12b079 199:9f03d6ca94c9 95 /*go to phy off and and py on then phy TX again */
ee12b079 199:9f03d6ca94c9 96 gCS_ADF = 0;
ee12b079 199:9f03d6ca94c9 97 spi.write(0xB1);/*phy_on */
ee12b079 199:9f03d6ca94c9 98 gCS_ADF = 1;
ee12b079 199:9f03d6ca94c9 99 gCS_ADF = 0;
ee12b079 199:9f03d6ca94c9 100 spi.write(0xB0);/*phy_off */
ee12b079 199:9f03d6ca94c9 101 gCS_ADF = 1;
ee12b079 199:9f03d6ca94c9 102 gCS_ADF = 0;
ee12b079 199:9f03d6ca94c9 103 spi.write(0xB1);/*phy_on */
ee12b079 199:9f03d6ca94c9 104 gCS_ADF = 1;
ee12b079 199:9f03d6ca94c9 105 gCS_ADF = 0;
ee12b079 199:9f03d6ca94c9 106 spi.write(0xB5);/*start transmission*/
ee12b079 199:9f03d6ca94c9 107 gCS_ADF = 1;
ee12b079 86:a26f5f22631d 108 }
ee12b079 86:a26f5f22631d 109
ee12b079 86:a26f5f22631d 110 int diff_prev;
ee12b079 86:a26f5f22631d 111 void differential_encode(unsigned char* ptr, int length){
ee12b079 86:a26f5f22631d 112 for(int i=0; i<length;i++){
ee12b079 86:a26f5f22631d 113 unsigned char s = ptr[i] , t;
ee12b079 86:a26f5f22631d 114 t = s ^ (s >> 1);
ee12b079 86:a26f5f22631d 115 (diff_prev == 0) ? t=t^0x00 : t=t^0x80 ;
ee12b079 86:a26f5f22631d 116 diff_prev = int(s & 0x01);
ee12b079 86:a26f5f22631d 117 ptr[i] = t;
ee12b079 86:a26f5f22631d 118 }
ee12b079 86:a26f5f22631d 119 }
ee12b079 86:a26f5f22631d 120
ee12b079 86:a26f5f22631d 121 #define check_PA_temp {\
ee12b079 199:9f03d6ca94c9 122 /* pending temperature check function*/\
ee12b079 199:9f03d6ca94c9 123 /* return 0 or 1*/\
ee12b079 86:a26f5f22631d 124 PA_HOT=0;\
ee12b079 86:a26f5f22631d 125 }
ee12b079 86:a26f5f22631d 126
ee12b079 86:a26f5f22631d 127
krishanprajapat 121:bd7263168ee4 128 #define flags_init {\
krishanprajapat 121:bd7263168ee4 129 send_EoS_and_stop = false; \
krishanprajapat 121:bd7263168ee4 130 adf_limit = false;\
krishanprajapat 121:bd7263168ee4 131 stop = false;\
krishanprajapat 121:bd7263168ee4 132 PA_HOT=0;\
krishanprajapat 121:bd7263168ee4 133 short_TC;\
krishanprajapat 121:bd7263168ee4 134 valid_SID = true;\
krishanprajapat 121:bd7263168ee4 135 enable_call_sign = true;\
krishanprajapat 121:bd7263168ee4 136 enable_new_segment=true;\
krishanprajapat 121:bd7263168ee4 137 enable_S_frame = true;\
krishanprajapat 121:bd7263168ee4 138 enable_read_block = false;\
krishanprajapat 121:bd7263168ee4 139 enable_T_frame = false;\
krishanprajapat 121:bd7263168ee4 140 enable_Ack_andcallsign = false;\
krishanprajapat 121:bd7263168ee4 141 enable_ackandcallsign = false;\
krishanprajapat 121:bd7263168ee4 142 new_session =true;\
krishanprajapat 121:bd7263168ee4 143 enable_EoS=false;\
krishanprajapat 121:bd7263168ee4 144 create_Ack_andcallsign = true;\
krishanprajapat 121:bd7263168ee4 145 Ack_andcallsign_over = false;\
krishanprajapat 121:bd7263168ee4 146 repeat_last_2T_frames = false;\
krishanprajapat 121:bd7263168ee4 147 last_block = false;\
krishanprajapat 121:bd7263168ee4 148 last_buffer = false;\
krishanprajapat 121:bd7263168ee4 149 new_OBSRS_TC = true;\
krishanprajapat 121:bd7263168ee4 150 enable_SCH = true;\
krishanprajapat 121:bd7263168ee4 151 enable_FCCH = false;\
krishanprajapat 121:bd7263168ee4 152 enable_DS = false;\
krishanprajapat 121:bd7263168ee4 153 half_buffer = 0;\
ee12b079 199:9f03d6ca94c9 154 read_success = false;\
krishanprajapat 121:bd7263168ee4 155 counter_buffer_112=0;\
krishanprajapat 121:bd7263168ee4 156 counter_EoS=0;\
krishanprajapat 121:bd7263168ee4 157 T_frames_sent=0;\
krishanprajapat 123:457d6fd9ac37 158 counter_interleavedata=0;\
krishanprajapat 121:bd7263168ee4 159 counter_buffer_512=0;\
krishanprajapat 121:bd7263168ee4 160 ack_code = 0xA0;\
krishanprajapat 121:bd7263168ee4 161 segments_sent = 0;\
krishanprajapat 121:bd7263168ee4 162 counter_SCH40 = 0;\
krishanprajapat 121:bd7263168ee4 163 counter_FCCH80 = 0;\
krishanprajapat 121:bd7263168ee4 164 counter_S_frame = 0;\
krishanprajapat 121:bd7263168ee4 165 T_frame_Ack_andcallsign_sent = 0;\
ee12b079 143:d81df402a016 166 T_frame_in_Ackandcallsign ;\
krishanprajapat 121:bd7263168ee4 167 block_counter = 0;\
krishanprajapat 121:bd7263168ee4 168 no_of_frames =0;\
krishanprajapat 121:bd7263168ee4 169 }
krishanprajapat 121:bd7263168ee4 170
krishanprajapat 123:457d6fd9ac37 171 #define send_Ack_andcallsign {\
ee12b079 86:a26f5f22631d 172 if(T_frames_sent < T_frames_in_segment){\
krishanprajapat 123:457d6fd9ac37 173 if (enable_SCH)\
krishanprajapat 123:457d6fd9ac37 174 {\
krishanprajapat 123:457d6fd9ac37 175 buffer_112[counter_buffer_112] = SCH40[counter_SCH40++];\
krishanprajapat 123:457d6fd9ac37 176 if (counter_SCH40 == 5)\
krishanprajapat 123:457d6fd9ac37 177 { \
ee12b079 201:3410fc4d80f0 178 gPC.printf("Asch40 sent\r\n");\
krishanprajapat 123:457d6fd9ac37 179 counter_SCH40 = 0;\
krishanprajapat 123:457d6fd9ac37 180 enable_SCH = false;\
krishanprajapat 123:457d6fd9ac37 181 enable_DS = true;\
krishanprajapat 123:457d6fd9ac37 182 }\
krishanprajapat 123:457d6fd9ac37 183 }\
krishanprajapat 123:457d6fd9ac37 184 else if (enable_DS)\
krishanprajapat 123:457d6fd9ac37 185 {\
krishanprajapat 123:457d6fd9ac37 186 buffer_112[counter_buffer_112] = interleave_data[half_buffer][counter_interleavedata++];\
krishanprajapat 123:457d6fd9ac37 187 if (counter_interleavedata == 144)\
krishanprajapat 123:457d6fd9ac37 188 { \
ee12b079 201:3410fc4d80f0 189 gPC.printf("Ads sent %d\r\n",half_buffer);\
krishanprajapat 123:457d6fd9ac37 190 enable_DS = false;\
krishanprajapat 123:457d6fd9ac37 191 enable_FCCH = true;\
ee12b079 143:d81df402a016 192 counter_interleavedata = 0;\
krishanprajapat 123:457d6fd9ac37 193 }\
krishanprajapat 123:457d6fd9ac37 194 }\
krishanprajapat 123:457d6fd9ac37 195 else if (enable_FCCH)\
krishanprajapat 123:457d6fd9ac37 196 {\
krishanprajapat 123:457d6fd9ac37 197 buffer_112[counter_buffer_112] = FCCH80[counter_FCCH80++];\
krishanprajapat 123:457d6fd9ac37 198 if (counter_FCCH80 == 10)\
krishanprajapat 123:457d6fd9ac37 199 {\
ee12b079 201:3410fc4d80f0 200 gPC.printf("Afcch80 sent\r\n");\
krishanprajapat 123:457d6fd9ac37 201 enable_FCCH = false;\
ee12b079 143:d81df402a016 202 counter_FCCH80 = 0;\
ee12b079 143:d81df402a016 203 enable_SCH = true;\
krishanprajapat 123:457d6fd9ac37 204 if(half_buffer == 0){\
krishanprajapat 123:457d6fd9ac37 205 half_buffer = 1;\
ee12b079 143:d81df402a016 206 }\
ee12b079 143:d81df402a016 207 else{\
ee12b079 143:d81df402a016 208 half_buffer =0;\
ee12b079 143:d81df402a016 209 TM_sent=true;\
krishanprajapat 123:457d6fd9ac37 210 }\
krishanprajapat 123:457d6fd9ac37 211 }\
krishanprajapat 123:457d6fd9ac37 212 }\
ee12b079 143:d81df402a016 213 if(TM_sent){\
ee12b079 143:d81df402a016 214 TM_sent =false;\
ee12b079 86:a26f5f22631d 215 T_frames_sent = T_frames_sent +2;\
ee12b079 86:a26f5f22631d 216 if(repeat_last_2T_frames){\
ee12b079 143:d81df402a016 217 enable_SCH = true;\
ee12b079 201:3410fc4d80f0 218 gPC.printf("repeated last 2 tframes\r\n");\
ee12b079 86:a26f5f22631d 219 /*cout<<"T_frames_sent = "<<T_frames_sent<<ENDL;*/\
ee12b079 86:a26f5f22631d 220 }\
ee12b079 86:a26f5f22631d 221 else{\
ee12b079 201:3410fc4d80f0 222 gPC.printf("Ackandcallsign sent");\
ee12b079 86:a26f5f22631d 223 /*cout<<"T_frames_sent = "<<T_frames_sent<<ENDL;*/\
ee12b079 86:a26f5f22631d 224 T_frame_Ack_andcallsign_sent = T_frame_Ack_andcallsign_sent + 2;\
ee12b079 86:a26f5f22631d 225 if(T_frame_Ack_andcallsign_sent == T_frame_in_Ackandcallsign ){\
ee12b079 86:a26f5f22631d 226 repeat_last_2T_frames = true;\
ee12b079 86:a26f5f22631d 227 }\
ee12b079 86:a26f5f22631d 228 else if(T_frame_Ack_andcallsign_sent < T_frame_in_Ackandcallsign){\
krishanprajapat 123:457d6fd9ac37 229 T_frame_in_Ackandcallsign = 2*snd_tm.make_shor_tm();\
krishanprajapat 122:b99f8be0a51a 230 enable_SCH = true;\
ee12b079 86:a26f5f22631d 231 }\
ee12b079 86:a26f5f22631d 232 else{\
ee12b079 143:d81df402a016 233 gPC.printf("error in send ack\r\n");\
ee12b079 86:a26f5f22631d 234 }\
ee12b079 86:a26f5f22631d 235 }\
ee12b079 86:a26f5f22631d 236 if(T_frames_sent == T_frames_in_segment){\
ee12b079 86:a26f5f22631d 237 if(T_frame_Ack_andcallsign_sent < T_frame_in_Ackandcallsign){\
ee12b079 86:a26f5f22631d 238 if(segments_sent + 1>= max_segments){\
ee12b079 86:a26f5f22631d 239 adf_limit = true;\
ee12b079 86:a26f5f22631d 240 segments_sent = 0;\
ee12b079 201:3410fc4d80f0 241 gPC.printf("adf limit reached");\
ee12b079 86:a26f5f22631d 242 }\
ee12b079 86:a26f5f22631d 243 else{\
ee12b079 86:a26f5f22631d 244 enable_new_segment = true;\
ee12b079 201:3410fc4d80f0 245 gPC.printf("new segment");\
ee12b079 86:a26f5f22631d 246 }\
ee12b079 86:a26f5f22631d 247 }\
ee12b079 86:a26f5f22631d 248 else{\
krishanprajapat 122:b99f8be0a51a 249 send_EoS_and_stop = true; \
ee12b079 143:d81df402a016 250 }\
ee12b079 86:a26f5f22631d 251 }\
ee12b079 86:a26f5f22631d 252 }\
ee12b079 86:a26f5f22631d 253 }\
ee12b079 86:a26f5f22631d 254 else if(send_EoS_and_stop){\
ee12b079 86:a26f5f22631d 255 buffer_112[counter_buffer_112] = EoS[counter_EoS++];\
ee12b079 86:a26f5f22631d 256 if(counter_EoS == 120){\
ee12b079 201:3410fc4d80f0 257 gPC.printf("A eos sent\r\n");\
ee12b079 86:a26f5f22631d 258 /*cout<<"EoS sent"<<ENDL;*/\
ee12b079 86:a26f5f22631d 259 counter_EoS = 0;\
ee12b079 86:a26f5f22631d 260 enable_ackandcallsign = false;\
ee12b079 86:a26f5f22631d 261 stop =true;\
ee12b079 86:a26f5f22631d 262 last_buffer = true;\
ee12b079 199:9f03d6ca94c9 263 send_EoS_and_stop = false;\
ee12b079 86:a26f5f22631d 264 }\
ee12b079 86:a26f5f22631d 265 }\
ee12b079 86:a26f5f22631d 266 else if(adf_limit){\
ee12b079 86:a26f5f22631d 267 buffer_112[counter_buffer_112] = EoS[counter_EoS++];\
ee12b079 86:a26f5f22631d 268 if(counter_EoS == 120){\
ee12b079 86:a26f5f22631d 269 counter_EoS = 0;\
ee12b079 201:3410fc4d80f0 270 gPC.printf("EoS sent");\
ee12b079 86:a26f5f22631d 271 restart_adf();\
ee12b079 86:a26f5f22631d 272 enable_new_segment = true;\
ee12b079 86:a26f5f22631d 273 /*cout<<"new session"<<ENDL;*/\
ee12b079 86:a26f5f22631d 274 /*cout<<"new segment"<<ENDL;*/\
ee12b079 86:a26f5f22631d 275 T_frames_sent = 0;\
ee12b079 86:a26f5f22631d 276 segments_sent = 0; \
ee12b079 86:a26f5f22631d 277 adf_limit = false;\
ee12b079 86:a26f5f22631d 278 }\
ee12b079 86:a26f5f22631d 279 }\
ee12b079 86:a26f5f22631d 280 else{\
ee12b079 86:a26f5f22631d 281 gPC.printf("error in send_Ack_andcallsign()");\
ee12b079 86:a26f5f22631d 282 }\
ee12b079 86:a26f5f22631d 283 }
ee12b079 86:a26f5f22631d 284 #define send_S_frame {\
ee12b079 86:a26f5f22631d 285 buffer_112[counter_buffer_112] = S_frame[counter_S_frame++];\
ee12b079 86:a26f5f22631d 286 if(counter_S_frame == 48){\
ee12b079 86:a26f5f22631d 287 enable_new_segment=false;\
ee12b079 86:a26f5f22631d 288 counter_S_frame = 0;\
ee12b079 200:05ff11766d9a 289 /*gPC.printf("S_frame_sent\r\n");*/\
ee12b079 86:a26f5f22631d 290 if(new_OBSRS_TC){\
ee12b079 86:a26f5f22631d 291 enable_call_sign = true;\
krishanprajapat 127:8a7bee7b8e8b 292 new_OBSRS_TC = false;\
krishanprajapat 118:60c5de4cb8ad 293 get_call_sign(callsign);\
ee12b079 142:83f48d1a1bc5 294 snd_tm.head_pointer_sdcard(callsign);\
ee12b079 139:1018e1dc82e9 295 int temp = snd_tm.make_shor_tm();\
krishanprajapat 127:8a7bee7b8e8b 296 delete callsign;\
krishanprajapat 148:46763854fa83 297 /*gPC.printf("new tc\r\n");*/\
ee12b079 86:a26f5f22631d 298 }\
ee12b079 86:a26f5f22631d 299 else{\
ee12b079 142:83f48d1a1bc5 300 if(!enable_ackandcallsign){\
ee12b079 86:a26f5f22631d 301 enable_read_block = true;\
ee12b079 142:83f48d1a1bc5 302 }\
ee12b079 86:a26f5f22631d 303 }\
ee12b079 86:a26f5f22631d 304 }\
ee12b079 86:a26f5f22631d 305 }
ee12b079 86:a26f5f22631d 306
ee12b079 86:a26f5f22631d 307 #define send_call_sign {\
krishanprajapat 119:2b5632bc78ab 308 if (enable_SCH)\
krishanprajapat 119:2b5632bc78ab 309 {\
krishanprajapat 119:2b5632bc78ab 310 buffer_112[counter_buffer_112] = SCH40[counter_SCH40++];\
krishanprajapat 119:2b5632bc78ab 311 if (counter_SCH40 == 5)\
krishanprajapat 119:2b5632bc78ab 312 { \
krishanprajapat 119:2b5632bc78ab 313 counter_SCH40 = 0;\
krishanprajapat 148:46763854fa83 314 /*gPC.printf("csch40 sent\r\n");*/\
krishanprajapat 119:2b5632bc78ab 315 enable_SCH = false;\
krishanprajapat 119:2b5632bc78ab 316 enable_DS = true;\
krishanprajapat 119:2b5632bc78ab 317 }\
krishanprajapat 119:2b5632bc78ab 318 }\
krishanprajapat 119:2b5632bc78ab 319 else if (enable_DS)\
krishanprajapat 119:2b5632bc78ab 320 {\
krishanprajapat 123:457d6fd9ac37 321 buffer_112[counter_buffer_112] = interleave_data[half_buffer][counter_interleavedata++];\
ee12b079 142:83f48d1a1bc5 322 /*gPC.printf("csending ds %d \r\n",counter_interleavedata);*/\
krishanprajapat 123:457d6fd9ac37 323 if (counter_interleavedata == 144)\
krishanprajapat 119:2b5632bc78ab 324 { \
krishanprajapat 119:2b5632bc78ab 325 enable_DS = false;\
krishanprajapat 119:2b5632bc78ab 326 enable_FCCH = true;\
ee12b079 146:d9ce37c49409 327 counter_interleavedata = 0;\
ee12b079 142:83f48d1a1bc5 328 /*counter_interleavedata = 0;not required here*/\
krishanprajapat 148:46763854fa83 329 /*gPC.printf("cds sent sent \r\n");*/\
krishanprajapat 119:2b5632bc78ab 330 }\
krishanprajapat 119:2b5632bc78ab 331 }\
krishanprajapat 119:2b5632bc78ab 332 else if (enable_FCCH)\
krishanprajapat 119:2b5632bc78ab 333 {\
krishanprajapat 119:2b5632bc78ab 334 buffer_112[counter_buffer_112] = FCCH80[counter_FCCH80++];\
krishanprajapat 119:2b5632bc78ab 335 if (counter_FCCH80 == 10)\
krishanprajapat 119:2b5632bc78ab 336 {\
krishanprajapat 119:2b5632bc78ab 337 enable_FCCH = false;\
ee12b079 146:d9ce37c49409 338 counter_FCCH80 = 0;\
krishanprajapat 148:46763854fa83 339 /*gPC.printf("cfcch sent\r\n");*/\
krishanprajapat 119:2b5632bc78ab 340 if(half_buffer == 0){\
krishanprajapat 119:2b5632bc78ab 341 enable_SCH = true;\
krishanprajapat 119:2b5632bc78ab 342 half_buffer = 1;\
ee12b079 146:d9ce37c49409 343 }\
ee12b079 146:d9ce37c49409 344 else{\
ee12b079 146:d9ce37c49409 345 half_buffer = 0;\
ee12b079 146:d9ce37c49409 346 TM_sent=true;\
krishanprajapat 119:2b5632bc78ab 347 }\
krishanprajapat 119:2b5632bc78ab 348 }\
krishanprajapat 119:2b5632bc78ab 349 }\
ee12b079 146:d9ce37c49409 350 if(TM_sent){\
ee12b079 146:d9ce37c49409 351 TM_sent= false;\
ee12b079 140:be4eea8275c3 352 enable_call_sign = false;\
ee12b079 86:a26f5f22631d 353 new_session =false;\
ee12b079 86:a26f5f22631d 354 /*cout<<"call_sign_sent"<<" ";*/\
ee12b079 86:a26f5f22631d 355 T_frames_sent = T_frames_sent+2;\
krishanprajapat 119:2b5632bc78ab 356 if(SID==0x1 || SID==0x2 || SID==0x3 || SID==0x4 || SID==0x5){\
ee12b079 86:a26f5f22631d 357 valid_SID=true;\
ee12b079 86:a26f5f22631d 358 /*cout<<"valid SID"<<ENDL;*/\
ee12b079 86:a26f5f22631d 359 }\
ee12b079 86:a26f5f22631d 360 else{\
ee12b079 86:a26f5f22631d 361 valid_SID=false;\
ee12b079 92:bce22b38c440 362 /*gPC.printf("invalid SID");*/\
ee12b079 86:a26f5f22631d 363 enable_ackandcallsign = true;\
ee12b079 86:a26f5f22631d 364 create_Ack_andcallsign = true;\
ee12b079 86:a26f5f22631d 365 ack_code = 0x02;\
ee12b079 86:a26f5f22631d 366 }\
ee12b079 86:a26f5f22631d 367 check_PA_temp;\
ee12b079 86:a26f5f22631d 368 /*cout<<"pa_hot = "<<PA_HOT<<ENDL;*/\
ee12b079 86:a26f5f22631d 369 if(PA_HOT){\
ee12b079 86:a26f5f22631d 370 enable_ackandcallsign = true;\
ee12b079 86:a26f5f22631d 371 create_Ack_andcallsign = true;\
ee12b079 86:a26f5f22631d 372 enable_read_block = false;\
ee12b079 86:a26f5f22631d 373 }\
ee12b079 86:a26f5f22631d 374 else{\
ee12b079 86:a26f5f22631d 375 enable_read_block = true;\
ee12b079 86:a26f5f22631d 376 enable_ackandcallsign = false;\
ee12b079 86:a26f5f22631d 377 }\
ee12b079 86:a26f5f22631d 378 }\
ee12b079 86:a26f5f22631d 379 }
ee12b079 86:a26f5f22631d 380
ee12b079 95:42d6747900cb 381 void send_tm_from_SD_card_fun(){
krishanprajapat 148:46763854fa83 382 /* gPC.printf("\n\rsend tm sd called\r\n");*/
ee12b079 86:a26f5f22631d 383 for(counter_buffer_112=0;counter_buffer_112<112;counter_buffer_112++){
ee12b079 86:a26f5f22631d 384 if(enable_new_segment){ // starting new segment
ee12b079 86:a26f5f22631d 385 send_S_frame;
ee12b079 86:a26f5f22631d 386 T_frames_sent=0;
ee12b079 86:a26f5f22631d 387 }
ee12b079 86:a26f5f22631d 388 else if(enable_call_sign){ // sending call sign
ee12b079 86:a26f5f22631d 389 send_call_sign ;
ee12b079 86:a26f5f22631d 390 }
ee12b079 86:a26f5f22631d 391 else if(enable_T_frame){
ee12b079 86:a26f5f22631d 392 if(read_success == 0){
ee12b079 86:a26f5f22631d 393 if(T_frames_sent < T_frames_in_segment){
ee12b079 86:a26f5f22631d 394 if (enable_SCH)
ee12b079 86:a26f5f22631d 395 {
ee12b079 86:a26f5f22631d 396 buffer_112[counter_buffer_112] = SCH40[counter_SCH40++];
ee12b079 86:a26f5f22631d 397 if (counter_SCH40 == 5)
ee12b079 86:a26f5f22631d 398 {
krishanprajapat 148:46763854fa83 399 /* gPC.printf("tsch40 sent\r\n");*/
ee12b079 86:a26f5f22631d 400 counter_SCH40 = 0;
ee12b079 86:a26f5f22631d 401 enable_SCH = false;
ee12b079 86:a26f5f22631d 402 enable_DS = true;
ee12b079 86:a26f5f22631d 403 }
ee12b079 86:a26f5f22631d 404 }
ee12b079 86:a26f5f22631d 405 else if (enable_DS)
ee12b079 86:a26f5f22631d 406 {
ee12b079 86:a26f5f22631d 407 buffer_112[counter_buffer_112] = buffer_512[counter_buffer_512++];
ee12b079 86:a26f5f22631d 408 if ((counter_buffer_512 == 288) || (counter_buffer_512 == 144))
ee12b079 86:a26f5f22631d 409 {
krishanprajapat 148:46763854fa83 410 /* gPC.printf("tds sent\r\n");*/
ee12b079 86:a26f5f22631d 411 // counter_buffer_512 = 0;
ee12b079 86:a26f5f22631d 412 enable_DS = false;
ee12b079 86:a26f5f22631d 413 enable_FCCH = true;
ee12b079 86:a26f5f22631d 414 }
ee12b079 86:a26f5f22631d 415 }
ee12b079 86:a26f5f22631d 416 else if (enable_FCCH)
ee12b079 86:a26f5f22631d 417 {
ee12b079 86:a26f5f22631d 418 buffer_112[counter_buffer_112] = FCCH80[counter_FCCH80++];
ee12b079 86:a26f5f22631d 419 if (counter_FCCH80 == 10)
ee12b079 86:a26f5f22631d 420 {
krishanprajapat 148:46763854fa83 421 /* gPC.printf("tfcch80 sent\r\n");*/
ee12b079 86:a26f5f22631d 422 enable_FCCH = false;
ee12b079 86:a26f5f22631d 423 if(counter_buffer_512 == 144){
ee12b079 86:a26f5f22631d 424 enable_SCH = true;
ee12b079 86:a26f5f22631d 425 counter_FCCH80 = 0;
ee12b079 86:a26f5f22631d 426 }
ee12b079 86:a26f5f22631d 427 else{
ee12b079 86:a26f5f22631d 428
ee12b079 86:a26f5f22631d 429 }
ee12b079 86:a26f5f22631d 430 }
ee12b079 86:a26f5f22631d 431 }
ee12b079 86:a26f5f22631d 432 if((counter_FCCH80 == 10)&&(counter_buffer_512 == 288)){
ee12b079 86:a26f5f22631d 433 counter_FCCH80 = 0;
ee12b079 86:a26f5f22631d 434 counter_buffer_512 = 0;
ee12b079 86:a26f5f22631d 435 T_frames_sent = T_frames_sent+2;
ee12b079 86:a26f5f22631d 436 // cout<<"T_frames_sent "<<T_frames_sent<<ENDL;
ee12b079 86:a26f5f22631d 437 if(last_block){
ee12b079 86:a26f5f22631d 438 // cout<<"last block"<<endl<<"\r";
krishanprajapat 148:46763854fa83 439 /* gPC.printf("last block\r\n");*/
ee12b079 86:a26f5f22631d 440 enable_read_block = false;
ee12b079 86:a26f5f22631d 441 enable_T_frame = false;
ee12b079 86:a26f5f22631d 442 enable_ackandcallsign = true;
ee12b079 199:9f03d6ca94c9 443 /*putting execution status */
ee12b079 199:9f03d6ca94c9 444 uint8_t temp2 = TC_STATE_SUCCESSFULLY_EXECUTED;
ee12b079 199:9f03d6ca94c9 445 PUTexec_status(current_obsrs_tc, temp2);
ee12b079 86:a26f5f22631d 446 create_Ack_andcallsign = true;
ee12b079 86:a26f5f22631d 447 if(T_frames_sent == T_frames_in_segment){
ee12b079 86:a26f5f22631d 448 if(segments_sent + 1>= max_segments){
ee12b079 86:a26f5f22631d 449 adf_limit = true;
ee12b079 86:a26f5f22631d 450 segments_sent = 0;
ee12b079 92:bce22b38c440 451 // gPC.printf("adf limit reached here");
ee12b079 86:a26f5f22631d 452 }
ee12b079 86:a26f5f22631d 453 else{
ee12b079 86:a26f5f22631d 454 enable_new_segment = true;
ee12b079 86:a26f5f22631d 455 // cout<<"new segment"<<ENDL;
ee12b079 86:a26f5f22631d 456 }
ee12b079 86:a26f5f22631d 457 }
ee12b079 86:a26f5f22631d 458 continue;
ee12b079 86:a26f5f22631d 459 }
ee12b079 86:a26f5f22631d 460 else{
ee12b079 86:a26f5f22631d 461 check_PA_temp;
ee12b079 86:a26f5f22631d 462 // cout<<"pa_hot = "<<PA_HOT<<" ";
ee12b079 86:a26f5f22631d 463 if(PA_HOT){
ee12b079 86:a26f5f22631d 464 enable_T_frame = false;
ee12b079 86:a26f5f22631d 465 enable_read_block = false;
ee12b079 86:a26f5f22631d 466 enable_ackandcallsign = true;
ee12b079 86:a26f5f22631d 467 create_Ack_andcallsign = true;
ee12b079 86:a26f5f22631d 468 }
ee12b079 86:a26f5f22631d 469 else{
ee12b079 86:a26f5f22631d 470 enable_read_block = true;
ee12b079 86:a26f5f22631d 471 }
ee12b079 86:a26f5f22631d 472 }
ee12b079 86:a26f5f22631d 473 if(T_frames_sent == T_frames_in_segment){
ee12b079 86:a26f5f22631d 474 enable_read_block = false;
ee12b079 86:a26f5f22631d 475 enable_T_frame = false;
ee12b079 86:a26f5f22631d 476 if((segments_sent + 1) >= max_segments){
ee12b079 86:a26f5f22631d 477 adf_limit = true;
ee12b079 86:a26f5f22631d 478 segments_sent++;
ee12b079 86:a26f5f22631d 479 // gPC.printf("segments_sent = "<<segments_sent<<ENDL;
ee12b079 140:be4eea8275c3 480 // gPC.printf("in for adf lim reached");
ee12b079 86:a26f5f22631d 481 }
ee12b079 86:a26f5f22631d 482 else{
ee12b079 86:a26f5f22631d 483 enable_new_segment = true;
ee12b079 92:bce22b38c440 484 // gPC.printf("data in next segment");
ee12b079 86:a26f5f22631d 485 segments_sent++;
ee12b079 86:a26f5f22631d 486 // cout<<"segments_sent = "<<segments_sent<<ENDL;
ee12b079 86:a26f5f22631d 487 }
ee12b079 86:a26f5f22631d 488 }
ee12b079 86:a26f5f22631d 489 else if(T_frames_sent > T_frames_in_segment){
ee12b079 86:a26f5f22631d 490 gPC.printf("error in enable T_frame");
ee12b079 86:a26f5f22631d 491 }
ee12b079 86:a26f5f22631d 492 }
ee12b079 86:a26f5f22631d 493 }
ee12b079 86:a26f5f22631d 494 else if(T_frames_sent > T_frames_in_segment){
ee12b079 86:a26f5f22631d 495 gPC.printf("error in if(read_success)");
ee12b079 86:a26f5f22631d 496 }
ee12b079 86:a26f5f22631d 497 }
ee12b079 86:a26f5f22631d 498 else{
ee12b079 86:a26f5f22631d 499 gPC.printf("error in enable T_frame");
ee12b079 86:a26f5f22631d 500 }
ee12b079 86:a26f5f22631d 501 }
ee12b079 86:a26f5f22631d 502 else if(adf_limit){
ee12b079 86:a26f5f22631d 503 buffer_112[counter_buffer_112] = EoS[counter_EoS++];
ee12b079 86:a26f5f22631d 504 if(counter_EoS == 120){
ee12b079 86:a26f5f22631d 505 // cout<<"EoS sent"<<ENDL;
ee12b079 86:a26f5f22631d 506 restart_adf();
ee12b079 86:a26f5f22631d 507 enable_new_segment = true;
ee12b079 86:a26f5f22631d 508 counter_EoS = 0;
ee12b079 86:a26f5f22631d 509 // cout<<"new session"<<ENDL;
ee12b079 86:a26f5f22631d 510 // cout<<"new segment"<<ENDL;
ee12b079 86:a26f5f22631d 511 T_frames_sent = 0;
ee12b079 86:a26f5f22631d 512 segments_sent = 0;
ee12b079 86:a26f5f22631d 513 adf_limit = false;
ee12b079 86:a26f5f22631d 514 }
ee12b079 86:a26f5f22631d 515 }
ee12b079 86:a26f5f22631d 516 else if(enable_ackandcallsign){
ee12b079 86:a26f5f22631d 517 if(create_Ack_andcallsign){
ee12b079 201:3410fc4d80f0 518 gPC.printf("cr ack\r\n");
krishanprajapat 122:b99f8be0a51a 519 enable_SCH = true;
ee12b079 199:9f03d6ca94c9 520
krishanprajapat 154:9aec89c8cdc7 521 if( (GETexec_status(current_obsrs_tc) == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_obsrs_tc) == 1) ){
krishanprajapat 154:9aec89c8cdc7 522 gMASTER_STATE = TCL_STATE_ABORTED;
krishanprajapat 154:9aec89c8cdc7 523 }
krishanprajapat 154:9aec89c8cdc7 524 else if( GETpacket_seq_count(current_obsrs_tc) == (gTOTAL_VALID_TC-1) ){
krishanprajapat 154:9aec89c8cdc7 525 gMASTER_STATE = TCL_STATE_COMPLETED;
krishanprajapat 154:9aec89c8cdc7 526 }
ee12b079 86:a26f5f22631d 527 create_Ack_andcallsign = false;
krishanprajapat 127:8a7bee7b8e8b 528 Base_tm *ack_and_callsign = NULL;
krishanprajapat 127:8a7bee7b8e8b 529 Base_tm *ack_head = NULL;
krishanprajapat 149:827e23febfdf 530 // get_call_sign(ack_and_callsign);
krishanprajapat 149:827e23febfdf 531 get_ack_l234(ack_and_callsign);
krishanprajapat 127:8a7bee7b8e8b 532 ack_head = ack_and_callsign;
krishanprajapat 149:827e23febfdf 533 get_ack_l1(ack_and_callsign->next_TM);
krishanprajapat 127:8a7bee7b8e8b 534 while(ack_and_callsign->next_TM != NULL){
krishanprajapat 127:8a7bee7b8e8b 535 ack_and_callsign = ack_and_callsign->next_TM;
krishanprajapat 127:8a7bee7b8e8b 536 }
krishanprajapat 149:827e23febfdf 537 get_call_sign(ack_and_callsign->next_TM);
ee12b079 142:83f48d1a1bc5 538 snd_tm.head_pointer_sdcard(ack_head);
krishanprajapat 127:8a7bee7b8e8b 539 T_frame_in_Ackandcallsign = 2*snd_tm.make_shor_tm();
krishanprajapat 148:46763854fa83 540 /* gPC.printf(" T_frame_in_Ackandcallsign = %d\r\n",T_frame_in_Ackandcallsign);*/
krishanprajapat 127:8a7bee7b8e8b 541 Base_tm *ack_l234 = ack_and_callsign->next_TM;
krishanprajapat 154:9aec89c8cdc7 542
krishanprajapat 154:9aec89c8cdc7 543 ack_and_callsign = ack_head->next_TM;
krishanprajapat 154:9aec89c8cdc7 544
krishanprajapat 127:8a7bee7b8e8b 545 if( GETshort_or_long_tm(ack_l234) == SHORT_TM_CODE ){
krishanprajapat 127:8a7bee7b8e8b 546 for(int i = 0 ; i < TM_SHORT_SIZE ; ++i){
krishanprajapat 127:8a7bee7b8e8b 547 gLAST_TM[i] = ack_l234->TM_string[i];
krishanprajapat 127:8a7bee7b8e8b 548 gLAST_TM_SHORT_OR_LONG = SHORT_TM_CODE;
krishanprajapat 127:8a7bee7b8e8b 549 }
krishanprajapat 127:8a7bee7b8e8b 550 }
krishanprajapat 127:8a7bee7b8e8b 551 else{
krishanprajapat 127:8a7bee7b8e8b 552 for( int i = 0 ; i < TM_LONG_SIZE ; ++i ){
krishanprajapat 127:8a7bee7b8e8b 553 gLAST_TM[i] = ack_l234->TM_string[i];
krishanprajapat 127:8a7bee7b8e8b 554 gLAST_TM_SHORT_OR_LONG = LONG_TM_CODE;
krishanprajapat 127:8a7bee7b8e8b 555 }
krishanprajapat 127:8a7bee7b8e8b 556 }
ee12b079 143:d81df402a016 557
ee12b079 201:3410fc4d80f0 558 gPC.printf("ex cr ack\r\n");
ee12b079 86:a26f5f22631d 559 }
ee12b079 86:a26f5f22631d 560 send_Ack_andcallsign;
ee12b079 201:3410fc4d80f0 561 if(last_buffer){
ee12b079 201:3410fc4d80f0 562 gPC.printf("last buffer");
ee12b079 199:9f03d6ca94c9 563 // delete ack_head;
ee12b079 199:9f03d6ca94c9 564 // while(ack_and_callsign != NULL){
ee12b079 199:9f03d6ca94c9 565 // Base_tm *temp = ack_and_callsign->next_TM;
ee12b079 199:9f03d6ca94c9 566 // delete ack_and_callsign;
ee12b079 199:9f03d6ca94c9 567 // ack_and_callsign = temp;
ee12b079 199:9f03d6ca94c9 568 }
ee12b079 199:9f03d6ca94c9 569
ee12b079 86:a26f5f22631d 570 }
ee12b079 143:d81df402a016 571 else if(last_buffer){
ee12b079 201:3410fc4d80f0 572 gPC.printf("last buffer2");
ee12b079 143:d81df402a016 573 // delete ack_head;
ee12b079 143:d81df402a016 574 // while(ack_and_callsign != NULL){
ee12b079 143:d81df402a016 575 // Base_tm *temp = ack_and_callsign->next_TM;
ee12b079 143:d81df402a016 576 // delete ack_and_callsign;
ee12b079 143:d81df402a016 577 // ack_and_callsign = temp;
ee12b079 143:d81df402a016 578 // }
ee12b079 143:d81df402a016 579 }
ee12b079 86:a26f5f22631d 580 else if(enable_EoS){
ee12b079 86:a26f5f22631d 581 // send_EoS();
ee12b079 201:3410fc4d80f0 582 gPC.printf("eos2");
ee12b079 86:a26f5f22631d 583 buffer_112[counter_buffer_112] = EoS[counter_EoS++];
ee12b079 86:a26f5f22631d 584 if(counter_EoS == 120){
ee12b079 86:a26f5f22631d 585 // cout<<"segments_sent = "<<segments_sent<<ENDL;
ee12b079 86:a26f5f22631d 586 // cout<<"EoS sent"<<ENDL;
ee12b079 86:a26f5f22631d 587 counter_EoS = 0;
ee12b079 86:a26f5f22631d 588 enable_EoS=false;
ee12b079 86:a26f5f22631d 589 enable_new_segment = true;
ee12b079 86:a26f5f22631d 590 break;
ee12b079 86:a26f5f22631d 591 }
ee12b079 86:a26f5f22631d 592 else{
ee12b079 86:a26f5f22631d 593 gPC.printf("Error in enable EoS");
ee12b079 86:a26f5f22631d 594 }
ee12b079 86:a26f5f22631d 595 }
ee12b079 86:a26f5f22631d 596 else{
ee12b079 86:a26f5f22631d 597 gPC.printf("error in for loop");
ee12b079 86:a26f5f22631d 598 }
ee12b079 86:a26f5f22631d 599 if(enable_read_block && (!last_block)){
ee12b079 86:a26f5f22631d 600 if(short_TC){
ee12b079 86:a26f5f22631d 601 /*cout<<"reading"<<int(FSC)<<" "<<int(SID)<<ENDL;*/
ee12b079 86:a26f5f22631d 602 // for(int i=0;i<512;i++){
ee12b079 86:a26f5f22631d 603 // printf("0x%02X,",write_buffer[i]);
ee12b079 86:a26f5f22631d 604 // }
ee12b079 199:9f03d6ca94c9 605 //int write_success = SD_WRITE(write_buffer,FSC + block_counter,SID);
ee12b079 86:a26f5f22631d 606 // wait_ms(8);
ee12b079 199:9f03d6ca94c9 607 //ack_code = SD_READ(buffer_512, FSC + block_counter,SID);
ee12b079 199:9f03d6ca94c9 608 /* gPC.printf("read block %d \n\r",read_success);*/
ee12b079 201:3410fc4d80f0 609 ack_code = 0x02;
ee12b079 199:9f03d6ca94c9 610 }
ee12b079 86:a26f5f22631d 611 else{
ee12b079 195:6a549c0e9287 612 ack_code = SD_READ(buffer_512, list_of_FSC[block_counter],SID);
ee12b079 86:a26f5f22631d 613 }
ee12b079 86:a26f5f22631d 614 block_counter++;
ee12b079 86:a26f5f22631d 615 if(block_counter == no_of_frames){
ee12b079 86:a26f5f22631d 616 last_block=true;
ee12b079 86:a26f5f22631d 617 }
ee12b079 86:a26f5f22631d 618 enable_read_block = false;
ee12b079 195:6a549c0e9287 619 if(ack_code == 0xA0){
ee12b079 201:3410fc4d80f0 620 gPC.puts("read one block successfully");
ee12b079 86:a26f5f22631d 621 enable_T_frame = true;
ee12b079 86:a26f5f22631d 622 enable_SCH = true;
ee12b079 86:a26f5f22631d 623 }
ee12b079 195:6a549c0e9287 624 else if(ack_code == 0x88 || ack_code == 0x89){
ee12b079 195:6a549c0e9287 625
ee12b079 86:a26f5f22631d 626 gPC.printf("Hardware failure");
ee12b079 86:a26f5f22631d 627 enable_T_frame = false;
ee12b079 86:a26f5f22631d 628 }
ee12b079 195:6a549c0e9287 629 else if(ack_code == 0x02){
ee12b079 195:6a549c0e9287 630 gPC.printf("Invalid SID");
ee12b079 195:6a549c0e9287 631 enable_T_frame = false;
ee12b079 195:6a549c0e9287 632 }
ee12b079 195:6a549c0e9287 633 else if(ack_code == 0x86){
ee12b079 195:6a549c0e9287 634 gPC.printf("FSC outof bounds");
ee12b079 86:a26f5f22631d 635 enable_T_frame = false;
ee12b079 86:a26f5f22631d 636 }
ee12b079 86:a26f5f22631d 637 else{
ee12b079 86:a26f5f22631d 638 gPC.printf("error Invalid ack code");
ee12b079 86:a26f5f22631d 639 enable_T_frame = false;
ee12b079 86:a26f5f22631d 640 stop = true;
ee12b079 86:a26f5f22631d 641 }
ee12b079 86:a26f5f22631d 642 }
ee12b079 201:3410fc4d80f0 643 if((PA_HOT || (!valid_SID)|| (gFLAGS & COM_SESSION_TIMEOUT_FLAG) ||(ack_code != 0xA0))&&(!enable_ackandcallsign)&&(!last_buffer)){
ee12b079 201:3410fc4d80f0 644 gPC.printf("last condition");
ee12b079 199:9f03d6ca94c9 645 uint8_t temp2 = TC_STATE_EXECUTION_FAILED;
ee12b079 199:9f03d6ca94c9 646 PUTexec_status(current_obsrs_tc, temp2);
ee12b079 86:a26f5f22631d 647 enable_ackandcallsign = true;
ee12b079 86:a26f5f22631d 648 create_Ack_andcallsign = true;
ee12b079 86:a26f5f22631d 649 enable_T_frame = false;
ee12b079 86:a26f5f22631d 650 }
ee12b079 86:a26f5f22631d 651 }
ee12b079 86:a26f5f22631d 652 // for(int i=0;i<112;i++){
ee12b079 86:a26f5f22631d 653 // printf("0x%02X,",buffer_112[i]);
ee12b079 86:a26f5f22631d 654 // }
ee12b079 86:a26f5f22631d 655 differential_encode(buffer_112, 112);
ee12b079 86:a26f5f22631d 656 if(last_buffer ==true){
ee12b079 86:a26f5f22631d 657 diff_prev=0;
ee12b079 86:a26f5f22631d 658 }
ee12b079 86:a26f5f22631d 659 }
ee12b079 86:a26f5f22631d 660
ee12b079 86:a26f5f22631d 661 void execute_OBSRS_TC(Base_tc *tcp){
krishanprajapat 127:8a7bee7b8e8b 662 current_obsrs_tc = tcp;
krishanprajapat 127:8a7bee7b8e8b 663 flags_init;
ee12b079 95:42d6747900cb 664 sent_tmfrom_SDcard = true;
ee12b079 142:83f48d1a1bc5 665 diff_prev = 0;
ee12b079 92:bce22b38c440 666 if( GETshort_or_long_tc(tcp) == SHORT_TC_CODE ){
ee12b079 92:bce22b38c440 667 short_TC = true;
ee12b079 92:bce22b38c440 668 gPC.printf("it is short TC\r\n");
ee12b079 92:bce22b38c440 669 }
ee12b079 92:bce22b38c440 670 else{
ee12b079 92:bce22b38c440 671 gPC.printf("it is long TC\r\n");
ee12b079 92:bce22b38c440 672 short_TC = false;
ee12b079 92:bce22b38c440 673 }
ee12b079 92:bce22b38c440 674 /* reading SID from TC */
ee12b079 92:bce22b38c440 675 SID = (tcp->TC_string[2]) & 0x0f;
ee12b079 92:bce22b38c440 676 /* reading FSC and no. of frames from TC */
ee12b079 92:bce22b38c440 677 if(short_TC){
ee12b079 92:bce22b38c440 678 FSC = tcp->TC_string[3] << 24;
ee12b079 92:bce22b38c440 679 FSC += tcp->TC_string[4] << 16;
ee12b079 92:bce22b38c440 680 FSC += tcp->TC_string[5] << 8;
ee12b079 92:bce22b38c440 681 FSC += tcp->TC_string[6];
ee12b079 92:bce22b38c440 682 no_of_frames = tcp->TC_string[7] << 8;
ee12b079 92:bce22b38c440 683 no_of_frames += tcp->TC_string[8];
ee12b079 92:bce22b38c440 684 }
ee12b079 92:bce22b38c440 685 else{
ee12b079 92:bce22b38c440 686 no_of_frames = tcp->TC_string[3];
ee12b079 92:bce22b38c440 687 for(int i=0 ;i<no_of_frames ; i++){
ee12b079 92:bce22b38c440 688 list_of_FSC[i] = tcp->TC_string[4+i];
ee12b079 92:bce22b38c440 689 }
ee12b079 92:bce22b38c440 690 }
ee12b079 100:484a687431cc 691
ee12b079 99:efde3df6cd94 692 gPC.printf("sid = %u \r\n",SID);
ee12b079 99:efde3df6cd94 693 gPC.printf("FSC = %u\r\n",FSC);
ee12b079 140:be4eea8275c3 694 // gPC.puts("exit_sdcard");
krishanprajapat 121:bd7263168ee4 695
krishanprajapat 121:bd7263168ee4 696 // SID = 0x1;
ee12b079 92:bce22b38c440 697 // FSC = 10;
ee12b079 92:bce22b38c440 698 // no_of_frames = 2;
ee12b079 86:a26f5f22631d 699 // cout<<"max_segments = "<<max_segments<<ENDL;
ee12b079 86:a26f5f22631d 700 //while(0){
ee12b079 86:a26f5f22631d 701 // while(!stop){
ee12b079 86:a26f5f22631d 702 // // send_call_sign();
ee12b079 86:a26f5f22631d 703 // if(short_TC){
ee12b079 86:a26f5f22631d 704 // send_tm_from_SD_card();
ee12b079 86:a26f5f22631d 705 // }
ee12b079 86:a26f5f22631d 706 // else{
ee12b079 86:a26f5f22631d 707 // send_tm_from_SD_card();
ee12b079 86:a26f5f22631d 708 // }
ee12b079 86:a26f5f22631d 709 // }
ee12b079 86:a26f5f22631d 710 }