annotate uptools/libcoding/hexdecode.c @ 1014:961efadd530a default tip

fc-shell TCH DL handler: add support for CSD modes TCH DL capture mechanism in FC Tourmaline firmware has been extended to support CSD modes in addition to speech - add the necessary support on the host tools side. It needs to be noted that this mechanism in its present state does NOT provide the debug utility value that was sought: as we learned only after the code was implemented, TI's DSP has a misfeature in that the buffer we are reading (a_dd_0[]) is zeroed out when the IDS block is enabled, i.e., we are reading all zeros and not the real DL bits we were after. But since the code has already been written, we are keeping it - perhaps we can do some tests with IDS disabled.
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 26 Nov 2024 06:27:43 +0000
parents 18c692984549
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
329
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This library module implements decoding of long hex strings,
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * such as SMS PDUs.
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/types.h>
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <ctype.h>
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 decode_hex_line(inbuf, outbuf, outmax)
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 char *inbuf;
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 u_char *outbuf;
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 unsigned outmax;
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 {
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 char *inp = inbuf;
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 u_char *outp = outbuf;
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 unsigned outcnt = 0;
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 int c, d[2], i;
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 while (*inp) {
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 if (!isxdigit(inp[0]) || !isxdigit(inp[1]))
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 return(-1);
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 if (outcnt >= outmax)
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 break;
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 for (i = 0; i < 2; i++) {
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 c = *inp++;
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 if (isdigit(c))
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 d[i] = c - '0';
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 else if (isupper(c))
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 d[i] = c - 'A' + 10;
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 else
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 d[i] = c - 'a' + 10;
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 }
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 *outp++ = (d[0] << 4) | d[1];
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 outcnt++;
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 }
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 return outcnt;
18c692984549 uptools/libcoding: hex line decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 }