FreeCalypso > hg > gsm-net-reveng
diff trau-decode/hr-guts.c @ 110:597640501626
trau-decode HR guts: prepare for integration with AMR8
A new investigation program is being developed that needs to decode
both classic HR and AMR8 frame types on 8 kbit/s channels. Each
side needs to be prepared for coexistence.
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Mon, 22 Dec 2025 06:30:43 +0000 |
| parents | e78c6b1ecb91 |
| children |
line wrap: on
line diff
--- a/trau-decode/hr-guts.c Mon Dec 22 05:25:15 2025 +0000 +++ b/trau-decode/hr-guts.c Mon Dec 22 06:30:43 2025 +0000 @@ -24,6 +24,24 @@ .remainder = 0x7, }; +static unsigned +bits_to_num(bits, nbits) + ubit_t *bits; + unsigned nbits; +{ + unsigned accum; + unsigned n; + + accum = 0; + for (n = 0; n < nbits; n++) { + accum <<= 1; + if (*bits) + accum |= 1; + bits++; + } + return accum; +} + static int bit_parity(bits, nbits) ubit_t *bits; @@ -55,8 +73,8 @@ } } -void -print_gsmhr_frame(frame) +static void +print_hr1_speech(frame) ubit_t *frame; { ubit_t xc_bits[6], dbits[112]; @@ -64,12 +82,10 @@ int16_t params[18]; int crc_stat; - printf(" C1-C4: %u%u%u%u OP %s\n", frame[9], frame[10], frame[11], - frame[12], bit_parity(frame + 9, 5) ? "good" : "bad"); bcopy(frame + 14, xc_bits, 2); bcopy(frame + 18, xc_bits + 2, 4); - printf(" XC1-XC5: %u%u%u%u%u OP %s\n", xc_bits[0], xc_bits[1], - xc_bits[2], xc_bits[3], xc_bits[4], + printf(" XC1-XC6: %u%u%u%u%u%u OP %s\n", xc_bits[0], xc_bits[1], + xc_bits[2], xc_bits[3], xc_bits[4], xc_bits[5], bit_parity(xc_bits, 6) ? "good" : "bad"); bcopy(frame + 22, dbits, 2); bcopy(frame + 25, dbits + 2, 7); @@ -108,3 +124,47 @@ frame[157]); printf(" T1=%u T2=%u\n", frame[158], frame[159]); } + +print_gsmhr_frame(frame) + ubit_t *frame; +{ + unsigned c1_3 = bits_to_num(frame + 9, 3); + char *desc; + + switch (c1_3) { + case 0: + desc = "speech"; + break; + case 1: + desc = "data"; + break; + case 2: + desc = "O&M"; + break; + case 7: + desc = "GCF"; + break; + default: + desc = "unknown"; + } + printf(" HR C1-C5: %u%u%u%u%u (%s) OP %s\n", frame[9], frame[10], + frame[11], frame[12], frame[13], desc, + bit_parity(frame + 9, 5) ? "good" : "bad"); + /* return number of T bits */ + switch (c1_3) { + case 0: + print_hr1_speech(frame); + return 2; + case 1: + /* TODO: print data frame */ + return 0; + case 2: + /* TODO: print O&M frame */ + return 0; + case 7: + /* TODO: print GCF */ + return 2; + default: + return 0; + } +}
