annotate rvinterf/libprint/hexdump.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 65953c172f24
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
928
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * The function contained in this module implements hex dump functionality:
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * an arbitrary binary packet is dumped in hex, line by line, calling an output
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * function for each line.
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 */
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <sys/types.h>
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdio.h>
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <string.h>
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <strings.h>
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 void
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 packet_hex_dump(src, srclen, outfunc)
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 u_char *src;
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 unsigned srclen;
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 void (*outfunc)();
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 {
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 u_char *sp = src;
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 unsigned remain = srclen;
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 unsigned offset = 0;
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 unsigned chunk;
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 char line[80], *dp;
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 int i, c;
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 while (remain) {
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 sprintf(line, "%04X: ", offset);
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 dp = line + 7;
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 chunk = remain;
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 if (chunk > 16)
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 chunk = 16;
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 for (i = 0; i < 16; i++) {
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 if (i < chunk)
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 sprintf(dp, "%02X ", sp[i]);
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 else
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 strcpy(dp, " ");
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 dp += 3;
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 if (i == 7 || i == 15)
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 *dp++ = ' ';
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 }
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 for (i = 0; i < chunk; i++) {
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 c = sp[i];
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 if (c < ' ' || c > '~')
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 c = '.';
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 *dp++ = c;
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 }
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 *dp = '\0';
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 outfunc(line);
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 sp += chunk;
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 remain -= chunk;
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 offset += chunk;
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 }
65953c172f24 rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 }