annotate rvinterf/asyncshell/keypress.c @ 497:74610c4f10f7

target-utils: added 10 ms delay at the end of abb_power_off() The deosmification of the ABB access code (replacement of osmo_delay_ms() bogus delays with correctly-timed ones, which are significantly shorter) had one annoying side effect: when executing the poweroff command from any of the programs, one last '=' prompt character was being sent (and received by the x86 host) as the Calypso board powers off. With delays being shorter now, the abb_power_off() function was returning and the standalone program's main loop was printing its prompt before the Iota chip fully executed the switch-off sequence! I thought about inserting an endless tight loop at the end of the abb_power_off() function, but the implemented solution of a 10 ms delay is a little nicer IMO because if the DEVOFF operation doesn't happen for some reason in a manual hacking scenario, there won't be an artificial blocker in the form of a tight loop keeping us from further poking around.
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 25 May 2019 20:44:05 +0000
parents 8c7e86bc137e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
398
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * Functions for sending simulated keystrokes via GPF MMI CONFIG sysprims.
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdio.h>
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <ctype.h>
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <string.h>
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <strings.h>
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <stdlib.h>
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include "pktmux.h"
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include "limits.h"
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include "exitcodes.h"
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 send_mmi_config_pair(key, value)
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 char *key, *value;
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 {
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 unsigned intlen;
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 u_char sendpkt[MAX_PKT_TO_TARGET+1];
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 unsigned pktlen;
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 intlen = 12 + 7 + strlen(key) + 1 + strlen(value);
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 pktlen = intlen + 4;
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 if (pktlen > MAX_PKT_TO_TARGET) {
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 printf("error: max pkt to target limit exceeded\n");
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 return(ERROR_USAGE);
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 }
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 /* fill out the packet */
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 sendpkt[0] = RVT_L23_HEADER;
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 sendpkt[1] = 0xB7; /* system prim */
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 sendpkt[2] = intlen;
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 sendpkt[3] = intlen >> 8;
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 /* send zeros for the timestamp */
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 sendpkt[4] = 0;
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 sendpkt[5] = 0;
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 sendpkt[6] = 0;
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 sendpkt[7] = 0;
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 /* as far as TI's sw is concerned, we are PCO */
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 sprintf(sendpkt + 8, "PCO MMI CONFIG %s=%s", key, value);
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 /* send it! */
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 send_pkt_to_target(sendpkt, pktlen);
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 return(0);
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 }
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 void
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 cmd_key_interactive(arg)
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 char *arg;
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 {
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 while (isspace(*arg))
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 arg++;
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 if (!*arg) {
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 printf("error: missing string argument\n");
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 return;
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 }
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 send_mmi_config_pair("KEY_SEQUENCE", arg);
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 }
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 cmd_key_oneshot(argc, argv)
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 char **argv;
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 {
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 return send_mmi_config_pair("KEY_SEQUENCE", argv[1]);
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 }
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 void
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 cmd_keydown_interactive(arg)
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 char *arg;
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 {
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 while (isspace(*arg))
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 arg++;
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 if (!*arg) {
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 printf("error: missing string argument\n");
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 return;
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 }
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 send_mmi_config_pair("KEY_PRESS", arg);
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 }
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 cmd_keydown_oneshot(argc, argv)
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 char **argv;
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 {
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 return send_mmi_config_pair("KEY_PRESS", argv[1]);
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 }
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 void
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 cmd_keyup_interactive(arg)
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 char *arg;
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 {
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 while (isspace(*arg))
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 arg++;
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 if (!*arg) {
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 printf("error: missing string argument\n");
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 return;
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 }
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 send_mmi_config_pair("KEY_RELEASE", arg);
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 }
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 cmd_keyup_oneshot(argc, argv)
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 char **argv;
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 {
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 return send_mmi_config_pair("KEY_RELEASE", argv[1]);
8c7e86bc137e fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 }