annotate libgsmhr1/gen-dhf-pack.c @ 540:5595293e4f29

gsmx-to-tw5a utility: use emit_hex_frame() in libtest
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 22 Sep 2024 00:36:35 +0000
parents a5d61331b675
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
511
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This helper program is built and executed during libgsmhr1 compilation
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * process. It converts the spec-fixed decoder homing frame (DHF)
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * from array-of-parameters form into the packed format of TS 101 318.
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 */
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdint.h>
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdlib.h>
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include "tw_gsmhr.h"
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 static void emit_frame_body(const uint8_t *frame)
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 {
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 int i;
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 for (i = 0; i < GSMHR_FRAME_LEN_RPF; i++) {
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 if (i == 0 || i == 7)
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 putchar('\t');
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 else
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 putchar(' ');
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 printf("0x%02X,", frame[i]);
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 if (i == 6 || i == 13)
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 putchar('\n');
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 }
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 }
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 int main(int argc, char **argv)
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 {
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 uint8_t frame[GSMHR_FRAME_LEN_RPF];
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 gsmhr_pack_ts101318(gsmhr_dhf_params, frame);
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 puts("/* This C module is auto-generated - do not edit! */");
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 putchar('\n');
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 puts("#include <stdint.h>");
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 puts("#include \"tw_gsmhr.h\"");
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 putchar('\n');
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 puts("const uint8_t gsmhr_dhf_ts101318[GSMHR_FRAME_LEN_RPF] = {");
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 emit_frame_body(frame);
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 puts("};");
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 exit(0);
a5d61331b675 libgsmhr1: generate packed version of DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 }