FreeCalypso > hg > freecalypso-tools
annotate miscutil/ti2arfcn.c @ 924:d452188587b4
rvinterf: begin change to backslash escape output format
Right now throughout the rvinterf suite, any time we emit output that
is expected to be ASCII, but may contain non-printable garbage, we use
'cat -v' form of garbage character representation. Unfortunately, this
transformation is lossy (can't be reversed 100% reliably in the user's
wetware), hence we would like to migrate to C-style backslash escapes,
including doubling of any already-present backslashes - this escape
mechanism is lossless. Begin this change by converting the output
of RV and L1 traces in rvinterf and rvtdump.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 23 May 2023 03:10:50 +0000 |
parents | d2fccd82a83e |
children |
rev | line source |
---|---|
759
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * TI's TCS211 L1 does not use standard ARFCNs internally, instead it uses |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * its own non-standard radio_freq numbers in their place. Other firmware |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * components and all external interfaces do use standard ARFCNs, thus |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * conversion functions are invoked at appropriate points in the firmware. |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * However, L1-internal radio_freq numbers are emitted in L1 debug traces, |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 * thus anyone looking at these traces needs to be able to convert between |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 * standard ARFCNs and L1-internal radio_freq. |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 * |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 * The present utility converts TI's radio_freq numbers as seen in L1 traces |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 * into standard ARFCNs. |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 */ |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include <stdio.h> |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #include <stdlib.h> |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #include <string.h> |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 #include <strings.h> |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 main(argc, argv) |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 char **argv; |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 { |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 int ti_num; |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 if (argc != 3) { |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 usage: fprintf(stderr, "usage: %s {eu|us} L1_radio_freq\n", argv[0]); |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 exit(1); |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 } |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 ti_num = atoi(argv[2]); |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 if (!strcmp(argv[1], "eu")) |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 ti2arfcn_eu(ti_num); |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 else if (!strcmp(argv[1], "us")) |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 ti2arfcn_us(ti_num); |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 else |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 goto usage; |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 exit(0); |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 } |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 ti2arfcn_eu(radio_freq) |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 { |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 int arfcn; |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 if (radio_freq < 1 || radio_freq > 548) { |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 fprintf(stderr, |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 "error: specified radio_freq is out of range for dual-EU\n"); |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 exit(1); |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 } |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 if (radio_freq < 175) { |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 if (radio_freq <= 124) |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 arfcn = radio_freq; |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 else if (radio_freq < 174) |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 arfcn = radio_freq - 125 + 975; |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 else |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 arfcn = 0; |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 } else |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 arfcn = radio_freq - 175 + 512; |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 printf("%d\n", arfcn); |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 } |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 ti2arfcn_us(radio_freq) |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 { |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 int arfcn; |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 if (radio_freq < 1 || radio_freq > 423) { |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 fprintf(stderr, |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 "error: specified radio_freq is out of range for dual-US\n"); |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 exit(1); |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 } |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 if (radio_freq < 125) |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 arfcn = radio_freq - 1 + 128; |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 else |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 arfcn = radio_freq - 125 + 512; |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 printf("%d\n", arfcn); |
d2fccd82a83e
ti2arfcn utility added to miscutil
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 } |