annotate hrutil/dec-parse.c @ 547:f9535c1fbf70

efrtest: new program gsmefr-decode-tw5
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 04 Oct 2024 20:17:36 +0000
parents 2d703e1e9107
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
115
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
517
2d703e1e9107 hrutil: implement gsmhr-dec-parse
Mychaela Falconia <falcon@freecalypso.org>
parents: 515
diff changeset
2 * This program reads an HRv1 *.dec file in ETSI test sequence format
2d703e1e9107 hrutil: implement gsmhr-dec-parse
Mychaela Falconia <falcon@freecalypso.org>
parents: 515
diff changeset
3 * (decoder input format) and displays its content in human-readable form.
115
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdio.h>
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdint.h>
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdlib.h>
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <string.h>
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <strings.h>
515
bb36ef735f25 hrutil: starting with gsmhr-cod-parse
Mychaela Falconia <falcon@freecalypso.org>
parents: 213
diff changeset
11 #include "../libgsmhr1/tw_gsmhr.h"
115
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 main(argc, argv)
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 char **argv;
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 {
148
bbe5669f0f29 gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 147
diff changeset
16 char *infname;
115
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 FILE *inf;
148
bbe5669f0f29 gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 147
diff changeset
18 int big_endian;
115
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 unsigned frame_no;
517
2d703e1e9107 hrutil: implement gsmhr-dec-parse
Mychaela Falconia <falcon@freecalypso.org>
parents: 515
diff changeset
20 int16_t params[GSMHR_NUM_PARAMS_DEC];
515
bb36ef735f25 hrutil: starting with gsmhr-cod-parse
Mychaela Falconia <falcon@freecalypso.org>
parents: 213
diff changeset
21 int rc;
115
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22
148
bbe5669f0f29 gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 147
diff changeset
23 if (argc == 2 && argv[1][0] != '-') {
bbe5669f0f29 gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 147
diff changeset
24 big_endian = 0;
bbe5669f0f29 gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 147
diff changeset
25 infname = argv[1];
bbe5669f0f29 gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 147
diff changeset
26 } else if (argc == 3 && !strcmp(argv[1], "-b")) {
bbe5669f0f29 gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 147
diff changeset
27 big_endian = 1;
bbe5669f0f29 gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 147
diff changeset
28 infname = argv[2];
bbe5669f0f29 gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 147
diff changeset
29 } else {
517
2d703e1e9107 hrutil: implement gsmhr-dec-parse
Mychaela Falconia <falcon@freecalypso.org>
parents: 515
diff changeset
30 fprintf(stderr, "usage: %s [-b] file.dec\n", argv[0]);
115
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 exit(1);
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 }
148
bbe5669f0f29 gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 147
diff changeset
33 inf = fopen(infname, "r");
115
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 if (!inf) {
148
bbe5669f0f29 gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 147
diff changeset
35 perror(infname);
115
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 exit(1);
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 }
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 for (frame_no = 0; ; frame_no++) {
517
2d703e1e9107 hrutil: implement gsmhr-dec-parse
Mychaela Falconia <falcon@freecalypso.org>
parents: 515
diff changeset
39 rc = read_dec_frame(inf, big_endian, params, infname, frame_no);
115
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 if (!rc)
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 break;
517
2d703e1e9107 hrutil: implement gsmhr-dec-parse
Mychaela Falconia <falcon@freecalypso.org>
parents: 515
diff changeset
42 printf("#%u: BFI=%d UFI=%d SID=%d TAF=%d\n", frame_no,
2d703e1e9107 hrutil: implement gsmhr-dec-parse
Mychaela Falconia <falcon@freecalypso.org>
parents: 515
diff changeset
43 params[18], params[19], params[20], params[21]);
515
bb36ef735f25 hrutil: starting with gsmhr-cod-parse
Mychaela Falconia <falcon@freecalypso.org>
parents: 213
diff changeset
44 print_frame_params(params);
115
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 }
213
46a6e6b6841a gsmefr-{cod,dec}-parse: missed exit(0) at the end
Mychaela Falconia <falcon@freecalypso.org>
parents: 148
diff changeset
46 exit(0);
115
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 }