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