comparison rvinterf/asyncshell/oneshot.c @ 75:bbc41034f14c

fc-shell: added support for AT commands in one-shot mode
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 27 Oct 2016 02:13:38 +0000
parents d43d82cbfb85
children 8c7e86bc137e
comparison
equal deleted inserted replaced
74:84920d3d97c6 75:bbc41034f14c
10 #include "exitcodes.h" 10 #include "exitcodes.h"
11 11
12 extern int cmd_poweroff(); 12 extern int cmd_poweroff();
13 extern int cmd_send_oneshot(); 13 extern int cmd_send_oneshot();
14 extern int cmd_sp_oneshot(); 14 extern int cmd_sp_oneshot();
15 extern int cmd_str_oneshot();
15 extern int cmd_tchdl_oneshot(); 16 extern int cmd_tchdl_oneshot();
16 extern int cmd_tgtreset(); 17 extern int cmd_tgtreset();
17 18
18 static struct cmdtab { 19 static struct cmdtab {
19 char *cmd; 20 char *cmd;
22 int (*func)(); 23 int (*func)();
23 } cmdtab[] = { 24 } cmdtab[] = {
24 {"poweroff", 0, 0, cmd_poweroff}, 25 {"poweroff", 0, 0, cmd_poweroff},
25 {"send", 1, MAX_PKT_TO_TARGET, cmd_send_oneshot}, 26 {"send", 1, MAX_PKT_TO_TARGET, cmd_send_oneshot},
26 {"sp", 2, 2, cmd_sp_oneshot}, 27 {"sp", 2, 2, cmd_sp_oneshot},
28 {"str", 1, 1, cmd_str_oneshot},
27 {"tch-dl", 1, 1, cmd_tchdl_oneshot}, 29 {"tch-dl", 1, 1, cmd_tchdl_oneshot},
28 {"tgtreset", 0, 0, cmd_tgtreset}, 30 {"tgtreset", 0, 0, cmd_tgtreset},
29 {0, 0, 0, 0} 31 {0, 0, 0, 0}
30 }; 32 };
31 33
32 oneshot_command(argc, argv) 34 oneshot_command(argc, argv)
33 char **argv; 35 char **argv;
34 { 36 {
35 struct cmdtab *tp; 37 struct cmdtab *tp;
36 38
39 if (!strncmp(argv[0], "AT", 2) || !strncmp(argv[0], "at", 2)) {
40 if (argc != 1) {
41 fprintf(stderr,
42 "error: AT command must be a single argument\n");
43 exit(ERROR_USAGE);
44 }
45 return oneshot_at_command(argv[0]);
46 }
37 for (tp = cmdtab; tp->cmd; tp++) 47 for (tp = cmdtab; tp->cmd; tp++)
38 if (!strcmp(tp->cmd, argv[0])) 48 if (!strcmp(tp->cmd, argv[0]))
39 break; 49 break;
40 if (!tp->func) { 50 if (!tp->func) {
41 fprintf(stderr, 51 fprintf(stderr,