comparison trau-decode/dump-1bit.c @ 27:f508dacf2cf9

trau-decode: new programs dump-1bit and trau-sync8
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 18 Aug 2024 06:26:23 +0000
parents
children
comparison
equal deleted inserted replaced
26:f80e64139670 27:f508dacf2cf9
1 /*
2 * This program reads a 64 kbit/s timeslot recording file, focuses on one
3 * bit out of the eight (a single 8 kbit/s subslot) and prints a dump
4 * that shows just this one bit out of each byte. It is an aid for
5 * development and debugging of frame sync tools for 8 kbit/s submultiplexing.
6 */
7
8 #include <stdio.h>
9 #include <stdlib.h>
10
11 main(argc, argv)
12 char **argv;
13 {
14 FILE *inf;
15 int subslot, right_shift;
16 unsigned file_offset, mod16;
17 int inb;
18
19 if (argc != 3) {
20 fprintf(stderr, "usage: %s binfile subslot\n", argv[0]);
21 exit(1);
22 }
23 inf = fopen(argv[1], "r");
24 if (!inf) {
25 perror(argv[1]);
26 exit(1);
27 }
28 subslot = atoi(argv[2]);
29 if (subslot < 0 || subslot > 7) {
30 fprintf(stderr, "error: invalid subslot argument\n");
31 exit(1);
32 }
33 right_shift = 7 - subslot;
34 for (file_offset = 0; ; file_offset++) {
35 inb = getc(inf);
36 if (inb < 0)
37 break;
38 mod16 = file_offset & 15;
39 if (mod16 == 0)
40 printf("%08X:", file_offset);
41 if (mod16 == 0 || mod16 == 4 || mod16 == 8 || mod16 == 12)
42 putchar(' ');
43 printf(" %u", (inb >> right_shift) & 1);
44 if (mod16 == 15)
45 putchar('\n');
46 }
47 }