comparison libgsmhr1/gen-dhf-pack.c @ 511:a5d61331b675

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