FreeCalypso > hg > gsm-net-reveng
changeset 46:f977027774cb
trau-parse: add support for D144 decoding
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 24 Sep 2024 17:02:59 +0000 |
parents | 59d1d15b6f7e |
children | 7119884f6afe |
files | trau-decode/parse-main.c |
diffstat | 1 files changed, 54 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/trau-decode/parse-main.c Fri Sep 13 17:37:21 2024 +0000 +++ b/trau-decode/parse-main.c Tue Sep 24 17:02:59 2024 +0000 @@ -19,6 +19,11 @@ GOT_8_ZEROS, SYNCED } state; +static enum { + NOT_D144, + D144_SYNC, + D144_EDATA, +} d144_state; static unsigned hunt_for_0_count, frame_pos_count; static uint8_t in_frame_2bit[160], frame_bits[320], d_bits[260]; @@ -165,30 +170,61 @@ case 0x14: fputs(" (D144 sync)", stdout); break; + case 0x1F: + fputs(" (E-TRAU)", stdout); + break; } putchar('\n'); - c6_11 = bits_to_num(frame_bits + 22, 6); - printf(" C6-C11: %u\n", c6_11); - printf(" C12=%u C13=%u C14=%u C15=%u\n", frame_bits[28], - frame_bits[29], frame_bits[30], frame_bits[31]); + if (c1_5 == 0x14) + d144_state = D144_SYNC; + else if (c1_5 == 0x1F && + (d144_state == D144_SYNC || d144_state == D144_EDATA)) + d144_state = D144_EDATA; + else + d144_state = NOT_D144; switch (c1_5) { case 0x02: case 0x1C: + case 0x1A: + c6_11 = bits_to_num(frame_bits + 22, 6); + printf(" C6-C11: %u\n", c6_11); + printf(" C12=%u C13=%u C14=%u C15=%u\n", frame_bits[28], + frame_bits[29], frame_bits[30], frame_bits[31]); collect_d_bits(); - print_fr_frame(d_bits); - break; - case 0x1A: - collect_d_bits(); - check_efr_crc(d_bits); - print_efr_frame(d_bits); break; case 0x08: case 0x09: case 0x16: case 0x17: case 0x14: + printf(" C6-C15: %u%u%u%u%u%u%u%u%u%u\n", frame_bits[22], + frame_bits[23], frame_bits[24], frame_bits[25], + frame_bits[26], frame_bits[27], frame_bits[28], + frame_bits[29], frame_bits[30], frame_bits[31]); print_data_frame(); return; + case 0x1F: + printf(" C6-C13: %u%u%u%u%u%u%u%u\n", frame_bits[22], + frame_bits[23], frame_bits[24], frame_bits[25], + frame_bits[26], frame_bits[27], frame_bits[28], + frame_bits[29]); + printf(" M1=%u M2=%u\n", frame_bits[30], frame_bits[31]); + return; + default: + printf(" C6-C15: %u%u%u%u%u%u%u%u%u%u\n", frame_bits[22], + frame_bits[23], frame_bits[24], frame_bits[25], + frame_bits[26], frame_bits[27], frame_bits[28], + frame_bits[29], frame_bits[30], frame_bits[31]); + } + switch (c1_5) { + case 0x02: + case 0x1C: + print_fr_frame(d_bits); + break; + case 0x1A: + check_efr_crc(d_bits); + print_efr_frame(d_bits); + break; } printf(" C16=%u C17=%u C18=%u C19=%u C20=%u C21=%u\n", frame_bits[310], frame_bits[311], frame_bits[312], @@ -224,7 +260,13 @@ static void check_sync() { - if (check_sync_zeros() && check_sync_ones()) + int sync_res; + + if (d144_state == D144_EDATA) + sync_res = check_sync_zeros() && frame_bits[16]; + else + sync_res = check_sync_zeros() && check_sync_ones(); + if (sync_res) return; printf("Bad frame sync, returning to hunt state\n"); state = HUNT_FOR_0; @@ -315,6 +357,7 @@ } right_shift = (3 - subslot) * 2; state = HUNT_FOR_0; + d144_state = NOT_D144; for (file_offset = 0; ; file_offset++) { inb = getc(inf); if (inb < 0)