]>
Commit | Line | Data |
---|---|---|
5e993f12 | 1 | Index: lfd.c |
2 | =================================================================== | |
3 | --- lfd.c (revision 1684) | |
4 | +++ lfd.c (working copy) | |
5 | @@ -493,6 +493,16 @@ static void ldr_send_timeout(int sig) | |
6 | warn("received signal %i: timeout while sending; aborting", sig); | |
7 | exit(2); | |
8 | } | |
9 | +static char ldr_send_prompt(const char *msg) | |
10 | +{ | |
11 | + int foo; | |
12 | + char dummy; | |
13 | + alarm(0); | |
14 | + printf("%s: ", msg); | |
15 | + fflush(stdout); | |
16 | + foo = scanf("%c", &dummy); | |
17 | + return (foo == EOF ? EOF : dummy); | |
18 | +} | |
19 | static bool ldr_load_uart(LFD *alfd, const void *void_opts) | |
20 | { | |
21 | const struct ldr_load_options *opts = void_opts; | |
22 | @@ -515,10 +525,9 @@ static bool ldr_load_uart(LFD *alfd, con | |
23 | ||
24 | setbuf(stdout, NULL); | |
25 | ||
26 | - /* give ourselves like ten seconds to do autobaud */ | |
27 | old_alarm = signal(SIGALRM, ldr_send_timeout); | |
28 | - alarm(10); | |
29 | ||
30 | + alarm(10); | |
31 | printf("Opening %s ... ", tty); | |
32 | if (tty[0] != '#') { | |
33 | fd = open(tty, O_RDWR); | |
34 | @@ -538,6 +547,10 @@ static bool ldr_load_uart(LFD *alfd, con | |
35 | } else | |
36 | printf("OK!\n"); | |
37 | ||
38 | + if (opts->prompt) | |
39 | + ldr_send_prompt("Press any key to send autobaud"); | |
40 | + | |
41 | + alarm(10); | |
42 | printf("Trying to send autobaud ... "); | |
43 | ret = write(fd, "@", 1); | |
44 | if (ret != 1) | |
45 | @@ -545,6 +558,10 @@ static bool ldr_load_uart(LFD *alfd, con | |
46 | tcdrain(fd); | |
47 | printf("OK!\n"); | |
48 | ||
49 | + if (opts->prompt) | |
50 | + ldr_send_prompt("Press any key to read autobaud"); | |
51 | + | |
52 | + alarm(10); | |
53 | printf("Trying to read autobaud ... "); | |
54 | ret = read_retry(fd, autobaud, 4); | |
55 | if (ret != 4) | |
56 | @@ -567,10 +584,15 @@ static bool ldr_load_uart(LFD *alfd, con | |
57 | autobaud[0], autobaud[1], autobaud[2], autobaud[3]); | |
58 | ||
59 | if (ldr->header) { | |
60 | + if (opts->prompt) | |
61 | + ldr_send_prompt("Press any key to send global LDR header"); | |
62 | + | |
63 | + alarm(10); | |
64 | printf("Sending global LDR header ... "); | |
65 | ret = write(fd, ldr->header, ldr->header_size); | |
66 | if (ret != (ssize_t)ldr->header_size) | |
67 | goto out; | |
68 | + tcdrain(fd); | |
69 | printf("OK!\n"); | |
70 | } | |
71 | ||
72 | @@ -580,6 +602,9 @@ static bool ldr_load_uart(LFD *alfd, con | |
73 | BLOCK *block = &(ldr->dxes[d].blocks[b]); | |
74 | int del; | |
75 | ||
76 | + if (opts->prompt) | |
77 | + ldr_send_prompt("Press any key to send block header"); | |
78 | + | |
79 | alarm(60); | |
80 | ||
81 | if (verbose) | |
82 | @@ -591,6 +616,9 @@ static bool ldr_load_uart(LFD *alfd, con | |
83 | goto out; | |
84 | tcdrain(fd); | |
85 | ||
86 | + if (opts->prompt && block->data != NULL) | |
87 | + ldr_send_prompt("Press any key to send block data"); | |
88 | + | |
89 | del += printf("%zi] (%2.0f%%)", ldr->dxes[d].num_blocks, | |
90 | ((float)(b+1) / (float)ldr->dxes[d].num_blocks) * 100); | |
91 | if (block->data != NULL) { | |
92 | Index: ldr.c | |
93 | =================================================================== | |
94 | --- ldr.c (revision 1684) | |
95 | +++ ldr.c (working copy) | |
96 | @@ -101,13 +101,15 @@ static struct option_help const create_o | |
97 | }; | |
98 | #define show_create_usage(status) show_some_usage("create", create_long_opts, create_opts_help, CREATE_PARSE_FLAGS, status) | |
99 | ||
100 | -#define LOAD_PARSE_FLAGS COMMON_FLAGS "b:f" | |
101 | +#define LOAD_PARSE_FLAGS COMMON_FLAGS "b:p" | |
102 | static struct option const load_long_opts[] = { | |
103 | {"baud", a_argument, NULL, 'b'}, | |
104 | + {"prompt", no_argument, NULL, 'p'}, | |
105 | COMMON_LONG_OPTS | |
106 | }; | |
107 | static struct option_help const load_opts_help[] = { | |
108 | - {"Set baud rate (default 115200)", "<baud>"}, | |
109 | + {"Set baud rate (default 115200)", "<baud>"}, | |
110 | + {"Prompt for data flow", NULL}, | |
111 | COMMON_HELP_OPTS | |
112 | }; | |
113 | #define show_load_usage(status) show_some_usage("load", load_long_opts, load_opts_help, LOAD_PARSE_FLAGS, status) | |
114 | @@ -238,11 +240,13 @@ static bool load_ldr(const int argc, cha | |
115 | struct ldr_load_options opts = { | |
116 | .tty = NULL, | |
117 | .baud = 115200, | |
118 | + .prompt = false, | |
119 | }; | |
120 | ||
121 | while ((i=getopt_long(argc, argv, LOAD_PARSE_FLAGS, load_long_opts, NULL)) != -1) { | |
122 | switch (i) { | |
123 | case 'b': opts.baud = atoi(optarg); break; | |
124 | + case 'p': opts.prompt = true; break; | |
125 | case 'h': show_load_usage(0); | |
126 | CASE_common_errors | |
127 | } | |
128 | Index: ldr.h | |
129 | =================================================================== | |
130 | --- ldr.h (revision 1684) | |
131 | +++ ldr.h (working copy) | |
132 | @@ -46,6 +46,7 @@ struct ldr_create_options { | |
133 | struct ldr_load_options { | |
134 | const char *tty; | |
135 | size_t baud; | |
136 | + bool prompt; | |
137 | }; | |
138 | ||
139 | struct ldr_dump_options { | |
140 | Index: .depend | |
141 | =================================================================== | |
142 | --- .depend (revision 1684) | |
143 | +++ .depend (working copy) | |
144 | @@ -11,3 +11,4 @@ lfd_bf561.o: lfd_bf561.c ldr.h headers.h | |
145 | dxe_jump.h blackfin_defines.h ldr_elf.h | |
146 | lfd.o: lfd.c ldr.h headers.h elf.h helpers.h lfd.h dxes.h dxe_jump.h \ | |
147 | blackfin_defines.h ldr_elf.h | |
148 | +test.o: test.c |