FreeCalypso > hg > freecalypso-tools
annotate rvinterf/asyncshell/oneshot.c @ 416:30f6d1c32c6f
doc/Flash-boot-defect article removed (no longer relevant)
This article is no longer relevant because the issue in question
only affected one (1) defective FCDEV3B board which was not
and never will be sold.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 26 Oct 2018 07:11:08 +0000 |
parents | 8c7e86bc137e |
children | 10f4062e049b |
rev | line source |
---|---|
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This module implements the one-shot command mode of fc-shell. |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <stdio.h> |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <string.h> |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <strings.h> |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdlib.h> |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include "limits.h" |
64
d43d82cbfb85
fc-shell: use the newly adopted exit code convention
Mychaela Falconia <falcon@freecalypso.org>
parents:
0
diff
changeset
|
10 #include "exitcodes.h" |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 |
398
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
75
diff
changeset
|
12 extern int cmd_key_oneshot(); |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
75
diff
changeset
|
13 extern int cmd_keydown_oneshot(); |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
75
diff
changeset
|
14 extern int cmd_keyup_oneshot(); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 extern int cmd_poweroff(); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 extern int cmd_send_oneshot(); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 extern int cmd_sp_oneshot(); |
75
bbc41034f14c
fc-shell: added support for AT commands in one-shot mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
64
diff
changeset
|
18 extern int cmd_str_oneshot(); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 extern int cmd_tchdl_oneshot(); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 extern int cmd_tgtreset(); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 static struct cmdtab { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 char *cmd; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 int minargs; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 int maxargs; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 int (*func)(); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 } cmdtab[] = { |
398
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
75
diff
changeset
|
28 {"key", 1, 1, cmd_key_oneshot}, |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
75
diff
changeset
|
29 {"keydown", 1, 1, cmd_keydown_oneshot}, |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
75
diff
changeset
|
30 {"keyup", 1, 1, cmd_keyup_oneshot}, |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 {"poweroff", 0, 0, cmd_poweroff}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 {"send", 1, MAX_PKT_TO_TARGET, cmd_send_oneshot}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 {"sp", 2, 2, cmd_sp_oneshot}, |
75
bbc41034f14c
fc-shell: added support for AT commands in one-shot mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
64
diff
changeset
|
34 {"str", 1, 1, cmd_str_oneshot}, |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 {"tch-dl", 1, 1, cmd_tchdl_oneshot}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 {"tgtreset", 0, 0, cmd_tgtreset}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 {0, 0, 0, 0} |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 }; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 oneshot_command(argc, argv) |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 char **argv; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 struct cmdtab *tp; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 |
75
bbc41034f14c
fc-shell: added support for AT commands in one-shot mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
64
diff
changeset
|
45 if (!strncmp(argv[0], "AT", 2) || !strncmp(argv[0], "at", 2)) { |
bbc41034f14c
fc-shell: added support for AT commands in one-shot mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
64
diff
changeset
|
46 if (argc != 1) { |
bbc41034f14c
fc-shell: added support for AT commands in one-shot mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
64
diff
changeset
|
47 fprintf(stderr, |
bbc41034f14c
fc-shell: added support for AT commands in one-shot mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
64
diff
changeset
|
48 "error: AT command must be a single argument\n"); |
bbc41034f14c
fc-shell: added support for AT commands in one-shot mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
64
diff
changeset
|
49 exit(ERROR_USAGE); |
bbc41034f14c
fc-shell: added support for AT commands in one-shot mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
64
diff
changeset
|
50 } |
bbc41034f14c
fc-shell: added support for AT commands in one-shot mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
64
diff
changeset
|
51 return oneshot_at_command(argv[0]); |
bbc41034f14c
fc-shell: added support for AT commands in one-shot mode
Mychaela Falconia <falcon@freecalypso.org>
parents:
64
diff
changeset
|
52 } |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 for (tp = cmdtab; tp->cmd; tp++) |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 if (!strcmp(tp->cmd, argv[0])) |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 break; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 if (!tp->func) { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 fprintf(stderr, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 "error: \"%s\" is not a valid one-shot command\n", |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 argv[0]); |
64
d43d82cbfb85
fc-shell: use the newly adopted exit code convention
Mychaela Falconia <falcon@freecalypso.org>
parents:
0
diff
changeset
|
60 exit(ERROR_USAGE); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 } |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 if (argc - 1 > tp->maxargs) { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 fprintf(stderr, "%s: too many arguments\n", tp->cmd); |
64
d43d82cbfb85
fc-shell: use the newly adopted exit code convention
Mychaela Falconia <falcon@freecalypso.org>
parents:
0
diff
changeset
|
64 exit(ERROR_USAGE); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 } |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 if (argc - 1 < tp->minargs) { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 fprintf(stderr, "%s: too few arguments\n", tp->cmd); |
64
d43d82cbfb85
fc-shell: use the newly adopted exit code convention
Mychaela Falconia <falcon@freecalypso.org>
parents:
0
diff
changeset
|
68 exit(ERROR_USAGE); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 } |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 return tp->func(argc, argv); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 } |