1
0
mirror of git://projects.qi-hardware.com/antorcha.git synced 2024-11-01 09:09:23 +02:00

tools/antorcha.c: new option -R to command a reset

This commit is contained in:
Werner Almesberger 2012-06-28 00:39:15 -03:00
parent fe3ff8d5e1
commit 00f0b4e692

View File

@ -389,6 +389,15 @@ static void send_param(struct atrf_dsc *dsc)
} }
/* ----- Reset ------------------------------------------------------------- */
static void reset(struct atrf_dsc *dsc)
{
packet_noack(dsc, RESET, 0, 0, unlock_secret, PAYLOAD);
}
/* ----- Samples ----------------------------------------------------------- */ /* ----- Samples ----------------------------------------------------------- */
@ -485,8 +494,9 @@ static void usage(const char *name)
"usage: %s [-d] [param=value ...] image_file\n" "usage: %s [-d] [param=value ...] image_file\n"
"%6s %s [-d] -F firmware_file\n" "%6s %s [-d] -F firmware_file\n"
"%6s %s [-d] -P\n" "%6s %s [-d] -P\n"
"%6s %s [-d] -R\n"
"%6s %s [-d] -S [-S]\n" "%6s %s [-d] -S [-S]\n"
, name, "", name, "", name, "", name); , name, "", name, "", name, "", name, "", name);
exit(1); exit(1);
} }
@ -494,11 +504,11 @@ static void usage(const char *name)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
const char *fw = NULL; const char *fw = NULL;
int do_ping = 0, do_sample = 0; int do_ping = 0, do_reset = 0, do_sample = 0;
struct atrf_dsc *dsc; struct atrf_dsc *dsc;
int c; int c;
while ((c = getopt(argc, argv, "dF:PS")) != EOF) while ((c = getopt(argc, argv, "dF:PRS")) != EOF)
switch (c) { switch (c) {
case 'd': case 'd':
debug++; debug++;
@ -509,6 +519,9 @@ int main(int argc, char **argv)
case 'P': case 'P':
do_ping = 1; do_ping = 1;
break; break;
case 'R':
do_reset = 1;
break;
case 'S': case 'S':
do_sample++; do_sample++;
break; break;
@ -516,9 +529,9 @@ int main(int argc, char **argv)
usage(*argv); usage(*argv);
} }
if (do_ping+!!do_sample+!!fw > 1) if (do_ping+do_reset+!!do_sample+!!fw > 1)
usage(*argv); usage(*argv);
if (do_ping || do_sample || fw) { if (do_ping || do_reset || do_sample || fw) {
if (argc != optind) if (argc != optind)
usage(*argv); usage(*argv);
} else { } else {
@ -533,6 +546,8 @@ int main(int argc, char **argv)
rf_init(dsc, 8, 15); rf_init(dsc, 8, 15);
if (do_ping) if (do_ping)
ping(dsc); ping(dsc);
else if (do_reset)
reset(dsc);
else if (do_sample) else if (do_sample)
samples(dsc, do_sample > 1); samples(dsc, do_sample > 1);
else if (fw) else if (fw)