annotate libtest/parse_dlcap.c @ 237:e4a4bf11f37c

doc/PCM8-conversions: document command line utilities
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 08 May 2023 04:29:05 +0000
parents be57e06bed84
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19
7960744ba19c frtest: gsmfr-cvt-dlcap program based on fc-tch2fr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
139
be57e06bed84 factor out common part of gsmfr-cvt-dlcap, in prep for EFR
Mychaela Falconia <falcon@freecalypso.org>
parents: 137
diff changeset
2 * All TCH/F downlink capture files produced by fc-shell tch record
be57e06bed84 factor out common part of gsmfr-cvt-dlcap, in prep for EFR
Mychaela Falconia <falcon@freecalypso.org>
parents: 137
diff changeset
3 * (both FR and EFR, both old and new formats) include the same
be57e06bed84 factor out common part of gsmfr-cvt-dlcap, in prep for EFR
Mychaela Falconia <falcon@freecalypso.org>
parents: 137
diff changeset
4 * 81-character block in each line: 3 DSP status words followed by
be57e06bed84 factor out common part of gsmfr-cvt-dlcap, in prep for EFR
Mychaela Falconia <falcon@freecalypso.org>
parents: 137
diff changeset
5 * 33 bytes of frame data. Here we are factoring out the function
be57e06bed84 factor out common part of gsmfr-cvt-dlcap, in prep for EFR
Mychaela Falconia <falcon@freecalypso.org>
parents: 137
diff changeset
6 * for parsing this common part.
19
7960744ba19c frtest: gsmfr-cvt-dlcap program based on fc-tch2fr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 */
7960744ba19c frtest: gsmfr-cvt-dlcap program based on fc-tch2fr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8
7960744ba19c frtest: gsmfr-cvt-dlcap program based on fc-tch2fr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <ctype.h>
139
be57e06bed84 factor out common part of gsmfr-cvt-dlcap, in prep for EFR
Mychaela Falconia <falcon@freecalypso.org>
parents: 137
diff changeset
10 #include <stdint.h>
19
7960744ba19c frtest: gsmfr-cvt-dlcap program based on fc-tch2fr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
7960744ba19c frtest: gsmfr-cvt-dlcap program based on fc-tch2fr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 static
7960744ba19c frtest: gsmfr-cvt-dlcap program based on fc-tch2fr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 decode_hex_digit(ch)
7960744ba19c frtest: gsmfr-cvt-dlcap program based on fc-tch2fr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 {
7960744ba19c frtest: gsmfr-cvt-dlcap program based on fc-tch2fr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 if (isdigit(ch))
7960744ba19c frtest: gsmfr-cvt-dlcap program based on fc-tch2fr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 return(ch - '0');
7960744ba19c frtest: gsmfr-cvt-dlcap program based on fc-tch2fr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 else if (isupper(ch))
7960744ba19c frtest: gsmfr-cvt-dlcap program based on fc-tch2fr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 return(ch - 'A' + 10);
7960744ba19c frtest: gsmfr-cvt-dlcap program based on fc-tch2fr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 else
7960744ba19c frtest: gsmfr-cvt-dlcap program based on fc-tch2fr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 return(ch - 'a' + 10);
7960744ba19c frtest: gsmfr-cvt-dlcap program based on fc-tch2fr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 }
7960744ba19c frtest: gsmfr-cvt-dlcap program based on fc-tch2fr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22
139
be57e06bed84 factor out common part of gsmfr-cvt-dlcap, in prep for EFR
Mychaela Falconia <falcon@freecalypso.org>
parents: 137
diff changeset
23 parse_dlcap_common(line, status_words, tidsp_bytes)
137
b7ea278390eb gsmfr-cvt-dlcap: support new FC TCH DL recording format
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
24 char *line;
139
be57e06bed84 factor out common part of gsmfr-cvt-dlcap, in prep for EFR
Mychaela Falconia <falcon@freecalypso.org>
parents: 137
diff changeset
25 uint16_t *status_words;
be57e06bed84 factor out common part of gsmfr-cvt-dlcap, in prep for EFR
Mychaela Falconia <falcon@freecalypso.org>
parents: 137
diff changeset
26 uint8_t *tidsp_bytes;
137
b7ea278390eb gsmfr-cvt-dlcap: support new FC TCH DL recording format
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
27 {
b7ea278390eb gsmfr-cvt-dlcap: support new FC TCH DL recording format
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
28 char *cp;
b7ea278390eb gsmfr-cvt-dlcap: support new FC TCH DL recording format
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
29 int i;
b7ea278390eb gsmfr-cvt-dlcap: support new FC TCH DL recording format
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
30
b7ea278390eb gsmfr-cvt-dlcap: support new FC TCH DL recording format
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
31 /* grok DSP status words */
b7ea278390eb gsmfr-cvt-dlcap: support new FC TCH DL recording format
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
32 cp = line;
b7ea278390eb gsmfr-cvt-dlcap: support new FC TCH DL recording format
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
33 for (i = 0; i < 3; i++) {
b7ea278390eb gsmfr-cvt-dlcap: support new FC TCH DL recording format
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
34 if (!isxdigit(cp[0]) || !isxdigit(cp[1]) ||
b7ea278390eb gsmfr-cvt-dlcap: support new FC TCH DL recording format
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
35 !isxdigit(cp[2]) || !isxdigit(cp[3]))
b7ea278390eb gsmfr-cvt-dlcap: support new FC TCH DL recording format
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
36 return -1;
b7ea278390eb gsmfr-cvt-dlcap: support new FC TCH DL recording format
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
37 status_words[i] = (decode_hex_digit(cp[0]) << 12) |
b7ea278390eb gsmfr-cvt-dlcap: support new FC TCH DL recording format
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
38 (decode_hex_digit(cp[1]) << 8) |
b7ea278390eb gsmfr-cvt-dlcap: support new FC TCH DL recording format
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
39 (decode_hex_digit(cp[2]) << 4) |
b7ea278390eb gsmfr-cvt-dlcap: support new FC TCH DL recording format
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
40 decode_hex_digit(cp[3]);
b7ea278390eb gsmfr-cvt-dlcap: support new FC TCH DL recording format
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
41 cp += 4;
b7ea278390eb gsmfr-cvt-dlcap: support new FC TCH DL recording format
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
42 if (*cp++ != ' ')
b7ea278390eb gsmfr-cvt-dlcap: support new FC TCH DL recording format
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
43 return -1;
b7ea278390eb gsmfr-cvt-dlcap: support new FC TCH DL recording format
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
44 }
b7ea278390eb gsmfr-cvt-dlcap: support new FC TCH DL recording format
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
45 /* read the frame bits */
b7ea278390eb gsmfr-cvt-dlcap: support new FC TCH DL recording format
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
46 for (i = 0; i < 33; i++) {
b7ea278390eb gsmfr-cvt-dlcap: support new FC TCH DL recording format
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
47 if (!isxdigit(cp[0]) || !isxdigit(cp[1]))
b7ea278390eb gsmfr-cvt-dlcap: support new FC TCH DL recording format
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
48 return -1;
b7ea278390eb gsmfr-cvt-dlcap: support new FC TCH DL recording format
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
49 tidsp_bytes[i] = (decode_hex_digit(cp[0]) << 4) |
b7ea278390eb gsmfr-cvt-dlcap: support new FC TCH DL recording format
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
50 decode_hex_digit(cp[1]);
b7ea278390eb gsmfr-cvt-dlcap: support new FC TCH DL recording format
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
51 cp += 2;
b7ea278390eb gsmfr-cvt-dlcap: support new FC TCH DL recording format
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
52 }
b7ea278390eb gsmfr-cvt-dlcap: support new FC TCH DL recording format
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
53 return 0;
b7ea278390eb gsmfr-cvt-dlcap: support new FC TCH DL recording format
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
54 }