40
40
*--------------------------------------------------------------*/
41
41
42
42
43
+ static int il2p_check_crc (unsigned char * payload , int payload_length , unsigned char * coded_crc );
44
+ static int il2p_generate_crc (unsigned char * coded_crc , unsigned char * payload , int payload_length );
45
+
46
+ #define IL2P_NIBLE_MASK 0x0f
47
+ #define IL2P_DECODE_MASK 0x7f
48
+
49
+ // local variables
50
+
51
+ static uint8_t encode_table [16 ] = { 0x0 , 0x71 , 0x62 , 0x13 , 0x54 , 0x25 , 0x36 , 0x47 , 0x38 , 0x49 , 0x5a , 0x2b , 0x6c , 0x1d , 0x0e , 0x7f };
52
+
53
+ static uint8_t decode_table [128 ] = { 0x0 , 0x0 , 0x0 , 0x3 , 0x0 , 0x5 , 0xe , 0x7 ,
54
+ 0x0 , 0x9 , 0xe , 0xb , 0xe , 0xd , 0xe , 0xe ,
55
+ 0x0 , 0x3 , 0x3 , 0x3 , 0x4 , 0xd , 0x6 , 0x3 ,
56
+ 0x8 , 0xd , 0xa , 0x3 , 0xd , 0xd , 0xe , 0xd ,
57
+ 0x0 , 0x5 , 0x2 , 0xb , 0x5 , 0x5 , 0x6 , 0x5 ,
58
+ 0x8 , 0xb , 0xb , 0xb , 0xc , 0x5 , 0xe , 0xb ,
59
+ 0x8 , 0x1 , 0x6 , 0x3 , 0x6 , 0x5 , 0x6 , 0x6 ,
60
+ 0x8 , 0x8 , 0x8 , 0xb , 0x8 , 0xd , 0x6 , 0xf ,
61
+ 0x0 , 0x9 , 0x2 , 0x7 , 0x4 , 0x7 , 0x7 , 0x7 ,
62
+ 0x9 , 0x9 , 0xa , 0x9 , 0xc , 0x9 , 0xe , 0x7 ,
63
+ 0x4 , 0x1 , 0xa , 0x3 , 0x4 , 0x4 , 0x4 , 0x7 ,
64
+ 0xa , 0x9 , 0xa , 0xa , 0x4 , 0xd , 0xa , 0xf ,
65
+ 0x2 , 0x1 , 0x2 , 0x2 , 0xc , 0x5 , 0x2 , 0x7 ,
66
+ 0xc , 0x9 , 0x2 , 0xb , 0xc , 0xc , 0xc , 0xf ,
67
+ 0x1 , 0x1 , 0x2 , 0x1 , 0x4 , 0x1 , 0x6 , 0xf ,
68
+ 0x8 , 0x1 , 0xa , 0xf , 0xc , 0xf , 0xf , 0xf };
69
+
70
+
43
71
/*-------------------------------------------------------------
44
72
*
45
73
* Name: il2p_encode_frame
52
80
*
53
81
* max_fec - 1 to send maximum FEC size rather than automatic.
54
82
*
83
+ * use_crc - 1 to use CRC for the payload.
84
+ *
55
85
* Outputs: iout - Encoded result, excluding the 3 byte sync word.
56
86
* Caller should provide IL2P_MAX_PACKET_SIZE bytes.
57
87
*
69
99
*
70
100
*--------------------------------------------------------------*/
71
101
72
- static int il2p_check_crc (unsigned char * payload , int payload_length , unsigned char * coded_crc );
73
- static int il2p_generate_crc (unsigned char * coded_crc , unsigned char * payload , int payload_length );
74
-
75
- #define IL2P_NIBLE_MASK 0x0f
76
- #define IL2P_DECODE_MASK 0x7f
77
-
78
- // local variables
79
-
80
- static uint8_t encode_table [16 ] = { 0x0 , 0x71 , 0x62 , 0x13 , 0x54 , 0x25 , 0x36 , 0x47 , 0x38 , 0x49 , 0x5a , 0x2b , 0x6c , 0x1d , 0x0e , 0x7f };
81
-
82
- static uint8_t decode_table [128 ] = { 0x0 , 0x0 , 0x0 , 0x3 , 0x0 , 0x5 , 0xe , 0x7 ,
83
- 0x0 , 0x9 , 0xe , 0xb , 0xe , 0xd , 0xe , 0xe ,
84
- 0x0 , 0x3 , 0x3 , 0x3 , 0x4 , 0xd , 0x6 , 0x3 ,
85
- 0x8 , 0xd , 0xa , 0x3 , 0xd , 0xd , 0xe , 0xd ,
86
- 0x0 , 0x5 , 0x2 , 0xb , 0x5 , 0x5 , 0x6 , 0x5 ,
87
- 0x8 , 0xb , 0xb , 0xb , 0xc , 0x5 , 0xe , 0xb ,
88
- 0x8 , 0x1 , 0x6 , 0x3 , 0x6 , 0x5 , 0x6 , 0x6 ,
89
- 0x8 , 0x8 , 0x8 , 0xb , 0x8 , 0xd , 0x6 , 0xf ,
90
- 0x0 , 0x9 , 0x2 , 0x7 , 0x4 , 0x7 , 0x7 , 0x7 ,
91
- 0x9 , 0x9 , 0xa , 0x9 , 0xc , 0x9 , 0xe , 0x7 ,
92
- 0x4 , 0x1 , 0xa , 0x3 , 0x4 , 0x4 , 0x4 , 0x7 ,
93
- 0xa , 0x9 , 0xa , 0xa , 0x4 , 0xd , 0xa , 0xf ,
94
- 0x2 , 0x1 , 0x2 , 0x2 , 0xc , 0x5 , 0x2 , 0x7 ,
95
- 0xc , 0x9 , 0x2 , 0xb , 0xc , 0xc , 0xc , 0xf ,
96
- 0x1 , 0x1 , 0x2 , 0x1 , 0x4 , 0x1 , 0x6 , 0xf ,
97
- 0x8 , 0x1 , 0xa , 0xf , 0xc , 0xf , 0xf , 0xf };
98
-
99
-
100
102
int il2p_encode_frame (packet_t pp , int max_fec , unsigned char * iout , int use_crc )
101
103
{
102
104
@@ -200,6 +202,7 @@ int il2p_encode_frame (packet_t pp, int max_fec, unsigned char *iout, int use_cr
200
202
* applied first so we would know how much to collect for the payload.
201
203
*
202
204
* Inputs: irec - Received IL2P frame excluding the 3 byte sync word.
205
+ * use_crc - 1 to chec CRC for the payload.
203
206
*
204
207
* Future Out: Number of symbols corrected.
205
208
*
@@ -226,6 +229,7 @@ packet_t il2p_decode_frame (unsigned char *irec, int use_crc)
226
229
*
227
230
* Inputs: uhdr - Received header after FEC and descrambling.
228
231
* epayload - Encoded payload.
232
+ * use_crc - 1 to check CRC for the payload.
229
233
*
230
234
* In/Out: symbols_corrected - Symbols (bytes) corrected in the header.
231
235
* Should be 0 or 1 because it has 2 parity symbols.
0 commit comments