publishing to check changes in cdms code
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE_samp_23SEP_DMA_flag by
OBSRS.h@140:be4eea8275c3, 2016-03-12 (annotated)
- Committer:
- ee12b079
- Date:
- Sat Mar 12 14:57:36 2016 +0000
- Revision:
- 140:be4eea8275c3
- Parent:
- 139:1018e1dc82e9
- Child:
- 142:83f48d1a1bc5
corrected some errors in obsrs.h
Who changed what in which revision?
User | Revision | Line number | New 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 |
ee12b079 | 113:b8991d9e3b6c | 11 | #define T_frames_in_segment 40 |
ee12b079 | 86:a26f5f22631d | 12 | |
ee12b079 | 86:a26f5f22631d | 13 | using namespace std; |
krishanprajapat | 127:8a7bee7b8e8b | 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; |
krishanprajapat | 127:8a7bee7b8e8b | 41 | //bool session_over = gFLAGS & COM_SESSION_TIMEOUT_FLAG; |
ee12b079 | 86:a26f5f22631d | 42 | |
ee12b079 | 86:a26f5f22631d | 43 | uint8_t SID ; |
ee12b079 | 86:a26f5f22631d | 44 | unsigned char buffer_112[112]; |
ee12b079 | 92:bce22b38c440 | 45 | uint32_t FSC; |
ee12b079 | 86:a26f5f22631d | 46 | uint16_t read_success = false; |
ee12b079 | 86:a26f5f22631d | 47 | uint16_t counter_buffer_112=0, counter_EoS=0,T_frames_sent=0; |
krishanprajapat | 123:457d6fd9ac37 | 48 | uint16_t counter_interleavedata=0; |
ee12b079 | 86:a26f5f22631d | 49 | uint16_t counter_buffer_512=0; |
ee12b079 | 86:a26f5f22631d | 50 | uint16_t max_segments = 65415/(48+T_frames_in_segment*159); |
ee12b079 | 86:a26f5f22631d | 51 | uint16_t ack_code = 0xA0; |
krishanprajapat | 123:457d6fd9ac37 | 52 | uint8_t segments_sent = 0; |
ee12b079 | 86:a26f5f22631d | 53 | uint8_t counter_SCH40 = 0; |
ee12b079 | 86:a26f5f22631d | 54 | uint8_t counter_FCCH80 = 0; |
ee12b079 | 86:a26f5f22631d | 55 | uint8_t counter_S_frame = 0; |
krishanprajapat | 123:457d6fd9ac37 | 56 | uint8_t T_frame_Ack_andcallsign_sent = 0; |
krishanprajapat | 123:457d6fd9ac37 | 57 | uint8_t T_frame_in_Ackandcallsign = 2; // needs to get from sukhdeep depends on size of Ack_L1 |
krishanprajapat | 123:457d6fd9ac37 | 58 | uint32_t block_counter = 0; |
ee12b079 | 88:b9beee1a7a3e | 59 | uint8_t no_of_frames =0; |
ee12b079 | 86:a26f5f22631d | 60 | |
ee12b079 | 86:a26f5f22631d | 61 | //#define max_segments = 65415/(48+T_frames_in_segment*159) |
ee12b079 | 86:a26f5f22631d | 62 | // 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 | 63 | // 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 | 64 | //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 | 65 | //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 | 66 | //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 | 67 | //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 | 68 | uint8_t buffer_512[512]; |
krishanprajapat | 123:457d6fd9ac37 | 69 | //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 | 70 | 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 | 119:2b5632bc78ab | 71 | //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 | 72 | //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 | 73 | //const unsigned char FCCH80[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; |
ee12b079 | 86:a26f5f22631d | 74 | //const unsigned char SCH40[] = {0x0a,0x3f,0x46,0xb4,0x00}; |
ee12b079 | 86:a26f5f22631d | 75 | |
ee12b079 | 86:a26f5f22631d | 76 | |
krishanprajapat | 127:8a7bee7b8e8b | 77 | #define get_ack_l234( tm_ptr ) {\ |
ee12b079 | 86:a26f5f22631d | 78 | Base_tm *ackl234new = new Short_tm;\ |
ee12b079 | 86:a26f5f22631d | 79 | ackl234new->next_TM = NULL;\ |
krishanprajapat | 127:8a7bee7b8e8b | 80 | tm_ptr = ackl234new;\ |
ee12b079 | 86:a26f5f22631d | 81 | /*return telemetry pointer here*/\ |
ee12b079 | 86:a26f5f22631d | 82 | ackl234new->TM_string[0] = TMID_ACK_L234 << 4;\ |
krishanprajapat | 127:8a7bee7b8e8b | 83 | ackl234new->TM_string[1] = GETpacket_seq_count(current_obsrs_tc);\ |
ee12b079 | 86:a26f5f22631d | 84 | ackl234new->TM_string[2] = ack_code; /* Ack code ....to be chnaged accordind to situation */\ |
ee12b079 | 86:a26f5f22631d | 85 | for(int i = 3; i < 11; ++i){\ |
ee12b079 | 86:a26f5f22631d | 86 | ackl234new->TM_string[i] = 0x00;\ |
ee12b079 | 86:a26f5f22631d | 87 | }\ |
ee12b079 | 86:a26f5f22631d | 88 | uint16_t crc = crc16_gen(ackl234new->TM_string, TM_SHORT_SIZE-2);\ |
ee12b079 | 86:a26f5f22631d | 89 | ackl234new->TM_string[11] = (crc & 0xFF00) >> 8;\ |
ee12b079 | 86:a26f5f22631d | 90 | ackl234new->TM_string[12] = crc & 0x00FF; \ |
ee12b079 | 86:a26f5f22631d | 91 | } |
ee12b079 | 86:a26f5f22631d | 92 | |
ee12b079 | 86:a26f5f22631d | 93 | void restart_adf(){ |
ee12b079 | 86:a26f5f22631d | 94 | |
ee12b079 | 86:a26f5f22631d | 95 | } |
ee12b079 | 86:a26f5f22631d | 96 | |
ee12b079 | 86:a26f5f22631d | 97 | int diff_prev; |
ee12b079 | 86:a26f5f22631d | 98 | void differential_encode(unsigned char* ptr, int length){ |
ee12b079 | 86:a26f5f22631d | 99 | for(int i=0; i<length;i++){ |
ee12b079 | 86:a26f5f22631d | 100 | unsigned char s = ptr[i] , t; |
ee12b079 | 86:a26f5f22631d | 101 | t = s ^ (s >> 1); |
ee12b079 | 86:a26f5f22631d | 102 | (diff_prev == 0) ? t=t^0x00 : t=t^0x80 ; |
ee12b079 | 86:a26f5f22631d | 103 | diff_prev = int(s & 0x01); |
ee12b079 | 86:a26f5f22631d | 104 | ptr[i] = t; |
ee12b079 | 86:a26f5f22631d | 105 | } |
ee12b079 | 86:a26f5f22631d | 106 | } |
ee12b079 | 86:a26f5f22631d | 107 | |
ee12b079 | 86:a26f5f22631d | 108 | #define check_PA_temp {\ |
ee12b079 | 86:a26f5f22631d | 109 | /* return 0 or 1*/\ |
ee12b079 | 86:a26f5f22631d | 110 | PA_HOT=0;\ |
ee12b079 | 86:a26f5f22631d | 111 | } |
ee12b079 | 86:a26f5f22631d | 112 | |
ee12b079 | 86:a26f5f22631d | 113 | |
krishanprajapat | 121:bd7263168ee4 | 114 | #define flags_init {\ |
krishanprajapat | 121:bd7263168ee4 | 115 | send_EoS_and_stop = false; \ |
krishanprajapat | 121:bd7263168ee4 | 116 | adf_limit = false;\ |
krishanprajapat | 121:bd7263168ee4 | 117 | stop = false;\ |
krishanprajapat | 121:bd7263168ee4 | 118 | PA_HOT=0;\ |
krishanprajapat | 121:bd7263168ee4 | 119 | short_TC;\ |
krishanprajapat | 121:bd7263168ee4 | 120 | valid_SID = true;\ |
krishanprajapat | 121:bd7263168ee4 | 121 | enable_call_sign = true;\ |
krishanprajapat | 121:bd7263168ee4 | 122 | enable_new_segment=true;\ |
krishanprajapat | 121:bd7263168ee4 | 123 | enable_S_frame = true;\ |
krishanprajapat | 121:bd7263168ee4 | 124 | enable_read_block = false;\ |
krishanprajapat | 121:bd7263168ee4 | 125 | enable_T_frame = false;\ |
krishanprajapat | 121:bd7263168ee4 | 126 | enable_Ack_andcallsign = false;\ |
krishanprajapat | 121:bd7263168ee4 | 127 | enable_ackandcallsign = false;\ |
krishanprajapat | 121:bd7263168ee4 | 128 | new_session =true;\ |
krishanprajapat | 121:bd7263168ee4 | 129 | enable_EoS=false;\ |
krishanprajapat | 121:bd7263168ee4 | 130 | create_Ack_andcallsign = true;\ |
krishanprajapat | 121:bd7263168ee4 | 131 | Ack_andcallsign_over = false;\ |
krishanprajapat | 121:bd7263168ee4 | 132 | repeat_last_2T_frames = false;\ |
krishanprajapat | 121:bd7263168ee4 | 133 | last_block = false;\ |
krishanprajapat | 121:bd7263168ee4 | 134 | last_buffer = false;\ |
krishanprajapat | 121:bd7263168ee4 | 135 | new_OBSRS_TC = true;\ |
krishanprajapat | 121:bd7263168ee4 | 136 | enable_SCH = true;\ |
krishanprajapat | 121:bd7263168ee4 | 137 | enable_FCCH = false;\ |
krishanprajapat | 121:bd7263168ee4 | 138 | enable_DS = false;\ |
krishanprajapat | 121:bd7263168ee4 | 139 | half_buffer = 0;\ |
krishanprajapat | 121:bd7263168ee4 | 140 | read_success = false;\ |
krishanprajapat | 121:bd7263168ee4 | 141 | counter_buffer_112=0;\ |
krishanprajapat | 121:bd7263168ee4 | 142 | counter_EoS=0;\ |
krishanprajapat | 121:bd7263168ee4 | 143 | T_frames_sent=0;\ |
krishanprajapat | 123:457d6fd9ac37 | 144 | counter_interleavedata=0;\ |
krishanprajapat | 121:bd7263168ee4 | 145 | counter_buffer_512=0;\ |
krishanprajapat | 121:bd7263168ee4 | 146 | ack_code = 0xA0;\ |
krishanprajapat | 121:bd7263168ee4 | 147 | segments_sent = 0;\ |
krishanprajapat | 121:bd7263168ee4 | 148 | counter_SCH40 = 0;\ |
krishanprajapat | 121:bd7263168ee4 | 149 | counter_FCCH80 = 0;\ |
krishanprajapat | 121:bd7263168ee4 | 150 | counter_S_frame = 0;\ |
krishanprajapat | 121:bd7263168ee4 | 151 | T_frame_Ack_andcallsign_sent = 0;\ |
krishanprajapat | 121:bd7263168ee4 | 152 | T_frame_in_Ackandcallsign = 4;\ |
krishanprajapat | 121:bd7263168ee4 | 153 | block_counter = 0;\ |
krishanprajapat | 121:bd7263168ee4 | 154 | no_of_frames =0;\ |
krishanprajapat | 121:bd7263168ee4 | 155 | } |
krishanprajapat | 121:bd7263168ee4 | 156 | |
krishanprajapat | 123:457d6fd9ac37 | 157 | #define send_Ack_andcallsign {\ |
ee12b079 | 86:a26f5f22631d | 158 | if(T_frames_sent < T_frames_in_segment){\ |
krishanprajapat | 123:457d6fd9ac37 | 159 | if (enable_SCH)\ |
krishanprajapat | 123:457d6fd9ac37 | 160 | {\ |
krishanprajapat | 123:457d6fd9ac37 | 161 | buffer_112[counter_buffer_112] = SCH40[counter_SCH40++];\ |
krishanprajapat | 123:457d6fd9ac37 | 162 | if (counter_SCH40 == 5)\ |
krishanprajapat | 123:457d6fd9ac37 | 163 | { \ |
krishanprajapat | 123:457d6fd9ac37 | 164 | counter_SCH40 = 0;\ |
krishanprajapat | 123:457d6fd9ac37 | 165 | enable_SCH = false;\ |
krishanprajapat | 123:457d6fd9ac37 | 166 | enable_DS = true;\ |
krishanprajapat | 123:457d6fd9ac37 | 167 | }\ |
krishanprajapat | 123:457d6fd9ac37 | 168 | }\ |
krishanprajapat | 123:457d6fd9ac37 | 169 | else if (enable_DS)\ |
krishanprajapat | 123:457d6fd9ac37 | 170 | {\ |
krishanprajapat | 123:457d6fd9ac37 | 171 | buffer_112[counter_buffer_112] = interleave_data[half_buffer][counter_interleavedata++];\ |
krishanprajapat | 123:457d6fd9ac37 | 172 | if (counter_interleavedata == 144)\ |
krishanprajapat | 123:457d6fd9ac37 | 173 | { \ |
krishanprajapat | 123:457d6fd9ac37 | 174 | enable_DS = false;\ |
krishanprajapat | 123:457d6fd9ac37 | 175 | enable_FCCH = true;\ |
krishanprajapat | 123:457d6fd9ac37 | 176 | }\ |
krishanprajapat | 123:457d6fd9ac37 | 177 | }\ |
krishanprajapat | 123:457d6fd9ac37 | 178 | else if (enable_FCCH)\ |
krishanprajapat | 123:457d6fd9ac37 | 179 | {\ |
krishanprajapat | 123:457d6fd9ac37 | 180 | buffer_112[counter_buffer_112] = FCCH80[counter_FCCH80++];\ |
krishanprajapat | 123:457d6fd9ac37 | 181 | if (counter_FCCH80 == 10)\ |
krishanprajapat | 123:457d6fd9ac37 | 182 | {\ |
krishanprajapat | 123:457d6fd9ac37 | 183 | enable_FCCH = false;\ |
krishanprajapat | 123:457d6fd9ac37 | 184 | if(half_buffer == 0){\ |
krishanprajapat | 123:457d6fd9ac37 | 185 | enable_SCH = true;\ |
krishanprajapat | 123:457d6fd9ac37 | 186 | half_buffer = 1;\ |
krishanprajapat | 123:457d6fd9ac37 | 187 | counter_FCCH80 = 0;\ |
ee12b079 | 140:be4eea8275c3 | 188 | counter_interleavedata = 0;\ |
krishanprajapat | 123:457d6fd9ac37 | 189 | }\ |
krishanprajapat | 123:457d6fd9ac37 | 190 | }\ |
krishanprajapat | 123:457d6fd9ac37 | 191 | }\ |
krishanprajapat | 123:457d6fd9ac37 | 192 | if((counter_interleavedata == 144 ) && (half_buffer == 1)){\ |
krishanprajapat | 123:457d6fd9ac37 | 193 | counter_interleavedata = 0;\ |
krishanprajapat | 123:457d6fd9ac37 | 194 | half_buffer = 0;\ |
ee12b079 | 86:a26f5f22631d | 195 | T_frames_sent = T_frames_sent +2;\ |
ee12b079 | 86:a26f5f22631d | 196 | if(repeat_last_2T_frames){\ |
ee12b079 | 86:a26f5f22631d | 197 | /*cout<<"repeated last two T frames"<<" ";*/\ |
ee12b079 | 86:a26f5f22631d | 198 | /*cout<<"T_frames_sent = "<<T_frames_sent<<ENDL;*/\ |
ee12b079 | 86:a26f5f22631d | 199 | }\ |
ee12b079 | 86:a26f5f22631d | 200 | else{\ |
ee12b079 | 86:a26f5f22631d | 201 | /*cout<<"Ackandcallsign sent"<<" ";*/\ |
ee12b079 | 86:a26f5f22631d | 202 | /*cout<<"T_frames_sent = "<<T_frames_sent<<ENDL;*/\ |
ee12b079 | 86:a26f5f22631d | 203 | T_frame_Ack_andcallsign_sent = T_frame_Ack_andcallsign_sent + 2;\ |
ee12b079 | 86:a26f5f22631d | 204 | if(T_frame_Ack_andcallsign_sent == T_frame_in_Ackandcallsign ){\ |
ee12b079 | 86:a26f5f22631d | 205 | repeat_last_2T_frames = true;\ |
ee12b079 | 86:a26f5f22631d | 206 | }\ |
ee12b079 | 86:a26f5f22631d | 207 | else if(T_frame_Ack_andcallsign_sent < T_frame_in_Ackandcallsign){\ |
krishanprajapat | 123:457d6fd9ac37 | 208 | T_frame_in_Ackandcallsign = 2*snd_tm.make_shor_tm();\ |
krishanprajapat | 122:b99f8be0a51a | 209 | enable_SCH = true;\ |
ee12b079 | 86:a26f5f22631d | 210 | }\ |
ee12b079 | 86:a26f5f22631d | 211 | else{\ |
krishanprajapat | 122:b99f8be0a51a | 212 | /*cout<<"error in send_Ack_andcallsign if T_frames_sent < T_frames_in_segment"<<ENDL;*/\ |
ee12b079 | 86:a26f5f22631d | 213 | }\ |
ee12b079 | 86:a26f5f22631d | 214 | }\ |
ee12b079 | 86:a26f5f22631d | 215 | if(T_frames_sent == T_frames_in_segment){\ |
ee12b079 | 86:a26f5f22631d | 216 | if(T_frame_Ack_andcallsign_sent < T_frame_in_Ackandcallsign){\ |
ee12b079 | 86:a26f5f22631d | 217 | if(segments_sent + 1>= max_segments){\ |
ee12b079 | 86:a26f5f22631d | 218 | adf_limit = true;\ |
ee12b079 | 86:a26f5f22631d | 219 | segments_sent = 0;\ |
ee12b079 | 86:a26f5f22631d | 220 | /*cout<<"adf limit reached"<<ENDL;*/\ |
ee12b079 | 86:a26f5f22631d | 221 | }\ |
ee12b079 | 86:a26f5f22631d | 222 | else{\ |
ee12b079 | 86:a26f5f22631d | 223 | enable_new_segment = true;\ |
ee12b079 | 86:a26f5f22631d | 224 | /*cout<<"new segment"<<ENDL;*/\ |
ee12b079 | 86:a26f5f22631d | 225 | }\ |
ee12b079 | 86:a26f5f22631d | 226 | }\ |
ee12b079 | 86:a26f5f22631d | 227 | else{\ |
krishanprajapat | 122:b99f8be0a51a | 228 | send_EoS_and_stop = true; \ |
ee12b079 | 86:a26f5f22631d | 229 | } \ |
ee12b079 | 86:a26f5f22631d | 230 | }\ |
ee12b079 | 86:a26f5f22631d | 231 | }\ |
ee12b079 | 86:a26f5f22631d | 232 | }\ |
ee12b079 | 86:a26f5f22631d | 233 | else if(send_EoS_and_stop){\ |
ee12b079 | 86:a26f5f22631d | 234 | buffer_112[counter_buffer_112] = EoS[counter_EoS++];\ |
ee12b079 | 86:a26f5f22631d | 235 | if(counter_EoS == 120){\ |
ee12b079 | 86:a26f5f22631d | 236 | /*cout<<"segments_sent = "<<segments_sent<<ENDL;*/\ |
ee12b079 | 86:a26f5f22631d | 237 | /*cout<<"EoS sent"<<ENDL;*/\ |
ee12b079 | 86:a26f5f22631d | 238 | counter_EoS = 0;\ |
ee12b079 | 86:a26f5f22631d | 239 | enable_ackandcallsign = false;\ |
ee12b079 | 86:a26f5f22631d | 240 | stop =true;\ |
ee12b079 | 86:a26f5f22631d | 241 | last_buffer = true;\ |
ee12b079 | 86:a26f5f22631d | 242 | }\ |
ee12b079 | 86:a26f5f22631d | 243 | }\ |
ee12b079 | 86:a26f5f22631d | 244 | else if(adf_limit){\ |
ee12b079 | 86:a26f5f22631d | 245 | buffer_112[counter_buffer_112] = EoS[counter_EoS++];\ |
ee12b079 | 86:a26f5f22631d | 246 | if(counter_EoS == 120){\ |
ee12b079 | 86:a26f5f22631d | 247 | counter_EoS = 0;\ |
ee12b079 | 86:a26f5f22631d | 248 | /*cout<<"EoS sent"<<ENDL;*/\ |
ee12b079 | 86:a26f5f22631d | 249 | restart_adf();\ |
ee12b079 | 86:a26f5f22631d | 250 | enable_new_segment = true;\ |
ee12b079 | 86:a26f5f22631d | 251 | /*cout<<"new session"<<ENDL;*/\ |
ee12b079 | 86:a26f5f22631d | 252 | /*cout<<"new segment"<<ENDL;*/\ |
ee12b079 | 86:a26f5f22631d | 253 | T_frames_sent = 0;\ |
ee12b079 | 86:a26f5f22631d | 254 | segments_sent = 0; \ |
ee12b079 | 86:a26f5f22631d | 255 | adf_limit = false;\ |
ee12b079 | 86:a26f5f22631d | 256 | }\ |
ee12b079 | 86:a26f5f22631d | 257 | }\ |
ee12b079 | 86:a26f5f22631d | 258 | else{\ |
ee12b079 | 86:a26f5f22631d | 259 | gPC.printf("error in send_Ack_andcallsign()");\ |
ee12b079 | 86:a26f5f22631d | 260 | }\ |
ee12b079 | 86:a26f5f22631d | 261 | } |
ee12b079 | 86:a26f5f22631d | 262 | #define send_S_frame {\ |
ee12b079 | 86:a26f5f22631d | 263 | buffer_112[counter_buffer_112] = S_frame[counter_S_frame++];\ |
ee12b079 | 86:a26f5f22631d | 264 | if(counter_S_frame == 48){\ |
ee12b079 | 86:a26f5f22631d | 265 | enable_new_segment=false;\ |
ee12b079 | 86:a26f5f22631d | 266 | counter_S_frame = 0;\ |
ee12b079 | 86:a26f5f22631d | 267 | /*cout<<"S_frame_sent"<<ENDL;*/\ |
ee12b079 | 86:a26f5f22631d | 268 | if(new_OBSRS_TC){\ |
ee12b079 | 86:a26f5f22631d | 269 | enable_call_sign = true;\ |
krishanprajapat | 127:8a7bee7b8e8b | 270 | new_OBSRS_TC = false;\ |
krishanprajapat | 118:60c5de4cb8ad | 271 | get_call_sign(callsign);\ |
krishanprajapat | 119:2b5632bc78ab | 272 | snd_tm.head_pointer(callsign);\ |
ee12b079 | 139:1018e1dc82e9 | 273 | int temp = snd_tm.make_shor_tm();\ |
krishanprajapat | 127:8a7bee7b8e8b | 274 | delete callsign;\ |
ee12b079 | 140:be4eea8275c3 | 275 | gPC.printf("new tc\r\n");\ |
ee12b079 | 86:a26f5f22631d | 276 | }\ |
ee12b079 | 86:a26f5f22631d | 277 | else{\ |
ee12b079 | 86:a26f5f22631d | 278 | enable_read_block = true;\ |
ee12b079 | 86:a26f5f22631d | 279 | }\ |
ee12b079 | 86:a26f5f22631d | 280 | }\ |
ee12b079 | 86:a26f5f22631d | 281 | } |
ee12b079 | 86:a26f5f22631d | 282 | |
ee12b079 | 86:a26f5f22631d | 283 | #define send_call_sign {\ |
krishanprajapat | 119:2b5632bc78ab | 284 | if (enable_SCH)\ |
krishanprajapat | 119:2b5632bc78ab | 285 | {\ |
krishanprajapat | 119:2b5632bc78ab | 286 | buffer_112[counter_buffer_112] = SCH40[counter_SCH40++];\ |
krishanprajapat | 119:2b5632bc78ab | 287 | if (counter_SCH40 == 5)\ |
krishanprajapat | 119:2b5632bc78ab | 288 | { \ |
krishanprajapat | 119:2b5632bc78ab | 289 | counter_SCH40 = 0;\ |
ee12b079 | 140:be4eea8275c3 | 290 | gPC.printf("sch40 sent\r\n");\ |
krishanprajapat | 119:2b5632bc78ab | 291 | enable_SCH = false;\ |
krishanprajapat | 119:2b5632bc78ab | 292 | enable_DS = true;\ |
krishanprajapat | 119:2b5632bc78ab | 293 | }\ |
krishanprajapat | 119:2b5632bc78ab | 294 | }\ |
krishanprajapat | 119:2b5632bc78ab | 295 | else if (enable_DS)\ |
krishanprajapat | 119:2b5632bc78ab | 296 | {\ |
krishanprajapat | 123:457d6fd9ac37 | 297 | buffer_112[counter_buffer_112] = interleave_data[half_buffer][counter_interleavedata++];\ |
ee12b079 | 140:be4eea8275c3 | 298 | gPC.printf("sending ds\r\n");\ |
krishanprajapat | 123:457d6fd9ac37 | 299 | if (counter_interleavedata == 144)\ |
krishanprajapat | 119:2b5632bc78ab | 300 | { \ |
krishanprajapat | 119:2b5632bc78ab | 301 | enable_DS = false;\ |
krishanprajapat | 119:2b5632bc78ab | 302 | enable_FCCH = true;\ |
ee12b079 | 140:be4eea8275c3 | 303 | counter_interleavedata = 0;\ |
ee12b079 | 140:be4eea8275c3 | 304 | gPC.printf("ds sent sent\r\n");\ |
krishanprajapat | 119:2b5632bc78ab | 305 | }\ |
krishanprajapat | 119:2b5632bc78ab | 306 | }\ |
krishanprajapat | 119:2b5632bc78ab | 307 | else if (enable_FCCH)\ |
krishanprajapat | 119:2b5632bc78ab | 308 | {\ |
krishanprajapat | 119:2b5632bc78ab | 309 | buffer_112[counter_buffer_112] = FCCH80[counter_FCCH80++];\ |
krishanprajapat | 119:2b5632bc78ab | 310 | if (counter_FCCH80 == 10)\ |
krishanprajapat | 119:2b5632bc78ab | 311 | {\ |
krishanprajapat | 119:2b5632bc78ab | 312 | enable_FCCH = false;\ |
krishanprajapat | 119:2b5632bc78ab | 313 | if(half_buffer == 0){\ |
krishanprajapat | 119:2b5632bc78ab | 314 | enable_SCH = true;\ |
krishanprajapat | 119:2b5632bc78ab | 315 | half_buffer = 1;\ |
krishanprajapat | 119:2b5632bc78ab | 316 | counter_FCCH80 = 0;\ |
ee12b079 | 140:be4eea8275c3 | 317 | gPC.printf("fcch sent\r\n");\ |
krishanprajapat | 119:2b5632bc78ab | 318 | }\ |
krishanprajapat | 119:2b5632bc78ab | 319 | }\ |
krishanprajapat | 119:2b5632bc78ab | 320 | }\ |
krishanprajapat | 123:457d6fd9ac37 | 321 | if((counter_interleavedata == 144) && (half_buffer ==1)){\ |
krishanprajapat | 123:457d6fd9ac37 | 322 | counter_interleavedata = 0;\ |
krishanprajapat | 119:2b5632bc78ab | 323 | half_buffer =0;\ |
ee12b079 | 140:be4eea8275c3 | 324 | enable_call_sign = false;\ |
ee12b079 | 86:a26f5f22631d | 325 | new_session =false;\ |
ee12b079 | 86:a26f5f22631d | 326 | /*cout<<"call_sign_sent"<<" ";*/\ |
ee12b079 | 86:a26f5f22631d | 327 | T_frames_sent = T_frames_sent+2;\ |
krishanprajapat | 119:2b5632bc78ab | 328 | if(SID==0x1 || SID==0x2 || SID==0x3 || SID==0x4 || SID==0x5){\ |
ee12b079 | 86:a26f5f22631d | 329 | valid_SID=true;\ |
ee12b079 | 86:a26f5f22631d | 330 | /*cout<<"valid SID"<<ENDL;*/\ |
ee12b079 | 86:a26f5f22631d | 331 | }\ |
ee12b079 | 86:a26f5f22631d | 332 | else{\ |
ee12b079 | 86:a26f5f22631d | 333 | valid_SID=false;\ |
ee12b079 | 92:bce22b38c440 | 334 | /*gPC.printf("invalid SID");*/\ |
ee12b079 | 86:a26f5f22631d | 335 | enable_ackandcallsign = true;\ |
ee12b079 | 86:a26f5f22631d | 336 | create_Ack_andcallsign = true;\ |
ee12b079 | 86:a26f5f22631d | 337 | ack_code = 0x02;\ |
ee12b079 | 86:a26f5f22631d | 338 | }\ |
ee12b079 | 86:a26f5f22631d | 339 | check_PA_temp;\ |
ee12b079 | 86:a26f5f22631d | 340 | /*cout<<"pa_hot = "<<PA_HOT<<ENDL;*/\ |
ee12b079 | 86:a26f5f22631d | 341 | if(PA_HOT){\ |
ee12b079 | 86:a26f5f22631d | 342 | enable_ackandcallsign = true;\ |
ee12b079 | 86:a26f5f22631d | 343 | create_Ack_andcallsign = true;\ |
ee12b079 | 86:a26f5f22631d | 344 | enable_read_block = false;\ |
ee12b079 | 86:a26f5f22631d | 345 | }\ |
ee12b079 | 86:a26f5f22631d | 346 | else{\ |
ee12b079 | 86:a26f5f22631d | 347 | enable_read_block = true;\ |
ee12b079 | 86:a26f5f22631d | 348 | enable_ackandcallsign = false;\ |
ee12b079 | 86:a26f5f22631d | 349 | }\ |
ee12b079 | 86:a26f5f22631d | 350 | }\ |
ee12b079 | 86:a26f5f22631d | 351 | } |
ee12b079 | 86:a26f5f22631d | 352 | |
ee12b079 | 86:a26f5f22631d | 353 | |
ee12b079 | 140:be4eea8275c3 | 354 | |
ee12b079 | 95:42d6747900cb | 355 | void send_tm_from_SD_card_fun(){ |
ee12b079 | 86:a26f5f22631d | 356 | for(counter_buffer_112=0;counter_buffer_112<112;counter_buffer_112++){ |
ee12b079 | 86:a26f5f22631d | 357 | if(enable_new_segment){ // starting new segment |
ee12b079 | 86:a26f5f22631d | 358 | send_S_frame; |
ee12b079 | 86:a26f5f22631d | 359 | T_frames_sent=0; |
ee12b079 | 86:a26f5f22631d | 360 | } |
ee12b079 | 86:a26f5f22631d | 361 | else if(enable_call_sign){ // sending call sign |
ee12b079 | 86:a26f5f22631d | 362 | send_call_sign ; |
ee12b079 | 86:a26f5f22631d | 363 | } |
ee12b079 | 86:a26f5f22631d | 364 | else if(enable_T_frame){ |
ee12b079 | 86:a26f5f22631d | 365 | if(read_success == 0){ |
ee12b079 | 86:a26f5f22631d | 366 | if(T_frames_sent < T_frames_in_segment){ |
ee12b079 | 86:a26f5f22631d | 367 | if (enable_SCH) |
ee12b079 | 86:a26f5f22631d | 368 | { |
ee12b079 | 86:a26f5f22631d | 369 | buffer_112[counter_buffer_112] = SCH40[counter_SCH40++]; |
ee12b079 | 86:a26f5f22631d | 370 | if (counter_SCH40 == 5) |
ee12b079 | 86:a26f5f22631d | 371 | { |
ee12b079 | 86:a26f5f22631d | 372 | // cout<<"sch sent"<<ENDL; |
ee12b079 | 86:a26f5f22631d | 373 | counter_SCH40 = 0; |
ee12b079 | 86:a26f5f22631d | 374 | enable_SCH = false; |
ee12b079 | 86:a26f5f22631d | 375 | enable_DS = true; |
ee12b079 | 86:a26f5f22631d | 376 | } |
ee12b079 | 86:a26f5f22631d | 377 | } |
ee12b079 | 86:a26f5f22631d | 378 | else if (enable_DS) |
ee12b079 | 86:a26f5f22631d | 379 | { |
ee12b079 | 86:a26f5f22631d | 380 | buffer_112[counter_buffer_112] = buffer_512[counter_buffer_512++]; |
ee12b079 | 86:a26f5f22631d | 381 | if ((counter_buffer_512 == 288) || (counter_buffer_512 == 144)) |
ee12b079 | 86:a26f5f22631d | 382 | { |
ee12b079 | 86:a26f5f22631d | 383 | // cout<<"ds sent"<<ENDL; |
ee12b079 | 86:a26f5f22631d | 384 | // counter_buffer_512 = 0; |
ee12b079 | 86:a26f5f22631d | 385 | enable_DS = false; |
ee12b079 | 86:a26f5f22631d | 386 | enable_FCCH = true; |
ee12b079 | 86:a26f5f22631d | 387 | } |
ee12b079 | 86:a26f5f22631d | 388 | } |
ee12b079 | 86:a26f5f22631d | 389 | else if (enable_FCCH) |
ee12b079 | 86:a26f5f22631d | 390 | { |
ee12b079 | 86:a26f5f22631d | 391 | buffer_112[counter_buffer_112] = FCCH80[counter_FCCH80++]; |
ee12b079 | 86:a26f5f22631d | 392 | if (counter_FCCH80 == 10) |
ee12b079 | 86:a26f5f22631d | 393 | { |
ee12b079 | 86:a26f5f22631d | 394 | // cout<<"fcch sent"<<ENDL; |
ee12b079 | 86:a26f5f22631d | 395 | enable_FCCH = false; |
ee12b079 | 86:a26f5f22631d | 396 | if(counter_buffer_512 == 144){ |
ee12b079 | 86:a26f5f22631d | 397 | enable_SCH = true; |
ee12b079 | 86:a26f5f22631d | 398 | counter_FCCH80 = 0; |
ee12b079 | 86:a26f5f22631d | 399 | } |
ee12b079 | 86:a26f5f22631d | 400 | else{ |
ee12b079 | 86:a26f5f22631d | 401 | |
ee12b079 | 86:a26f5f22631d | 402 | } |
ee12b079 | 86:a26f5f22631d | 403 | } |
ee12b079 | 86:a26f5f22631d | 404 | } |
ee12b079 | 86:a26f5f22631d | 405 | if((counter_FCCH80 == 10)&&(counter_buffer_512 == 288)){ |
ee12b079 | 86:a26f5f22631d | 406 | counter_FCCH80 = 0; |
ee12b079 | 86:a26f5f22631d | 407 | counter_buffer_512 = 0; |
ee12b079 | 86:a26f5f22631d | 408 | T_frames_sent = T_frames_sent+2; |
ee12b079 | 86:a26f5f22631d | 409 | // cout<<"T_frames_sent "<<T_frames_sent<<ENDL; |
ee12b079 | 86:a26f5f22631d | 410 | if(last_block){ |
ee12b079 | 86:a26f5f22631d | 411 | // cout<<"last block"<<endl<<"\r"; |
ee12b079 | 86:a26f5f22631d | 412 | enable_read_block = false; |
ee12b079 | 86:a26f5f22631d | 413 | enable_T_frame = false; |
ee12b079 | 86:a26f5f22631d | 414 | enable_ackandcallsign = true; |
ee12b079 | 86:a26f5f22631d | 415 | create_Ack_andcallsign = true; |
ee12b079 | 86:a26f5f22631d | 416 | if(T_frames_sent == T_frames_in_segment){ |
ee12b079 | 86:a26f5f22631d | 417 | if(segments_sent + 1>= max_segments){ |
ee12b079 | 86:a26f5f22631d | 418 | adf_limit = true; |
ee12b079 | 86:a26f5f22631d | 419 | segments_sent = 0; |
ee12b079 | 92:bce22b38c440 | 420 | // gPC.printf("adf limit reached here"); |
ee12b079 | 86:a26f5f22631d | 421 | } |
ee12b079 | 86:a26f5f22631d | 422 | else{ |
ee12b079 | 86:a26f5f22631d | 423 | enable_new_segment = true; |
ee12b079 | 86:a26f5f22631d | 424 | // cout<<"new segment"<<ENDL; |
ee12b079 | 86:a26f5f22631d | 425 | } |
ee12b079 | 86:a26f5f22631d | 426 | } |
ee12b079 | 86:a26f5f22631d | 427 | continue; |
ee12b079 | 86:a26f5f22631d | 428 | } |
ee12b079 | 86:a26f5f22631d | 429 | else{ |
ee12b079 | 86:a26f5f22631d | 430 | check_PA_temp; |
ee12b079 | 86:a26f5f22631d | 431 | // cout<<"pa_hot = "<<PA_HOT<<" "; |
ee12b079 | 86:a26f5f22631d | 432 | if(PA_HOT){ |
ee12b079 | 86:a26f5f22631d | 433 | enable_T_frame = false; |
ee12b079 | 86:a26f5f22631d | 434 | enable_read_block = false; |
ee12b079 | 86:a26f5f22631d | 435 | enable_ackandcallsign = true; |
ee12b079 | 86:a26f5f22631d | 436 | create_Ack_andcallsign = true; |
ee12b079 | 86:a26f5f22631d | 437 | } |
ee12b079 | 86:a26f5f22631d | 438 | else{ |
ee12b079 | 86:a26f5f22631d | 439 | enable_read_block = true; |
ee12b079 | 86:a26f5f22631d | 440 | } |
ee12b079 | 86:a26f5f22631d | 441 | } |
ee12b079 | 86:a26f5f22631d | 442 | if(T_frames_sent == T_frames_in_segment){ |
ee12b079 | 86:a26f5f22631d | 443 | enable_read_block = false; |
ee12b079 | 86:a26f5f22631d | 444 | enable_T_frame = false; |
ee12b079 | 86:a26f5f22631d | 445 | if((segments_sent + 1) >= max_segments){ |
ee12b079 | 86:a26f5f22631d | 446 | adf_limit = true; |
ee12b079 | 86:a26f5f22631d | 447 | segments_sent++; |
ee12b079 | 86:a26f5f22631d | 448 | // gPC.printf("segments_sent = "<<segments_sent<<ENDL; |
ee12b079 | 140:be4eea8275c3 | 449 | // gPC.printf("in for adf lim reached"); |
ee12b079 | 86:a26f5f22631d | 450 | } |
ee12b079 | 86:a26f5f22631d | 451 | else{ |
ee12b079 | 86:a26f5f22631d | 452 | enable_new_segment = true; |
ee12b079 | 92:bce22b38c440 | 453 | // gPC.printf("data in next segment"); |
ee12b079 | 86:a26f5f22631d | 454 | segments_sent++; |
ee12b079 | 86:a26f5f22631d | 455 | // cout<<"segments_sent = "<<segments_sent<<ENDL; |
ee12b079 | 86:a26f5f22631d | 456 | } |
ee12b079 | 86:a26f5f22631d | 457 | } |
ee12b079 | 86:a26f5f22631d | 458 | else if(T_frames_sent > T_frames_in_segment){ |
ee12b079 | 86:a26f5f22631d | 459 | gPC.printf("error in enable T_frame"); |
ee12b079 | 86:a26f5f22631d | 460 | } |
ee12b079 | 86:a26f5f22631d | 461 | } |
ee12b079 | 86:a26f5f22631d | 462 | } |
ee12b079 | 86:a26f5f22631d | 463 | else if(T_frames_sent > T_frames_in_segment){ |
ee12b079 | 86:a26f5f22631d | 464 | gPC.printf("error in if(read_success)"); |
ee12b079 | 86:a26f5f22631d | 465 | } |
ee12b079 | 86:a26f5f22631d | 466 | } |
ee12b079 | 86:a26f5f22631d | 467 | else{ |
ee12b079 | 86:a26f5f22631d | 468 | gPC.printf("error in enable T_frame"); |
ee12b079 | 86:a26f5f22631d | 469 | } |
ee12b079 | 86:a26f5f22631d | 470 | } |
ee12b079 | 86:a26f5f22631d | 471 | else if(adf_limit){ |
ee12b079 | 86:a26f5f22631d | 472 | buffer_112[counter_buffer_112] = EoS[counter_EoS++]; |
ee12b079 | 86:a26f5f22631d | 473 | if(counter_EoS == 120){ |
ee12b079 | 86:a26f5f22631d | 474 | // cout<<"EoS sent"<<ENDL; |
ee12b079 | 86:a26f5f22631d | 475 | restart_adf(); |
ee12b079 | 86:a26f5f22631d | 476 | enable_new_segment = true; |
ee12b079 | 86:a26f5f22631d | 477 | counter_EoS = 0; |
ee12b079 | 86:a26f5f22631d | 478 | // cout<<"new session"<<ENDL; |
ee12b079 | 86:a26f5f22631d | 479 | // cout<<"new segment"<<ENDL; |
ee12b079 | 86:a26f5f22631d | 480 | T_frames_sent = 0; |
ee12b079 | 86:a26f5f22631d | 481 | segments_sent = 0; |
ee12b079 | 86:a26f5f22631d | 482 | adf_limit = false; |
ee12b079 | 86:a26f5f22631d | 483 | } |
ee12b079 | 86:a26f5f22631d | 484 | } |
ee12b079 | 86:a26f5f22631d | 485 | else if(stop){ |
ee12b079 | 86:a26f5f22631d | 486 | // cout<<"Done bro"<<ENDL; |
ee12b079 | 86:a26f5f22631d | 487 | break; |
ee12b079 | 86:a26f5f22631d | 488 | } |
ee12b079 | 86:a26f5f22631d | 489 | else if(enable_ackandcallsign){ |
ee12b079 | 86:a26f5f22631d | 490 | if(create_Ack_andcallsign){ |
krishanprajapat | 122:b99f8be0a51a | 491 | enable_SCH = true; |
ee12b079 | 86:a26f5f22631d | 492 | create_Ack_andcallsign = false; |
krishanprajapat | 127:8a7bee7b8e8b | 493 | Base_tm *ack_and_callsign = NULL; |
krishanprajapat | 127:8a7bee7b8e8b | 494 | Base_tm *ack_head = NULL; |
krishanprajapat | 127:8a7bee7b8e8b | 495 | get_call_sign(ack_and_callsign); |
krishanprajapat | 127:8a7bee7b8e8b | 496 | ack_head = ack_and_callsign; |
krishanprajapat | 127:8a7bee7b8e8b | 497 | get_ack_l1(ack_and_callsign->next_TM); |
krishanprajapat | 127:8a7bee7b8e8b | 498 | while(ack_and_callsign->next_TM != NULL){ |
krishanprajapat | 127:8a7bee7b8e8b | 499 | ack_and_callsign = ack_and_callsign->next_TM; |
krishanprajapat | 127:8a7bee7b8e8b | 500 | } |
krishanprajapat | 127:8a7bee7b8e8b | 501 | get_ack_l234(ack_and_callsign->next_TM); |
krishanprajapat | 127:8a7bee7b8e8b | 502 | snd_tm.head_pointer(ack_head); |
krishanprajapat | 127:8a7bee7b8e8b | 503 | T_frame_in_Ackandcallsign = 2*snd_tm.make_shor_tm(); |
krishanprajapat | 127:8a7bee7b8e8b | 504 | Base_tm *ack_l234 = ack_and_callsign->next_TM; |
krishanprajapat | 127:8a7bee7b8e8b | 505 | uint8_t temp2 = TC_STATE_SUCCESSFULLY_EXECUTED; // see all the possible cases |
krishanprajapat | 127:8a7bee7b8e8b | 506 | PUTexec_status(current_obsrs_tc, temp2); |
krishanprajapat | 127:8a7bee7b8e8b | 507 | if( (GETexec_status(current_obsrs_tc) == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_obsrs_tc) == 1) ){ |
krishanprajapat | 127:8a7bee7b8e8b | 508 | gMASTER_STATE = TCL_STATE_ABORTED; |
krishanprajapat | 127:8a7bee7b8e8b | 509 | } |
krishanprajapat | 127:8a7bee7b8e8b | 510 | else if( GETpacket_seq_count(current_obsrs_tc) == (gTOTAL_VALID_TC-1) ){ |
krishanprajapat | 127:8a7bee7b8e8b | 511 | gMASTER_STATE = TCL_STATE_COMPLETED; |
krishanprajapat | 127:8a7bee7b8e8b | 512 | } |
krishanprajapat | 127:8a7bee7b8e8b | 513 | if( GETshort_or_long_tm(ack_l234) == SHORT_TM_CODE ){ |
krishanprajapat | 127:8a7bee7b8e8b | 514 | for(int i = 0 ; i < TM_SHORT_SIZE ; ++i){ |
krishanprajapat | 127:8a7bee7b8e8b | 515 | gLAST_TM[i] = ack_l234->TM_string[i]; |
krishanprajapat | 127:8a7bee7b8e8b | 516 | gLAST_TM_SHORT_OR_LONG = SHORT_TM_CODE; |
krishanprajapat | 127:8a7bee7b8e8b | 517 | } |
krishanprajapat | 127:8a7bee7b8e8b | 518 | } |
krishanprajapat | 127:8a7bee7b8e8b | 519 | else{ |
krishanprajapat | 127:8a7bee7b8e8b | 520 | for( int i = 0 ; i < TM_LONG_SIZE ; ++i ){ |
krishanprajapat | 127:8a7bee7b8e8b | 521 | gLAST_TM[i] = ack_l234->TM_string[i]; |
krishanprajapat | 127:8a7bee7b8e8b | 522 | gLAST_TM_SHORT_OR_LONG = LONG_TM_CODE; |
krishanprajapat | 127:8a7bee7b8e8b | 523 | } |
krishanprajapat | 127:8a7bee7b8e8b | 524 | } |
ee12b079 | 139:1018e1dc82e9 | 525 | ack_and_callsign = ack_head; |
krishanprajapat | 127:8a7bee7b8e8b | 526 | delete ack_head; |
krishanprajapat | 127:8a7bee7b8e8b | 527 | while(ack_and_callsign != NULL){ |
krishanprajapat | 127:8a7bee7b8e8b | 528 | Base_tm *temp = ack_and_callsign->next_TM; |
krishanprajapat | 127:8a7bee7b8e8b | 529 | delete ack_and_callsign; |
krishanprajapat | 127:8a7bee7b8e8b | 530 | ack_and_callsign = temp; |
krishanprajapat | 127:8a7bee7b8e8b | 531 | } |
ee12b079 | 86:a26f5f22631d | 532 | } |
ee12b079 | 86:a26f5f22631d | 533 | send_Ack_andcallsign; |
ee12b079 | 86:a26f5f22631d | 534 | } |
ee12b079 | 86:a26f5f22631d | 535 | else if(enable_EoS){ |
ee12b079 | 86:a26f5f22631d | 536 | // send_EoS(); |
ee12b079 | 86:a26f5f22631d | 537 | buffer_112[counter_buffer_112] = EoS[counter_EoS++]; |
ee12b079 | 86:a26f5f22631d | 538 | if(counter_EoS == 120){ |
ee12b079 | 86:a26f5f22631d | 539 | // cout<<"segments_sent = "<<segments_sent<<ENDL; |
ee12b079 | 86:a26f5f22631d | 540 | // cout<<"EoS sent"<<ENDL; |
ee12b079 | 86:a26f5f22631d | 541 | counter_EoS = 0; |
ee12b079 | 86:a26f5f22631d | 542 | enable_EoS=false; |
ee12b079 | 86:a26f5f22631d | 543 | enable_new_segment = true; |
ee12b079 | 86:a26f5f22631d | 544 | break; |
ee12b079 | 86:a26f5f22631d | 545 | } |
ee12b079 | 86:a26f5f22631d | 546 | else{ |
ee12b079 | 86:a26f5f22631d | 547 | gPC.printf("Error in enable EoS"); |
ee12b079 | 86:a26f5f22631d | 548 | } |
ee12b079 | 86:a26f5f22631d | 549 | } |
ee12b079 | 86:a26f5f22631d | 550 | else{ |
ee12b079 | 86:a26f5f22631d | 551 | gPC.printf("error in for loop"); |
ee12b079 | 86:a26f5f22631d | 552 | } |
ee12b079 | 86:a26f5f22631d | 553 | if(enable_read_block && (!last_block)){ |
ee12b079 | 86:a26f5f22631d | 554 | if(short_TC){ |
ee12b079 | 86:a26f5f22631d | 555 | /*cout<<"reading"<<int(FSC)<<" "<<int(SID)<<ENDL;*/ |
ee12b079 | 86:a26f5f22631d | 556 | // for(int i=0;i<512;i++){ |
ee12b079 | 86:a26f5f22631d | 557 | // printf("0x%02X,",write_buffer[i]); |
ee12b079 | 86:a26f5f22631d | 558 | // } |
ee12b079 | 98:fd99ddc0e0a1 | 559 | //int write_success = SD_WRITE(write_buffer,FSC + block_counter,SID); |
ee12b079 | 86:a26f5f22631d | 560 | // wait_ms(8); |
ee12b079 | 99:efde3df6cd94 | 561 | read_success = SD_READ(buffer_512, FSC + block_counter,SID); |
ee12b079 | 86:a26f5f22631d | 562 | } |
ee12b079 | 86:a26f5f22631d | 563 | else{ |
ee12b079 | 99:efde3df6cd94 | 564 | read_success = SD_READ(buffer_512, list_of_FSC[block_counter],SID); |
ee12b079 | 86:a26f5f22631d | 565 | } |
ee12b079 | 86:a26f5f22631d | 566 | ack_code = read_success; |
ee12b079 | 86:a26f5f22631d | 567 | block_counter++; |
ee12b079 | 86:a26f5f22631d | 568 | if(block_counter == no_of_frames){ |
ee12b079 | 86:a26f5f22631d | 569 | last_block=true; |
ee12b079 | 86:a26f5f22631d | 570 | } |
ee12b079 | 86:a26f5f22631d | 571 | enable_read_block = false; |
ee12b079 | 86:a26f5f22631d | 572 | if(read_success == 0){ |
ee12b079 | 86:a26f5f22631d | 573 | // cout<<"read one block successfully"<<" "; |
ee12b079 | 86:a26f5f22631d | 574 | enable_T_frame = true; |
ee12b079 | 86:a26f5f22631d | 575 | enable_SCH = true; |
ee12b079 | 86:a26f5f22631d | 576 | } |
ee12b079 | 86:a26f5f22631d | 577 | else if(ack_code == 0x85){ |
ee12b079 | 86:a26f5f22631d | 578 | gPC.printf("Hardware failure"); |
ee12b079 | 86:a26f5f22631d | 579 | enable_T_frame = false; |
ee12b079 | 86:a26f5f22631d | 580 | } |
ee12b079 | 86:a26f5f22631d | 581 | else if(ack_code == 0x86){ |
ee12b079 | 86:a26f5f22631d | 582 | gPC.printf("Invalid FSC"); |
ee12b079 | 86:a26f5f22631d | 583 | enable_T_frame = false; |
ee12b079 | 86:a26f5f22631d | 584 | } |
ee12b079 | 86:a26f5f22631d | 585 | else{ |
ee12b079 | 86:a26f5f22631d | 586 | gPC.printf("error Invalid ack code"); |
ee12b079 | 86:a26f5f22631d | 587 | enable_T_frame = false; |
ee12b079 | 86:a26f5f22631d | 588 | stop = true; |
ee12b079 | 86:a26f5f22631d | 589 | } |
ee12b079 | 86:a26f5f22631d | 590 | } |
krishanprajapat | 127:8a7bee7b8e8b | 591 | if((PA_HOT || (!valid_SID)|| (gFLAGS & COM_SESSION_TIMEOUT_FLAG) ||(read_success != 0))&&(!enable_ackandcallsign)){ |
ee12b079 | 86:a26f5f22631d | 592 | enable_ackandcallsign = true; |
ee12b079 | 86:a26f5f22631d | 593 | create_Ack_andcallsign = true; |
ee12b079 | 86:a26f5f22631d | 594 | enable_T_frame = false; |
ee12b079 | 86:a26f5f22631d | 595 | } |
ee12b079 | 86:a26f5f22631d | 596 | } |
ee12b079 | 86:a26f5f22631d | 597 | // for(int i=0;i<112;i++){ |
ee12b079 | 86:a26f5f22631d | 598 | // printf("0x%02X,",buffer_112[i]); |
ee12b079 | 86:a26f5f22631d | 599 | // } |
ee12b079 | 86:a26f5f22631d | 600 | differential_encode(buffer_112, 112); |
ee12b079 | 86:a26f5f22631d | 601 | if(last_buffer ==true){ |
ee12b079 | 86:a26f5f22631d | 602 | diff_prev=0; |
ee12b079 | 86:a26f5f22631d | 603 | } |
ee12b079 | 86:a26f5f22631d | 604 | } |
ee12b079 | 86:a26f5f22631d | 605 | |
ee12b079 | 86:a26f5f22631d | 606 | void execute_OBSRS_TC(Base_tc *tcp){ |
krishanprajapat | 127:8a7bee7b8e8b | 607 | current_obsrs_tc = tcp; |
krishanprajapat | 127:8a7bee7b8e8b | 608 | flags_init; |
ee12b079 | 95:42d6747900cb | 609 | sent_tmfrom_SDcard = true; |
ee12b079 | 92:bce22b38c440 | 610 | if( GETshort_or_long_tc(tcp) == SHORT_TC_CODE ){ |
ee12b079 | 92:bce22b38c440 | 611 | short_TC = true; |
ee12b079 | 92:bce22b38c440 | 612 | gPC.printf("it is short TC\r\n"); |
ee12b079 | 92:bce22b38c440 | 613 | } |
ee12b079 | 92:bce22b38c440 | 614 | else{ |
ee12b079 | 92:bce22b38c440 | 615 | gPC.printf("it is long TC\r\n"); |
ee12b079 | 92:bce22b38c440 | 616 | short_TC = false; |
ee12b079 | 92:bce22b38c440 | 617 | } |
ee12b079 | 92:bce22b38c440 | 618 | /* reading SID from TC */ |
ee12b079 | 92:bce22b38c440 | 619 | SID = (tcp->TC_string[2]) & 0x0f; |
ee12b079 | 92:bce22b38c440 | 620 | /* reading FSC and no. of frames from TC */ |
ee12b079 | 92:bce22b38c440 | 621 | if(short_TC){ |
ee12b079 | 92:bce22b38c440 | 622 | FSC = tcp->TC_string[3] << 24; |
ee12b079 | 92:bce22b38c440 | 623 | FSC += tcp->TC_string[4] << 16; |
ee12b079 | 92:bce22b38c440 | 624 | FSC += tcp->TC_string[5] << 8; |
ee12b079 | 92:bce22b38c440 | 625 | FSC += tcp->TC_string[6]; |
ee12b079 | 92:bce22b38c440 | 626 | no_of_frames = tcp->TC_string[7] << 8; |
ee12b079 | 92:bce22b38c440 | 627 | no_of_frames += tcp->TC_string[8]; |
ee12b079 | 92:bce22b38c440 | 628 | } |
ee12b079 | 92:bce22b38c440 | 629 | else{ |
ee12b079 | 92:bce22b38c440 | 630 | no_of_frames = tcp->TC_string[3]; |
ee12b079 | 92:bce22b38c440 | 631 | for(int i=0 ;i<no_of_frames ; i++){ |
ee12b079 | 92:bce22b38c440 | 632 | list_of_FSC[i] = tcp->TC_string[4+i]; |
ee12b079 | 92:bce22b38c440 | 633 | } |
ee12b079 | 92:bce22b38c440 | 634 | } |
ee12b079 | 100:484a687431cc | 635 | |
ee12b079 | 99:efde3df6cd94 | 636 | gPC.printf("sid = %u \r\n",SID); |
ee12b079 | 99:efde3df6cd94 | 637 | gPC.printf("FSC = %u\r\n",FSC); |
ee12b079 | 140:be4eea8275c3 | 638 | // gPC.puts("exit_sdcard"); |
krishanprajapat | 121:bd7263168ee4 | 639 | |
krishanprajapat | 121:bd7263168ee4 | 640 | // SID = 0x1; |
ee12b079 | 92:bce22b38c440 | 641 | // FSC = 10; |
ee12b079 | 92:bce22b38c440 | 642 | // no_of_frames = 2; |
ee12b079 | 86:a26f5f22631d | 643 | // cout<<"max_segments = "<<max_segments<<ENDL; |
ee12b079 | 86:a26f5f22631d | 644 | //while(0){ |
ee12b079 | 86:a26f5f22631d | 645 | // while(!stop){ |
ee12b079 | 86:a26f5f22631d | 646 | // // send_call_sign(); |
ee12b079 | 86:a26f5f22631d | 647 | // if(short_TC){ |
ee12b079 | 86:a26f5f22631d | 648 | // send_tm_from_SD_card(); |
ee12b079 | 86:a26f5f22631d | 649 | // } |
ee12b079 | 86:a26f5f22631d | 650 | // else{ |
ee12b079 | 86:a26f5f22631d | 651 | // send_tm_from_SD_card(); |
ee12b079 | 86:a26f5f22631d | 652 | // } |
ee12b079 | 86:a26f5f22631d | 653 | // } |
ee12b079 | 86:a26f5f22631d | 654 | } |