comparison trau-decode/trau-hr-dump.c @ 73:06f241846c67

trau-hr-dump: add -r option for raw frame output
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 08 Feb 2025 01:13:54 +0000
parents 61181373875d
children e78c6b1ecb91
comparison
equal deleted inserted replaced
72:afebef67e8d4 73:06f241846c67
29 .remainder = 0x7, 29 .remainder = 0x7,
30 }; 30 };
31 31
32 static uint8_t *filebuf; 32 static uint8_t *filebuf;
33 static unsigned total_size; 33 static unsigned total_size;
34 static int include_raw;
34 35
35 static void 36 static void
36 read_ts_file(filename, subslot_arg) 37 read_ts_file(filename, subslot_arg)
37 char *filename, *subslot_arg; 38 char *filename, *subslot_arg;
38 { 39 {
136 *bytes++ = acc; 137 *bytes++ = acc;
137 } 138 }
138 } 139 }
139 140
140 static void 141 static void
142 dump_raw_frame(frame_bits)
143 ubit_t *frame_bits;
144 {
145 uint8_t *sp = frame_bits;
146 unsigned n, m, d;
147
148 for (n = 0; n < 40; n++) {
149 d = 0;
150 for (m = 0; m < 4; m++) {
151 d <<= 1;
152 d |= *sp++;
153 }
154 printf("%x", d);
155 }
156 putchar('\n');
157 }
158
159 static void
141 process_frame(pos) 160 process_frame(pos)
142 unsigned pos; 161 unsigned pos;
143 { 162 {
144 ubit_t *frame = filebuf + pos; 163 ubit_t *frame = filebuf + pos;
145 ubit_t xc_bits[6], dbits[112]; 164 ubit_t xc_bits[6], dbits[112];
146 uint8_t hr_bytes[14]; 165 uint8_t hr_bytes[14];
147 int16_t params[18]; 166 int16_t params[18];
148 int crc_stat; 167 int crc_stat;
149 168
150 printf("Frame at 0x%x:\n", pos); 169 printf("Frame at 0x%x:\n", pos);
170 if (include_raw)
171 dump_raw_frame(frame);
151 printf(" C1-C4: %u%u%u%u OP %s\n", frame[9], frame[10], frame[11], 172 printf(" C1-C4: %u%u%u%u OP %s\n", frame[9], frame[10], frame[11],
152 frame[12], bit_parity(frame + 9, 5) ? "good" : "bad"); 173 frame[12], bit_parity(frame + 9, 5) ? "good" : "bad");
153 bcopy(frame + 14, xc_bits, 2); 174 bcopy(frame + 14, xc_bits, 2);
154 bcopy(frame + 18, xc_bits + 2, 4); 175 bcopy(frame + 18, xc_bits + 2, 4);
155 printf(" XC1-XC5: %u%u%u%u%u OP %s\n", xc_bits[0], xc_bits[1], 176 printf(" XC1-XC5: %u%u%u%u%u OP %s\n", xc_bits[0], xc_bits[1],
221 } 242 }
222 243
223 main(argc, argv) 244 main(argc, argv)
224 char **argv; 245 char **argv;
225 { 246 {
226 if (argc != 3) { 247 char *filename, *subslot_arg;
227 fprintf(stderr, "usage: %s binfile subslot\n", argv[0]); 248
228 exit(1); 249 switch (argc) {
229 } 250 case 3:
230 read_ts_file(argv[1], argv[2]); 251 if (argv[1][0] == '-')
252 goto usage;
253 filename = argv[1];
254 subslot_arg = argv[2];
255 include_raw = 0;
256 break;
257 case 4:
258 if (strcmp(argv[1], "-r"))
259 goto usage;
260 if (argv[2][0] == '-')
261 goto usage;
262 filename = argv[2];
263 subslot_arg = argv[3];
264 include_raw = 1;
265 break;
266 default:
267 usage:
268 fprintf(stderr, "usage: %s [-r] binfile subslot\n", argv[0]);
269 exit(1);
270 }
271 read_ts_file(filename, subslot_arg);
231 process_filebuf(); 272 process_filebuf();
232 exit(0); 273 exit(0);
233 } 274 }