annotate rvinterf/tmsh/audiocmd.c @ 166:2e1be0fc150e

fc-tmsh: ETM_AUDIO commands are just aul/aus/aur/auw, not audio <subcmd>
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 19 Mar 2017 17:17:57 +0000
parents 86e4d8aea021
children 6e4120cdb456
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
158
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
55 cmd_audio_read(argc, argv)
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
56 char **argv;
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
57 {
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
58 unsigned param;
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
59 u_char cmdpkt[5];
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
60
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
61 param = strtoul(argv[1], 0, 0);
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
62 if (param > 255) {
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
63 printf("error: argument is too large\n");
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
64 return(ERROR_USAGE);
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
65 }
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
66 cmdpkt[1] = ETM_AUDIO;
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
67 cmdpkt[2] = 'R';
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
68 cmdpkt[3] = param;
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
69 send_etm_cmd(cmdpkt, 3);
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
70 return(0);
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
71 }