FreeCalypso > hg > freecalypso-tools
view loadtools/initscript.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 | e7502631a0f9 |
children |
line wrap: on
line source
/* * This module has been copied from ltscript.c, ltdispatch.c and ltpassthru.c: * here we implement the init-script functionality for fc-xram. */ #include <sys/param.h> #include <stdio.h> #include <string.h> #include <strings.h> #include <stdlib.h> extern char default_helpers_dir[]; extern int cmd_baud(); static loadagent_cmd(argc, argv) char **argv; { if (tpinterf_make_cmd(argv) < 0) { fprintf(stderr, "error: unable to form target command\n"); return(-1); } if (tpinterf_send_cmd() < 0) return(-1); return tpinterf_pass_output(1); } static struct cmdtab { char *cmd; int minargs; int maxargs; int (*func)(); } cmdtab[] = { {"baud", 1, 1, cmd_baud}, {"w8", 2, 2, loadagent_cmd}, {"w16", 2, 2, loadagent_cmd}, {"w32", 2, 2, loadagent_cmd}, {0, 0, 0, 0} }; static dispatch_cmd(cmd) char *cmd; { char *argv[10]; char *cp, **ap; struct cmdtab *tp; for (cp = cmd; isspace(*cp); cp++) ; if (!*cp || *cp == '#') return(0); printf("init-script command: %s\n", cp); argv[0] = cp; while (*cp && !isspace(*cp)) cp++; if (*cp) *cp++ = '\0'; for (tp = cmdtab; tp->cmd; tp++) if (!strcmp(tp->cmd, argv[0])) break; if (!tp->func) { fprintf(stderr, "error: no such command\n"); return(-1); } for (ap = argv + 1; ; ) { while (isspace(*cp)) cp++; if (!*cp || *cp == '#') break; if (ap - argv - 1 >= tp->maxargs) { fprintf(stderr, "error: too many arguments\n"); return(-1); } *ap++ = cp; while (*cp && !isspace(*cp)) cp++; if (*cp) *cp++ = '\0'; } if (ap - argv - 1 < tp->minargs) { fprintf(stderr, "error: too few arguments\n"); return(-1); } *ap = 0; return tp->func(ap - argv, argv); } exec_init_script(script_name) char *script_name; { char pathbuf[MAXPATHLEN], *openfname; FILE *f; char linebuf[512], *cp; int lineno, retval = 0; if (index(script_name, '/')) openfname = script_name; else { sprintf(pathbuf, "%s/%s", default_helpers_dir, script_name); openfname = pathbuf; } f = fopen(openfname, "r"); if (!f) { perror(openfname); return(-1); } for (lineno = 1; fgets(linebuf, sizeof linebuf, f); lineno++) { cp = index(linebuf, '\n'); if (!cp) { fprintf(stderr, "%s line %d: missing newline\n", openfname, lineno); fclose(f); return(-1); } *cp = '\0'; retval = dispatch_cmd(linebuf); if (retval) break; } fclose(f); return(retval); }