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:
krishanprajapat
Date:
Tue Jan 19 10:30:46 2016 +0000
Revision:
71:9193fbdaa3e1
Modification of CDMS_sd.h required

Who changed what in which revision?

UserRevisionLine numberNew contents of line
krishanprajapat 71:9193fbdaa3e1 1 // problem in check pa and valid sid not sending anything in one for loop
krishanprajapat 71:9193fbdaa3e1 2
krishanprajapat 71:9193fbdaa3e1 3
krishanprajapat 71:9193fbdaa3e1 4
krishanprajapat 71:9193fbdaa3e1 5 // no error case 2 ackl234new->TM_string[2] = (101_0000) = 0x_0; spare = 0 10100000 = 0xA0
krishanprajapat 71:9193fbdaa3e1 6 // Hardware failure Case 4 ackl234new->TM_string[2] = (100_0101) = 0x_5; spare = 0 10000101 = 0x85 comes from cdms ask pradeep
krishanprajapat 71:9193fbdaa3e1 7 // Invalid FSC Case 4 ackl234new->TM_string[2] = (100_0110) = 0x_6; spare = 0 10000110 = 0x86 Invalid FSC
krishanprajapat 71:9193fbdaa3e1 8 // Illegal TC Case 3 ackl234new->TM_string[2] = (000_0010) = 0x_2; spare = 0 00000010 = 0x02 invalid SID
krishanprajapat 71:9193fbdaa3e1 9
krishanprajapat 71:9193fbdaa3e1 10
krishanprajapat 71:9193fbdaa3e1 11
krishanprajapat 71:9193fbdaa3e1 12 #define TMID_ACK_L234 0xB
krishanprajapat 71:9193fbdaa3e1 13 #define T_frames_in_segment 10
krishanprajapat 71:9193fbdaa3e1 14
krishanprajapat 71:9193fbdaa3e1 15 using namespace std;
krishanprajapat 71:9193fbdaa3e1 16 Serial pc(USBTX, USBRX); // tx, rx
krishanprajapat 71:9193fbdaa3e1 17
krishanprajapat 71:9193fbdaa3e1 18 DigitalOut gpo(D0);
krishanprajapat 71:9193fbdaa3e1 19 DigitalOut led(LED_RED);
krishanprajapat 71:9193fbdaa3e1 20
krishanprajapat 71:9193fbdaa3e1 21 bool send_EoS_and_stop = false;
krishanprajapat 71:9193fbdaa3e1 22 bool adf_limit = false;
krishanprajapat 71:9193fbdaa3e1 23 bool stop = false;
krishanprajapat 71:9193fbdaa3e1 24 bool check_PA = true;
krishanprajapat 71:9193fbdaa3e1 25 bool PA_HOT=0;
krishanprajapat 71:9193fbdaa3e1 26 bool short_TC;
krishanprajapat 71:9193fbdaa3e1 27 bool valid_SID = true;
krishanprajapat 71:9193fbdaa3e1 28 bool enable_call_sign = true;
krishanprajapat 71:9193fbdaa3e1 29 bool enable_new_segment=true;
krishanprajapat 71:9193fbdaa3e1 30 bool enable_S_frame = true;
krishanprajapat 71:9193fbdaa3e1 31 bool enable_read_block = false;
krishanprajapat 71:9193fbdaa3e1 32 bool enable_T_frame = false;
krishanprajapat 71:9193fbdaa3e1 33 bool enable_Ack_andcallsign = false;
krishanprajapat 71:9193fbdaa3e1 34 bool enable_ackandcallsign = false;
krishanprajapat 71:9193fbdaa3e1 35 bool new_session =true;
krishanprajapat 71:9193fbdaa3e1 36 bool enable_EoS=false;
krishanprajapat 71:9193fbdaa3e1 37 bool create_Ack_andcallsign = true;
krishanprajapat 71:9193fbdaa3e1 38 bool Ack_andcallsign_over = false;
krishanprajapat 71:9193fbdaa3e1 39 bool repeat_last_2T_frames = false;
krishanprajapat 71:9193fbdaa3e1 40 bool last_block = false;
krishanprajapat 71:9193fbdaa3e1 41 bool last_buffer = false;
krishanprajapat 71:9193fbdaa3e1 42 bool new_OBSRS_TC = true;
krishanprajapat 71:9193fbdaa3e1 43 bool enable_SCH = true;
krishanprajapat 71:9193fbdaa3e1 44 bool enable_FCCH = false;
krishanprajapat 71:9193fbdaa3e1 45 bool enable_DS = false;
krishanprajapat 71:9193fbdaa3e1 46
krishanprajapat 71:9193fbdaa3e1 47 uint8_t SID ;
krishanprajapat 71:9193fbdaa3e1 48 unsigned char buffer_112[112];
krishanprajapat 71:9193fbdaa3e1 49 uint32_t FSC;
krishanprajapat 71:9193fbdaa3e1 50 uint16_t read_success = false;
krishanprajapat 71:9193fbdaa3e1 51 uint16_t counter_buffer_112=0, counter_EoS=0,T_frames_sent=0;
krishanprajapat 71:9193fbdaa3e1 52 uint16_t counter_call_sign_buffer=0;
krishanprajapat 71:9193fbdaa3e1 53 uint16_t counter_buffer_512=0;
krishanprajapat 71:9193fbdaa3e1 54 uint16_t counter_Ack_andcallsign = 0;
krishanprajapat 71:9193fbdaa3e1 55 uint16_t max_segments = 65415/(48+T_frames_in_segment*159);
krishanprajapat 71:9193fbdaa3e1 56 uint16_t ack_code = 0xA0;
krishanprajapat 71:9193fbdaa3e1 57 uint16_t segments_sent = 0;
krishanprajapat 71:9193fbdaa3e1 58 uint8_t counter_SCH40 = 0;
krishanprajapat 71:9193fbdaa3e1 59 uint8_t counter_FCCH80 = 0;
krishanprajapat 71:9193fbdaa3e1 60 uint8_t counter_S_frame = 0;
krishanprajapat 71:9193fbdaa3e1 61 uint16_t T_frame_Ack_andcallsign_sent = 0;
krishanprajapat 71:9193fbdaa3e1 62 uint16_t T_frame_in_Ackandcallsign = 4; // needs to get from sukhdeep depends on size of Ack_L1
krishanprajapat 71:9193fbdaa3e1 63 uint64_t start_block_num ;
krishanprajapat 71:9193fbdaa3e1 64 uint32_t block_counter = 0;
krishanprajapat 71:9193fbdaa3e1 65 uint32_t no_of_frames =0;
krishanprajapat 71:9193fbdaa3e1 66 int Ack_L1; // should be always even
krishanprajapat 71:9193fbdaa3e1 67
krishanprajapat 71:9193fbdaa3e1 68 //#define max_segments = 65415/(48+T_frames_in_segment*159)
krishanprajapat 71:9193fbdaa3e1 69 // 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
krishanprajapat 71:9193fbdaa3e1 70 // 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,
krishanprajapat 71:9193fbdaa3e1 71 //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};
krishanprajapat 71:9193fbdaa3e1 72 //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 71:9193fbdaa3e1 73 uint16_t counter=0;
krishanprajapat 71:9193fbdaa3e1 74 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};
krishanprajapat 71:9193fbdaa3e1 75 //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};
krishanprajapat 71:9193fbdaa3e1 76 uint8_t buffer_512[512];
krishanprajapat 71:9193fbdaa3e1 77 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};
krishanprajapat 71:9193fbdaa3e1 78 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};
krishanprajapat 71:9193fbdaa3e1 79 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};
krishanprajapat 71:9193fbdaa3e1 80 //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};
krishanprajapat 71:9193fbdaa3e1 81 //const unsigned char FCCH80[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
krishanprajapat 71:9193fbdaa3e1 82 //const unsigned char SCH40[] = {0x0a,0x3f,0x46,0xb4,0x00};
krishanprajapat 71:9193fbdaa3e1 83
krishanprajapat 71:9193fbdaa3e1 84
krishanprajapat 71:9193fbdaa3e1 85
krishanprajapat 71:9193fbdaa3e1 86
krishanprajapat 71:9193fbdaa3e1 87 #define create_Ack_L234 {\
krishanprajapat 71:9193fbdaa3e1 88 Base_tm *ackl234new = new Short_tm;\
krishanprajapat 71:9193fbdaa3e1 89 ackl234new->next_TM = NULL;\
krishanprajapat 71:9193fbdaa3e1 90 /*return telemetry pointer here*/\
krishanprajapat 71:9193fbdaa3e1 91 uint8_t temp8;\
krishanprajapat 71:9193fbdaa3e1 92 temp8 = SHORT_TM_CODE;\
krishanprajapat 71:9193fbdaa3e1 93 PUTshort_or_long_tm(ackl234new->fields, temp8);\
krishanprajapat 71:9193fbdaa3e1 94 temp8 = TMID_ACK_L234;\
krishanprajapat 71:9193fbdaa3e1 95 PUTtmid((ackl234new->fields), temp8);\
krishanprajapat 71:9193fbdaa3e1 96 ackl234new->TM_string[0] = TMID_ACK_L234 << 4;\
krishanprajapat 71:9193fbdaa3e1 97 ackl234new->TM_string[1] = 0x12;\
krishanprajapat 71:9193fbdaa3e1 98 ackl234new->TM_string[2] = ack_code; /* Ack code ....to be chnaged accordind to situation */\
krishanprajapat 71:9193fbdaa3e1 99 for(int i = 3; i < 11; ++i){\
krishanprajapat 71:9193fbdaa3e1 100 ackl234new->TM_string[i] = 0x00;\
krishanprajapat 71:9193fbdaa3e1 101 }\
krishanprajapat 71:9193fbdaa3e1 102 uint16_t crc = crc16_gen(ackl234new->TM_string, TM_SHORT_SIZE-2);\
krishanprajapat 71:9193fbdaa3e1 103 ackl234new->TM_string[11] = (crc & 0xFF00) >> 8;\
krishanprajapat 71:9193fbdaa3e1 104 ackl234new->TM_string[12] = crc & 0x00FF; \
krishanprajapat 71:9193fbdaa3e1 105 }
krishanprajapat 71:9193fbdaa3e1 106
krishanprajapat 71:9193fbdaa3e1 107 #define make_T_frame_Ack_andcallsign {\
krishanprajapat 71:9193fbdaa3e1 108 }
krishanprajapat 71:9193fbdaa3e1 109
krishanprajapat 71:9193fbdaa3e1 110 void restart_adf(){
krishanprajapat 71:9193fbdaa3e1 111
krishanprajapat 71:9193fbdaa3e1 112 }
krishanprajapat 71:9193fbdaa3e1 113
krishanprajapat 71:9193fbdaa3e1 114 int diff_prev;
krishanprajapat 71:9193fbdaa3e1 115 void differential_encode(unsigned char* ptr, int length){
krishanprajapat 71:9193fbdaa3e1 116 for(int i=0; i<length;i++){
krishanprajapat 71:9193fbdaa3e1 117 unsigned char s = ptr[i] , t;
krishanprajapat 71:9193fbdaa3e1 118 t = s ^ (s >> 1);
krishanprajapat 71:9193fbdaa3e1 119 (diff_prev == 0) ? t=t^0x00 : t=t^0x80 ;
krishanprajapat 71:9193fbdaa3e1 120 diff_prev = int(s & 0x01);
krishanprajapat 71:9193fbdaa3e1 121 ptr[i] = t;
krishanprajapat 71:9193fbdaa3e1 122 }
krishanprajapat 71:9193fbdaa3e1 123 }
krishanprajapat 71:9193fbdaa3e1 124
krishanprajapat 71:9193fbdaa3e1 125 #define check_PA_temp {\
krishanprajapat 71:9193fbdaa3e1 126 /* return 0 or 1*/\
krishanprajapat 71:9193fbdaa3e1 127 PA_HOT=0;\
krishanprajapat 71:9193fbdaa3e1 128 }
krishanprajapat 71:9193fbdaa3e1 129
krishanprajapat 71:9193fbdaa3e1 130 int get_Ack_L1(){
krishanprajapat 71:9193fbdaa3e1 131 for(int i=0;i<288;i++){
krishanprajapat 71:9193fbdaa3e1 132 // Ack_andcallsign[i] = 0xff;
krishanprajapat 71:9193fbdaa3e1 133 }
krishanprajapat 71:9193fbdaa3e1 134 //cout<<"in side get_Ack_L1"<<endl<<"\r";
krishanprajapat 71:9193fbdaa3e1 135 return 1;
krishanprajapat 71:9193fbdaa3e1 136 }
krishanprajapat 71:9193fbdaa3e1 137
krishanprajapat 71:9193fbdaa3e1 138 #define send_Ack_andcallsign{\
krishanprajapat 71:9193fbdaa3e1 139 if(T_frames_sent < T_frames_in_segment){\
krishanprajapat 71:9193fbdaa3e1 140 buffer_112[counter_buffer_112] = Ack_andcallsign[counter_Ack_andcallsign++]; /* to be changed sukhdeep should write in buffer_112*/\
krishanprajapat 71:9193fbdaa3e1 141 if(counter_Ack_andcallsign == 318){\
krishanprajapat 71:9193fbdaa3e1 142 counter_Ack_andcallsign = 0;\
krishanprajapat 71:9193fbdaa3e1 143 T_frames_sent = T_frames_sent +2;\
krishanprajapat 71:9193fbdaa3e1 144 if(repeat_last_2T_frames){\
krishanprajapat 71:9193fbdaa3e1 145 /*cout<<"repeated last two T frames"<<" ";*/\
krishanprajapat 71:9193fbdaa3e1 146 /*cout<<"T_frames_sent = "<<T_frames_sent<<ENDL;*/\
krishanprajapat 71:9193fbdaa3e1 147 }\
krishanprajapat 71:9193fbdaa3e1 148 else{\
krishanprajapat 71:9193fbdaa3e1 149 /*cout<<"Ackandcallsign sent"<<" ";*/\
krishanprajapat 71:9193fbdaa3e1 150 /*cout<<"T_frames_sent = "<<T_frames_sent<<ENDL;*/\
krishanprajapat 71:9193fbdaa3e1 151 T_frame_Ack_andcallsign_sent = T_frame_Ack_andcallsign_sent + 2;\
krishanprajapat 71:9193fbdaa3e1 152 if(T_frame_Ack_andcallsign_sent == T_frame_in_Ackandcallsign ){\
krishanprajapat 71:9193fbdaa3e1 153 repeat_last_2T_frames = true;\
krishanprajapat 71:9193fbdaa3e1 154 }\
krishanprajapat 71:9193fbdaa3e1 155 else if(T_frame_Ack_andcallsign_sent < T_frame_in_Ackandcallsign){\
krishanprajapat 71:9193fbdaa3e1 156 make_T_frame_Ack_andcallsign;\
krishanprajapat 71:9193fbdaa3e1 157 }\
krishanprajapat 71:9193fbdaa3e1 158 else{\
krishanprajapat 71:9193fbdaa3e1 159 /*cout<<"error in send_Ack_andcallsign if T_frames_sent < T_frames_in_segment"<<ENDL;*/\
krishanprajapat 71:9193fbdaa3e1 160 }\
krishanprajapat 71:9193fbdaa3e1 161 }\
krishanprajapat 71:9193fbdaa3e1 162 if(T_frames_sent == T_frames_in_segment){\
krishanprajapat 71:9193fbdaa3e1 163 if(T_frame_Ack_andcallsign_sent < T_frame_in_Ackandcallsign){\
krishanprajapat 71:9193fbdaa3e1 164 if(segments_sent + 1>= max_segments){\
krishanprajapat 71:9193fbdaa3e1 165 adf_limit = true;\
krishanprajapat 71:9193fbdaa3e1 166 segments_sent = 0;\
krishanprajapat 71:9193fbdaa3e1 167 /*cout<<"adf limit reached"<<ENDL;*/\
krishanprajapat 71:9193fbdaa3e1 168 }\
krishanprajapat 71:9193fbdaa3e1 169 else{\
krishanprajapat 71:9193fbdaa3e1 170 enable_new_segment = true;\
krishanprajapat 71:9193fbdaa3e1 171 /*cout<<"new segment"<<ENDL;*/\
krishanprajapat 71:9193fbdaa3e1 172 }\
krishanprajapat 71:9193fbdaa3e1 173 }\
krishanprajapat 71:9193fbdaa3e1 174 else{\
krishanprajapat 71:9193fbdaa3e1 175 send_EoS_and_stop = true; \
krishanprajapat 71:9193fbdaa3e1 176 } \
krishanprajapat 71:9193fbdaa3e1 177 }\
krishanprajapat 71:9193fbdaa3e1 178 }\
krishanprajapat 71:9193fbdaa3e1 179 }\
krishanprajapat 71:9193fbdaa3e1 180 else if(send_EoS_and_stop){\
krishanprajapat 71:9193fbdaa3e1 181 buffer_112[counter_buffer_112] = EoS[counter_EoS++];\
krishanprajapat 71:9193fbdaa3e1 182 if(counter_EoS == 120){\
krishanprajapat 71:9193fbdaa3e1 183 /*cout<<"segments_sent = "<<segments_sent<<ENDL;*/\
krishanprajapat 71:9193fbdaa3e1 184 /*cout<<"EoS sent"<<ENDL;*/\
krishanprajapat 71:9193fbdaa3e1 185 counter_EoS = 0;\
krishanprajapat 71:9193fbdaa3e1 186 enable_ackandcallsign = false;\
krishanprajapat 71:9193fbdaa3e1 187 stop =true;\
krishanprajapat 71:9193fbdaa3e1 188 last_buffer = true;\
krishanprajapat 71:9193fbdaa3e1 189 }\
krishanprajapat 71:9193fbdaa3e1 190 }\
krishanprajapat 71:9193fbdaa3e1 191 else if(adf_limit){\
krishanprajapat 71:9193fbdaa3e1 192 buffer_112[counter_buffer_112] = EoS[counter_EoS++];\
krishanprajapat 71:9193fbdaa3e1 193 if(counter_EoS == 120){\
krishanprajapat 71:9193fbdaa3e1 194 counter_EoS = 0;\
krishanprajapat 71:9193fbdaa3e1 195 /*cout<<"EoS sent"<<ENDL;*/\
krishanprajapat 71:9193fbdaa3e1 196 restart_adf();\
krishanprajapat 71:9193fbdaa3e1 197 enable_new_segment = true;\
krishanprajapat 71:9193fbdaa3e1 198 /*cout<<"new session"<<ENDL;*/\
krishanprajapat 71:9193fbdaa3e1 199 /*cout<<"new segment"<<ENDL;*/\
krishanprajapat 71:9193fbdaa3e1 200 T_frames_sent = 0;\
krishanprajapat 71:9193fbdaa3e1 201 segments_sent = 0; \
krishanprajapat 71:9193fbdaa3e1 202 adf_limit = false;\
krishanprajapat 71:9193fbdaa3e1 203 }\
krishanprajapat 71:9193fbdaa3e1 204 }\
krishanprajapat 71:9193fbdaa3e1 205 else{\
krishanprajapat 71:9193fbdaa3e1 206 gPC.printf("error in send_Ack_andcallsign()");\
krishanprajapat 71:9193fbdaa3e1 207 }\
krishanprajapat 71:9193fbdaa3e1 208 }
krishanprajapat 71:9193fbdaa3e1 209 #define send_S_frame {\
krishanprajapat 71:9193fbdaa3e1 210 buffer_112[counter_buffer_112] = S_frame[counter_S_frame++];\
krishanprajapat 71:9193fbdaa3e1 211 if(counter_S_frame == 48){\
krishanprajapat 71:9193fbdaa3e1 212 enable_new_segment=false;\
krishanprajapat 71:9193fbdaa3e1 213 counter_S_frame = 0;\
krishanprajapat 71:9193fbdaa3e1 214 /*cout<<"S_frame_sent"<<ENDL;*/\
krishanprajapat 71:9193fbdaa3e1 215 if(new_OBSRS_TC){\
krishanprajapat 71:9193fbdaa3e1 216 enable_call_sign = true;\
krishanprajapat 71:9193fbdaa3e1 217 new_OBSRS_TC = false;\
krishanprajapat 71:9193fbdaa3e1 218 }\
krishanprajapat 71:9193fbdaa3e1 219 else{\
krishanprajapat 71:9193fbdaa3e1 220 enable_read_block = true;\
krishanprajapat 71:9193fbdaa3e1 221 }\
krishanprajapat 71:9193fbdaa3e1 222 }\
krishanprajapat 71:9193fbdaa3e1 223 }
krishanprajapat 71:9193fbdaa3e1 224
krishanprajapat 71:9193fbdaa3e1 225 #define send_call_sign {\
krishanprajapat 71:9193fbdaa3e1 226 buffer_112[counter_buffer_112] = call_sign_buffer[counter_call_sign_buffer++];\
krishanprajapat 71:9193fbdaa3e1 227 if(counter_call_sign_buffer == 318){\
krishanprajapat 71:9193fbdaa3e1 228 counter_call_sign_buffer = 0;\
krishanprajapat 71:9193fbdaa3e1 229 enable_call_sign = false;\
krishanprajapat 71:9193fbdaa3e1 230 new_session =false;\
krishanprajapat 71:9193fbdaa3e1 231 /*cout<<"call_sign_sent"<<" ";*/\
krishanprajapat 71:9193fbdaa3e1 232 T_frames_sent = T_frames_sent+2;\
krishanprajapat 71:9193fbdaa3e1 233 if(SID==0x0 || SID==0x2 || SID==0x3 || SID==0x4 || SID==0x5){\
krishanprajapat 71:9193fbdaa3e1 234 valid_SID=true;\
krishanprajapat 71:9193fbdaa3e1 235 /*cout<<"valid SID"<<ENDL;*/\
krishanprajapat 71:9193fbdaa3e1 236 }\
krishanprajapat 71:9193fbdaa3e1 237 else{\
krishanprajapat 71:9193fbdaa3e1 238 valid_SID=false;\
krishanprajapat 71:9193fbdaa3e1 239 gPC.printf("invalid SID");\
krishanprajapat 71:9193fbdaa3e1 240 enable_ackandcallsign = true;\
krishanprajapat 71:9193fbdaa3e1 241 create_Ack_andcallsign = true;\
krishanprajapat 71:9193fbdaa3e1 242 ack_code = 0x02;\
krishanprajapat 71:9193fbdaa3e1 243 }\
krishanprajapat 71:9193fbdaa3e1 244 check_PA_temp;\
krishanprajapat 71:9193fbdaa3e1 245 /*cout<<"pa_hot = "<<PA_HOT<<ENDL;*/\
krishanprajapat 71:9193fbdaa3e1 246 if(PA_HOT){\
krishanprajapat 71:9193fbdaa3e1 247 enable_ackandcallsign = true;\
krishanprajapat 71:9193fbdaa3e1 248 create_Ack_andcallsign = true;\
krishanprajapat 71:9193fbdaa3e1 249 enable_read_block = false;\
krishanprajapat 71:9193fbdaa3e1 250 }\
krishanprajapat 71:9193fbdaa3e1 251 else{\
krishanprajapat 71:9193fbdaa3e1 252 enable_read_block = true;\
krishanprajapat 71:9193fbdaa3e1 253 enable_ackandcallsign = false;\
krishanprajapat 71:9193fbdaa3e1 254 }\
krishanprajapat 71:9193fbdaa3e1 255 }\
krishanprajapat 71:9193fbdaa3e1 256 }
krishanprajapat 71:9193fbdaa3e1 257
krishanprajapat 71:9193fbdaa3e1 258 //uint16_t SD_READ(uint64_t block_to_read){
krishanprajapat 71:9193fbdaa3e1 259 // for(int i=0;i<318;i++){
krishanprajapat 71:9193fbdaa3e1 260 // buffer_512[counter_buffer_512++] = 0xff;
krishanprajapat 71:9193fbdaa3e1 261 // }
krishanprajapat 71:9193fbdaa3e1 262 // for(int i=319;i<512;i++){
krishanprajapat 71:9193fbdaa3e1 263 // buffer_512[counter_buffer_512++] = 0x00;
krishanprajapat 71:9193fbdaa3e1 264 // }
krishanprajapat 71:9193fbdaa3e1 265 // counter_buffer_512 = 0;
krishanprajapat 71:9193fbdaa3e1 266 // return 0xA0; // if success
krishanprajapat 71:9193fbdaa3e1 267 //// return 0x85; // Hardware failure
krishanprajapat 71:9193fbdaa3e1 268 // // return 0x86; // invalid TC
krishanprajapat 71:9193fbdaa3e1 269 //}
krishanprajapat 71:9193fbdaa3e1 270
krishanprajapat 71:9193fbdaa3e1 271 void send_tm_from_SD_card(){
krishanprajapat 71:9193fbdaa3e1 272 for(counter_buffer_112=0;counter_buffer_112<112;counter_buffer_112++){
krishanprajapat 71:9193fbdaa3e1 273 if(enable_new_segment){ // starting new segment
krishanprajapat 71:9193fbdaa3e1 274 send_S_frame;
krishanprajapat 71:9193fbdaa3e1 275 T_frames_sent=0;
krishanprajapat 71:9193fbdaa3e1 276 }
krishanprajapat 71:9193fbdaa3e1 277 else if(enable_call_sign){ // sending call sign
krishanprajapat 71:9193fbdaa3e1 278 send_call_sign ;
krishanprajapat 71:9193fbdaa3e1 279 }
krishanprajapat 71:9193fbdaa3e1 280 else if(enable_T_frame){
krishanprajapat 71:9193fbdaa3e1 281 if(read_success == 0){
krishanprajapat 71:9193fbdaa3e1 282 if(T_frames_sent < T_frames_in_segment){
krishanprajapat 71:9193fbdaa3e1 283 if (enable_SCH)
krishanprajapat 71:9193fbdaa3e1 284 {
krishanprajapat 71:9193fbdaa3e1 285 buffer_112[counter_buffer_112] = SCH40[counter_SCH40++];
krishanprajapat 71:9193fbdaa3e1 286 if (counter_SCH40 == 5)
krishanprajapat 71:9193fbdaa3e1 287 {
krishanprajapat 71:9193fbdaa3e1 288 // cout<<"sch sent"<<ENDL;
krishanprajapat 71:9193fbdaa3e1 289 counter_SCH40 = 0;
krishanprajapat 71:9193fbdaa3e1 290 enable_SCH = false;
krishanprajapat 71:9193fbdaa3e1 291 enable_DS = true;
krishanprajapat 71:9193fbdaa3e1 292 }
krishanprajapat 71:9193fbdaa3e1 293 }
krishanprajapat 71:9193fbdaa3e1 294 else if (enable_DS)
krishanprajapat 71:9193fbdaa3e1 295 {
krishanprajapat 71:9193fbdaa3e1 296 buffer_112[counter_buffer_112] = buffer_512[counter_buffer_512++];
krishanprajapat 71:9193fbdaa3e1 297 if ((counter_buffer_512 == 288) || (counter_buffer_512 == 144))
krishanprajapat 71:9193fbdaa3e1 298 {
krishanprajapat 71:9193fbdaa3e1 299 // cout<<"ds sent"<<ENDL;
krishanprajapat 71:9193fbdaa3e1 300 // counter_buffer_512 = 0;
krishanprajapat 71:9193fbdaa3e1 301 enable_DS = false;
krishanprajapat 71:9193fbdaa3e1 302 enable_FCCH = true;
krishanprajapat 71:9193fbdaa3e1 303 }
krishanprajapat 71:9193fbdaa3e1 304 }
krishanprajapat 71:9193fbdaa3e1 305 else if (enable_FCCH)
krishanprajapat 71:9193fbdaa3e1 306 {
krishanprajapat 71:9193fbdaa3e1 307 buffer_112[counter_buffer_112] = FCCH80[counter_FCCH80++];
krishanprajapat 71:9193fbdaa3e1 308 if (counter_FCCH80 == 10)
krishanprajapat 71:9193fbdaa3e1 309 {
krishanprajapat 71:9193fbdaa3e1 310 // cout<<"fcch sent"<<ENDL;
krishanprajapat 71:9193fbdaa3e1 311 enable_FCCH = false;
krishanprajapat 71:9193fbdaa3e1 312 if(counter_buffer_512 == 144){
krishanprajapat 71:9193fbdaa3e1 313 enable_SCH = true;
krishanprajapat 71:9193fbdaa3e1 314 counter_FCCH80 = 0;
krishanprajapat 71:9193fbdaa3e1 315 }
krishanprajapat 71:9193fbdaa3e1 316 else{
krishanprajapat 71:9193fbdaa3e1 317
krishanprajapat 71:9193fbdaa3e1 318 }
krishanprajapat 71:9193fbdaa3e1 319 }
krishanprajapat 71:9193fbdaa3e1 320 }
krishanprajapat 71:9193fbdaa3e1 321 if((counter_FCCH80 == 10)&&(counter_buffer_512 == 288)){
krishanprajapat 71:9193fbdaa3e1 322 counter_FCCH80 = 0;
krishanprajapat 71:9193fbdaa3e1 323 counter_buffer_512 = 0;
krishanprajapat 71:9193fbdaa3e1 324 T_frames_sent = T_frames_sent+2;
krishanprajapat 71:9193fbdaa3e1 325 // cout<<"T_frames_sent "<<T_frames_sent<<ENDL;
krishanprajapat 71:9193fbdaa3e1 326 if(last_block){
krishanprajapat 71:9193fbdaa3e1 327 // cout<<"last block"<<endl<<"\r";
krishanprajapat 71:9193fbdaa3e1 328 enable_read_block = false;
krishanprajapat 71:9193fbdaa3e1 329 enable_T_frame = false;
krishanprajapat 71:9193fbdaa3e1 330 enable_ackandcallsign = true;
krishanprajapat 71:9193fbdaa3e1 331 create_Ack_andcallsign = true;
krishanprajapat 71:9193fbdaa3e1 332 if(T_frames_sent == T_frames_in_segment){
krishanprajapat 71:9193fbdaa3e1 333 if(segments_sent + 1>= max_segments){
krishanprajapat 71:9193fbdaa3e1 334 adf_limit = true;
krishanprajapat 71:9193fbdaa3e1 335 segments_sent = 0;
krishanprajapat 71:9193fbdaa3e1 336 gPC.printf("adf limit reached here");
krishanprajapat 71:9193fbdaa3e1 337 }
krishanprajapat 71:9193fbdaa3e1 338 else{
krishanprajapat 71:9193fbdaa3e1 339 enable_new_segment = true;
krishanprajapat 71:9193fbdaa3e1 340 // cout<<"new segment"<<ENDL;
krishanprajapat 71:9193fbdaa3e1 341 }
krishanprajapat 71:9193fbdaa3e1 342 }
krishanprajapat 71:9193fbdaa3e1 343 continue;
krishanprajapat 71:9193fbdaa3e1 344 }
krishanprajapat 71:9193fbdaa3e1 345 else{
krishanprajapat 71:9193fbdaa3e1 346 check_PA_temp;
krishanprajapat 71:9193fbdaa3e1 347 // cout<<"pa_hot = "<<PA_HOT<<" ";
krishanprajapat 71:9193fbdaa3e1 348 if(PA_HOT){
krishanprajapat 71:9193fbdaa3e1 349 enable_T_frame = false;
krishanprajapat 71:9193fbdaa3e1 350 enable_read_block = false;
krishanprajapat 71:9193fbdaa3e1 351 enable_ackandcallsign = true;
krishanprajapat 71:9193fbdaa3e1 352 create_Ack_andcallsign = true;
krishanprajapat 71:9193fbdaa3e1 353 }
krishanprajapat 71:9193fbdaa3e1 354 else{
krishanprajapat 71:9193fbdaa3e1 355 enable_read_block = true;
krishanprajapat 71:9193fbdaa3e1 356 }
krishanprajapat 71:9193fbdaa3e1 357 }
krishanprajapat 71:9193fbdaa3e1 358 if(T_frames_sent == T_frames_in_segment){
krishanprajapat 71:9193fbdaa3e1 359 enable_read_block = false;
krishanprajapat 71:9193fbdaa3e1 360 enable_T_frame = false;
krishanprajapat 71:9193fbdaa3e1 361 if((segments_sent + 1) >= max_segments){
krishanprajapat 71:9193fbdaa3e1 362 adf_limit = true;
krishanprajapat 71:9193fbdaa3e1 363 segments_sent++;
krishanprajapat 71:9193fbdaa3e1 364 // gPC.printf("segments_sent = "<<segments_sent<<ENDL;
krishanprajapat 71:9193fbdaa3e1 365 gPC.printf("in for adf limit reached");
krishanprajapat 71:9193fbdaa3e1 366 }
krishanprajapat 71:9193fbdaa3e1 367 else{
krishanprajapat 71:9193fbdaa3e1 368 enable_new_segment = true;
krishanprajapat 71:9193fbdaa3e1 369 gPC.printf("data in next segment");
krishanprajapat 71:9193fbdaa3e1 370 segments_sent++;
krishanprajapat 71:9193fbdaa3e1 371 // cout<<"segments_sent = "<<segments_sent<<ENDL;
krishanprajapat 71:9193fbdaa3e1 372 }
krishanprajapat 71:9193fbdaa3e1 373 }
krishanprajapat 71:9193fbdaa3e1 374 else if(T_frames_sent > T_frames_in_segment){
krishanprajapat 71:9193fbdaa3e1 375 gPC.printf("error in enable T_frame");
krishanprajapat 71:9193fbdaa3e1 376 }
krishanprajapat 71:9193fbdaa3e1 377 }
krishanprajapat 71:9193fbdaa3e1 378 }
krishanprajapat 71:9193fbdaa3e1 379 else if(T_frames_sent > T_frames_in_segment){
krishanprajapat 71:9193fbdaa3e1 380 gPC.printf("error in if(read_success)");
krishanprajapat 71:9193fbdaa3e1 381 }
krishanprajapat 71:9193fbdaa3e1 382 }
krishanprajapat 71:9193fbdaa3e1 383 else{
krishanprajapat 71:9193fbdaa3e1 384 gPC.printf("error in enable T_frame");
krishanprajapat 71:9193fbdaa3e1 385 }
krishanprajapat 71:9193fbdaa3e1 386 }
krishanprajapat 71:9193fbdaa3e1 387 else if(adf_limit){
krishanprajapat 71:9193fbdaa3e1 388 buffer_112[counter_buffer_112] = EoS[counter_EoS++];
krishanprajapat 71:9193fbdaa3e1 389 if(counter_EoS == 120){
krishanprajapat 71:9193fbdaa3e1 390 // cout<<"EoS sent"<<ENDL;
krishanprajapat 71:9193fbdaa3e1 391 restart_adf();
krishanprajapat 71:9193fbdaa3e1 392 enable_new_segment = true;
krishanprajapat 71:9193fbdaa3e1 393 counter_EoS = 0;
krishanprajapat 71:9193fbdaa3e1 394 // cout<<"new session"<<ENDL;
krishanprajapat 71:9193fbdaa3e1 395 // cout<<"new segment"<<ENDL;
krishanprajapat 71:9193fbdaa3e1 396 T_frames_sent = 0;
krishanprajapat 71:9193fbdaa3e1 397 segments_sent = 0;
krishanprajapat 71:9193fbdaa3e1 398 adf_limit = false;
krishanprajapat 71:9193fbdaa3e1 399 }
krishanprajapat 71:9193fbdaa3e1 400 }
krishanprajapat 71:9193fbdaa3e1 401 else if(stop){
krishanprajapat 71:9193fbdaa3e1 402 // cout<<"Done bro"<<ENDL;
krishanprajapat 71:9193fbdaa3e1 403 break;
krishanprajapat 71:9193fbdaa3e1 404 }
krishanprajapat 71:9193fbdaa3e1 405 else if(enable_ackandcallsign){
krishanprajapat 71:9193fbdaa3e1 406 if(create_Ack_andcallsign){
krishanprajapat 71:9193fbdaa3e1 407 create_Ack_L234;
krishanprajapat 71:9193fbdaa3e1 408 Ack_L1 = get_Ack_L1();
krishanprajapat 71:9193fbdaa3e1 409 make_T_frame_Ack_andcallsign;
krishanprajapat 71:9193fbdaa3e1 410 create_Ack_andcallsign = false;
krishanprajapat 71:9193fbdaa3e1 411 }
krishanprajapat 71:9193fbdaa3e1 412 send_Ack_andcallsign;
krishanprajapat 71:9193fbdaa3e1 413 }
krishanprajapat 71:9193fbdaa3e1 414
krishanprajapat 71:9193fbdaa3e1 415 else if(enable_EoS){
krishanprajapat 71:9193fbdaa3e1 416 // send_EoS();
krishanprajapat 71:9193fbdaa3e1 417 buffer_112[counter_buffer_112] = EoS[counter_EoS++];
krishanprajapat 71:9193fbdaa3e1 418 if(counter_EoS == 120){
krishanprajapat 71:9193fbdaa3e1 419 // cout<<"segments_sent = "<<segments_sent<<ENDL;
krishanprajapat 71:9193fbdaa3e1 420 // cout<<"EoS sent"<<ENDL;
krishanprajapat 71:9193fbdaa3e1 421 counter_EoS = 0;
krishanprajapat 71:9193fbdaa3e1 422 enable_EoS=false;
krishanprajapat 71:9193fbdaa3e1 423 enable_new_segment = true;
krishanprajapat 71:9193fbdaa3e1 424 break;
krishanprajapat 71:9193fbdaa3e1 425 }
krishanprajapat 71:9193fbdaa3e1 426 else{
krishanprajapat 71:9193fbdaa3e1 427 gPC.printf("Error in enable EoS");
krishanprajapat 71:9193fbdaa3e1 428 }
krishanprajapat 71:9193fbdaa3e1 429 }
krishanprajapat 71:9193fbdaa3e1 430 else{
krishanprajapat 71:9193fbdaa3e1 431 gPC.printf("error in for loop");
krishanprajapat 71:9193fbdaa3e1 432 }
krishanprajapat 71:9193fbdaa3e1 433 if(enable_read_block && (!last_block)){
krishanprajapat 71:9193fbdaa3e1 434 if(short_TC){
krishanprajapat 71:9193fbdaa3e1 435 /*cout<<"reading"<<int(FSC)<<" "<<int(SID)<<ENDL;*/
krishanprajapat 71:9193fbdaa3e1 436 // for(int i=0;i<512;i++){
krishanprajapat 71:9193fbdaa3e1 437 // printf("0x%02X,",write_buffer[i]);
krishanprajapat 71:9193fbdaa3e1 438 // }
krishanprajapat 71:9193fbdaa3e1 439 int write_success = SD_WRITE(write_buffer,FSC + block_counter,SID);
krishanprajapat 71:9193fbdaa3e1 440 // wait_ms(8);
krishanprajapat 71:9193fbdaa3e1 441 read_success = SD_READ(buffer_512, FSC + block_counter,SID);
krishanprajapat 71:9193fbdaa3e1 442 // wait_ms(8);
krishanprajapat 71:9193fbdaa3e1 443 // cout<<"read_success = "<<read_success<<ENDL<<"\r\n";
krishanprajapat 71:9193fbdaa3e1 444 // cout<<"write_success = "<<write_success<<ENDL;
krishanprajapat 71:9193fbdaa3e1 445 // for(int i=0;i<512;i++){
krishanprajapat 71:9193fbdaa3e1 446 // printf("0x%02X,",buffer_512[i]);
krishanprajapat 71:9193fbdaa3e1 447 // }
krishanprajapat 71:9193fbdaa3e1 448 }
krishanprajapat 71:9193fbdaa3e1 449 else{
krishanprajapat 71:9193fbdaa3e1 450 read_success = SD_READ(buffer_512, list_of_FSC[block_counter],SID);
krishanprajapat 71:9193fbdaa3e1 451 }
krishanprajapat 71:9193fbdaa3e1 452 ack_code = read_success;
krishanprajapat 71:9193fbdaa3e1 453 block_counter++;
krishanprajapat 71:9193fbdaa3e1 454 if(block_counter == no_of_frames){
krishanprajapat 71:9193fbdaa3e1 455 last_block=true;
krishanprajapat 71:9193fbdaa3e1 456 }
krishanprajapat 71:9193fbdaa3e1 457 enable_read_block = false;
krishanprajapat 71:9193fbdaa3e1 458 if(read_success == 0){
krishanprajapat 71:9193fbdaa3e1 459 // cout<<"read one block successfully"<<" ";
krishanprajapat 71:9193fbdaa3e1 460 enable_T_frame = true;
krishanprajapat 71:9193fbdaa3e1 461 enable_SCH = true;
krishanprajapat 71:9193fbdaa3e1 462 }
krishanprajapat 71:9193fbdaa3e1 463 else if(ack_code == 0x85){
krishanprajapat 71:9193fbdaa3e1 464 gPC.printf("Hardware failure");
krishanprajapat 71:9193fbdaa3e1 465 enable_T_frame = false;
krishanprajapat 71:9193fbdaa3e1 466 }
krishanprajapat 71:9193fbdaa3e1 467 else if(ack_code == 0x86){
krishanprajapat 71:9193fbdaa3e1 468 gPC.printf("Invalid FSC");
krishanprajapat 71:9193fbdaa3e1 469 enable_T_frame = false;
krishanprajapat 71:9193fbdaa3e1 470 }
krishanprajapat 71:9193fbdaa3e1 471 else{
krishanprajapat 71:9193fbdaa3e1 472 gPC.printf("error Invalid ack code");
krishanprajapat 71:9193fbdaa3e1 473 enable_T_frame = false;
krishanprajapat 71:9193fbdaa3e1 474 stop = true;
krishanprajapat 71:9193fbdaa3e1 475 }
krishanprajapat 71:9193fbdaa3e1 476 }
krishanprajapat 71:9193fbdaa3e1 477 if((PA_HOT || (!valid_SID)|| (read_success != 0))&&(!enable_ackandcallsign)){
krishanprajapat 71:9193fbdaa3e1 478 enable_ackandcallsign = true;
krishanprajapat 71:9193fbdaa3e1 479 create_Ack_andcallsign = true;
krishanprajapat 71:9193fbdaa3e1 480 enable_T_frame = false;
krishanprajapat 71:9193fbdaa3e1 481 }
krishanprajapat 71:9193fbdaa3e1 482 }
krishanprajapat 71:9193fbdaa3e1 483 // for(int i=0;i<112;i++){
krishanprajapat 71:9193fbdaa3e1 484 // printf("0x%02X,",buffer_112[i]);
krishanprajapat 71:9193fbdaa3e1 485 // }
krishanprajapat 71:9193fbdaa3e1 486 differential_encode(buffer_112, 112);
krishanprajapat 71:9193fbdaa3e1 487 if(last_buffer ==true){
krishanprajapat 71:9193fbdaa3e1 488 diff_prev=0;
krishanprajapat 71:9193fbdaa3e1 489 }
krishanprajapat 71:9193fbdaa3e1 490 }
krishanprajapat 71:9193fbdaa3e1 491
krishanprajapat 71:9193fbdaa3e1 492 void execute_OBSRS_TC(Base_tc *tcp){
krishanprajapat 71:9193fbdaa3e1 493 short_TC = true;
krishanprajapat 71:9193fbdaa3e1 494 pc.printf("WELCOME\n\r");
krishanprajapat 71:9193fbdaa3e1 495 FCTN_CDMS_SD_INIT();/* sd card initialization*/
krishanprajapat 71:9193fbdaa3e1 496 // SID = 0x0;
krishanprajapat 71:9193fbdaa3e1 497 // FSC =10;
krishanprajapat 71:9193fbdaa3e1 498 // no_of_frames =1;
krishanprajapat 71:9193fbdaa3e1 499 // short_TC = true;
krishanprajapat 71:9193fbdaa3e1 500 // adf_SND_SDCard;
krishanprajapat 71:9193fbdaa3e1 501
krishanprajapat 71:9193fbdaa3e1 502 if( GETshort_or_long_tc(tcp) == SHORT_TC_CODE ){
krishanprajapat 71:9193fbdaa3e1 503 short_TC = true;
krishanprajapat 71:9193fbdaa3e1 504 }
krishanprajapat 71:9193fbdaa3e1 505 else{
krishanprajapat 71:9193fbdaa3e1 506 short_TC = false;
krishanprajapat 71:9193fbdaa3e1 507 }
krishanprajapat 71:9193fbdaa3e1 508 /* reading SID from TC */
krishanprajapat 71:9193fbdaa3e1 509 SID = (tcp->TC_string[2]) & 0x0f;
krishanprajapat 71:9193fbdaa3e1 510 /* reading FSC and no. of frames from TC */
krishanprajapat 71:9193fbdaa3e1 511 if(short_TC){
krishanprajapat 71:9193fbdaa3e1 512 FSC = tcp->TC_string[3] << 24;
krishanprajapat 71:9193fbdaa3e1 513 FSC += tcp->TC_string[4] << 16;
krishanprajapat 71:9193fbdaa3e1 514 FSC += tcp->TC_string[5] << 8;
krishanprajapat 71:9193fbdaa3e1 515 FSC += tcp->TC_string[6];
krishanprajapat 71:9193fbdaa3e1 516 no_of_frames = tcp->TC_string[7] << 8;
krishanprajapat 71:9193fbdaa3e1 517 no_of_frames += tcp->TC_string[8];
krishanprajapat 71:9193fbdaa3e1 518 }
krishanprajapat 71:9193fbdaa3e1 519 else{
krishanprajapat 71:9193fbdaa3e1 520 no_of_frames = tcp->TC_string[3];
krishanprajapat 71:9193fbdaa3e1 521 for(int i=0 ;i<no_of_frames ; i++){
krishanprajapat 71:9193fbdaa3e1 522 list_of_FSC[i] = tcp->TC_string[4+i];
krishanprajapat 71:9193fbdaa3e1 523 }
krishanprajapat 71:9193fbdaa3e1 524 }
krishanprajapat 71:9193fbdaa3e1 525 gPC.printf("sid = %u \r\n",SID);
krishanprajapat 71:9193fbdaa3e1 526 gPC.printf("FSC = %u\r\n",FSC);
krishanprajapat 71:9193fbdaa3e1 527 // cout<<"max_segments = "<<max_segments<<ENDL;
krishanprajapat 71:9193fbdaa3e1 528 //while(0){
krishanprajapat 71:9193fbdaa3e1 529 // while(!stop){
krishanprajapat 71:9193fbdaa3e1 530 // // send_call_sign();
krishanprajapat 71:9193fbdaa3e1 531 // if(short_TC){
krishanprajapat 71:9193fbdaa3e1 532 // send_tm_from_SD_card();
krishanprajapat 71:9193fbdaa3e1 533 // }
krishanprajapat 71:9193fbdaa3e1 534 // else{
krishanprajapat 71:9193fbdaa3e1 535 // send_tm_from_SD_card();
krishanprajapat 71:9193fbdaa3e1 536 // }
krishanprajapat 71:9193fbdaa3e1 537 // }
krishanprajapat 71:9193fbdaa3e1 538 }