annotate rvinterf/tmsh/audiocmd.c @ 153:9925fba699be

fc-olddump replaced with fc-memdump
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 06 Mar 2017 01:19:51 +0000
parents 2159f260ed13
children 86e4d8aea021
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
32
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * ETM audio commands
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdio.h>
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <string.h>
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <strings.h>
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdlib.h>
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include "limits.h"
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include "localtypes.h"
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include "etm.h"
69
2159f260ed13 fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
13 #include "exitcodes.h"
32
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 cmd_audio_load(argc, argv)
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 char **argv;
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 {
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 u_char cmdpkt[MAX_PKT_TO_TARGET], *dp;
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 int slen;
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 slen = strlen(argv[1]);
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 if (slen > 9) {
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 printf("error: audio config name is limited to 9 chars\n");
69
2159f260ed13 fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
24 return(ERROR_USAGE);
32
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 }
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 dp = cmdpkt + 1;
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 *dp++ = ETM_AUDIO;
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 *dp++ = 'L';
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 strcpy(dp, argv[1]);
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 dp += slen + 1;
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 send_etm_cmd(cmdpkt, dp - cmdpkt - 1);
69
2159f260ed13 fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
32 return(0);
32
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 }
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 cmd_audio_save(argc, argv)
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 char **argv;
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 {
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 u_char cmdpkt[MAX_PKT_TO_TARGET], *dp;
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 int slen;
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 slen = strlen(argv[1]);
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 if (slen > 9) {
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 printf("error: audio config name is limited to 9 chars\n");
69
2159f260ed13 fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
44 return(ERROR_USAGE);
32
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 }
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 dp = cmdpkt + 1;
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 *dp++ = ETM_AUDIO;
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 *dp++ = 'S';
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 strcpy(dp, argv[1]);
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 dp += slen + 1;
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 send_etm_cmd(cmdpkt, dp - cmdpkt - 1);
69
2159f260ed13 fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
52 return(0);
32
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 }
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 static struct cmdtab {
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 char *cmd;
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 int minargs;
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 int maxargs;
69
2159f260ed13 fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
59 int (*func)();
32
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 } audio_cmds[] = {
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 {"load", 1, 1, cmd_audio_load},
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 {"save", 1, 1, cmd_audio_save},
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 {0, 0, 0, 0}
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 };
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 cmd_audio(argc, argv)
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 char **argv;
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 {
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 struct cmdtab *tp;
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 int extargs;
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 for (tp = audio_cmds; tp->cmd; tp++)
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 if (!strcmp(tp->cmd, argv[1]))
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 break;
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 if (!tp->func) {
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 printf("error: no such audio command\n");
69
2159f260ed13 fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
77 return(ERROR_USAGE);
32
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 }
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 extargs = argc - 2;
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 if (extargs > tp->maxargs) {
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 printf("error: too many arguments\n");
69
2159f260ed13 fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
82 return(ERROR_USAGE);
32
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 }
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 if (extargs < tp->minargs) {
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 printf("error: too few arguments\n");
69
2159f260ed13 fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
86 return(ERROR_USAGE);
32
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 }
69
2159f260ed13 fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
88 return tp->func(argc - 1, argv + 1);
32
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 }