comparison ater/out_frame.c @ 22:bacc590ec839

ater: implement EFR CRC inversion option
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 24 Jun 2024 09:28:28 +0000
parents 2ee910aa03c3
children
comparison
equal deleted inserted replaced
21:2ee910aa03c3 22:bacc590ec839
97 i++; 97 i++;
98 j++; 98 j++;
99 } 99 }
100 } 100 }
101 101
102 static void invert_crc3(ubit_t *crc)
103 {
104 crc[0] = !crc[0];
105 crc[1] = !crc[1];
106 crc[2] = !crc[2];
107 }
108
102 static void fill_data_efr(const uint8_t *data, struct osmo_trau_frame *tf) 109 static void fill_data_efr(const uint8_t *data, struct osmo_trau_frame *tf)
103 { 110 {
104 int i, j; 111 int i, j;
105 ubit_t check_bits[26]; 112 ubit_t check_bits[26];
113 uint8_t crc_inv;
106 114
107 /* reassemble d-bits */ 115 /* reassemble d-bits */
108 tf->d_bits[0] = 1; 116 tf->d_bits[0] = 1;
109 for (i = 1, j = 4; i < 39; i++, j++) 117 for (i = 1, j = 4; i < 39; i++, j++)
110 tf->d_bits[i] = (data[j/8] >> (7-(j%8))) & 1; 118 tf->d_bits[i] = (data[j/8] >> (7-(j%8))) & 1;
129 for (i = 207, j = 198; i < 257; i++, j++) 137 for (i = 207, j = 198; i < 257; i++, j++)
130 tf->d_bits[i] = (data[j/8] >> (7-(j%8))) & 1; 138 tf->d_bits[i] = (data[j/8] >> (7-(j%8))) & 1;
131 efr_parity_bits_5(check_bits, tf->d_bits); 139 efr_parity_bits_5(check_bits, tf->d_bits);
132 osmo_crc8gen_set_bits(&gsm0860_efr_crc3, check_bits, 8, 140 osmo_crc8gen_set_bits(&gsm0860_efr_crc3, check_bits, 8,
133 tf->d_bits + 257); 141 tf->d_bits + 257);
142
143 /* inverted CRC option */
144 crc_inv = data[31];
145 if (crc_inv & 0x80)
146 invert_crc3(tf->d_bits + 39);
147 if (crc_inv & 0x40)
148 invert_crc3(tf->d_bits + 95);
149 if (crc_inv & 0x20)
150 invert_crc3(tf->d_bits + 148);
151 if (crc_inv & 0x10)
152 invert_crc3(tf->d_bits + 204);
153 if (crc_inv & 0x08)
154 invert_crc3(tf->d_bits + 257);
134 } 155 }
135 156
136 void trau_frame_from_record(const uint8_t *rec, bool is_efr, 157 void trau_frame_from_record(const uint8_t *rec, bool is_efr,
137 struct osmo_trau_frame *tf) 158 struct osmo_trau_frame *tf)
138 { 159 {