annotate loadtools/tpinterfb.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 8d7dcfd9df53
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
649
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module contains functions for binary (as opposed to our usual ASCII)
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * interfacing to loadagent.
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/types.h>
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <sys/time.h>
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <sys/errno.h>
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdio.h>
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <string.h>
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <strings.h>
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <stdlib.h>
695
8d7dcfd9df53 loadtools: missing #include <unistd.h> in tpinterf modules
Mychaela Falconia <falcon@freecalypso.org>
parents: 649
diff changeset
13 #include <unistd.h>
649
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 extern int errno;
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 extern int target_fd;
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 collect_binblock_from_target(buf, expect_len, timeout)
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 u_char *buf;
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 unsigned expect_len;
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 {
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 fd_set fds;
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 struct timeval tv;
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 unsigned rcvd;
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 int cc;
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 for (rcvd = 0; rcvd < expect_len; ) {
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 FD_ZERO(&fds);
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 FD_SET(target_fd, &fds);
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 tv.tv_sec = timeout;
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 tv.tv_usec = 0;
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 cc = select(target_fd+1, &fds, NULL, NULL, &tv);
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 if (cc < 0) {
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 if (errno == EINTR)
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 continue;
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 perror("select");
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 return(-1);
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 }
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 if (cc < 1) {
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 fprintf(stderr,
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 "error: timeout waiting for binary block\n");
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 return(-1);
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 }
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 cc = read(target_fd, buf + rcvd, expect_len - rcvd);
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 if (cc <= 0) {
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 perror("read after successful select");
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 return(-1);
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 }
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 rcvd += cc;
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 }
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 return(0);
141372e0d28f fc-loadtool module refactoring: tpinterfb.c split out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 }