annotate rvinterf/etmsync/help.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 24cb10d508d7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module implements the fc-fsio help facility.
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <stdio.h>
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <ctype.h>
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <string.h>
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <strings.h>
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdlib.h>
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include "exitcodes.h"
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 extern char help_file_pathname[];
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 show_help_topic(topic)
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 char *topic;
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 {
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 FILE *f;
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 char linebuf[256];
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 char *cp, *np;
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 int flag;
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 f = fopen(help_file_pathname, "r");
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 if (!f) {
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 perror(help_file_pathname);
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 return(ERROR_UNIX);
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 }
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 for (;;) {
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 if (!fgets(linebuf, sizeof linebuf, f)) {
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 fprintf(stderr, "Help topic \"%s\" not found\n", topic);
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 fclose(f);
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 return(ERROR_USAGE);
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 }
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 if (linebuf[0] != '=' || linebuf[1] != '=' || linebuf[2] != '=')
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 continue;
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 for (cp = linebuf + 3; isspace(*cp); cp++)
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 ;
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 for (np = cp; *cp && !isspace(*cp); cp++)
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 ;
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 if (*cp)
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 *cp++ = '\0';
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 if (!strcmp(np, topic))
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 break;
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 }
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 for (flag = 0; fgets(linebuf, sizeof linebuf, f); ) {
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 if (linebuf[0] == '=' && linebuf[1] == '=' &&
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 linebuf[2] == '=') {
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 if (flag)
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 break;
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 else
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 continue;
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 }
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 fputs(linebuf, stdout);
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 flag = 1;
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 }
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 fclose(f);
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 return(0);
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 }
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 cmd_help(argc, argv)
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 char **argv;
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 {
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 switch (argc) {
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 case 1:
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 return show_help_topic("main");
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 case 2:
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 return show_help_topic(argv[1]);
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 default:
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 fprintf(stderr, "internal error in cmd_help(): bad argc\n");
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 abort();
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 }
24cb10d508d7 fc-fsio help command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 }