1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2025-04-21 12:27:27 +03:00

tools/: added option -d driver[:arg] to all tools

- atrf-id/atrf-id.c (main), atrf-reset/atrf-reset.c (main),
  atrf-trim/atrf-trim.c (main): changed command-line parsing to use
  "getopt"
- atrf-id/atrf-id.c (usage, main), atrf-reset/atrf-reset.c (usage, main),
  atrf-rssi/atrf-rssi.c (usage, main), atrf-trim/atrf-trim.c (usage,
  main), atrf-txrx/atrf-txrx.c (init_txrx, usage, main),
  atrf-xtal/atrf-xtal.c (usage, main): added option -d to select a driver
This commit is contained in:
Werner Almesberger
2011-04-10 07:13:53 -03:00
parent 1175923df7
commit 7ff1a32ccf
6 changed files with 96 additions and 47 deletions

View File

@@ -13,6 +13,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include "atrf.h"
@@ -21,34 +22,40 @@
static void usage(const char *name)
{
fprintf(stderr,
"usage: %s [-a|-t]\n\n"
" -a reset the MCU and transceiver\n"
" -t reset transceiver (default)\n"
, name);
"usage: %s [-a|-t] [-d driver[:arg]]\n\n"
" -a reset MCU and transceiver\n"
" -d driver[:arg] use the specified driver (default: %s)\n"
" -t reset transceiver (default)\n"
, name, atrf_default_driver_name());
exit(1);
}
int main(int argc, const char **argv)
int main(int argc, char *const *argv)
{
const char *driver = NULL;
struct atrf_dsc *dsc;
int txrx = 1;
int c;
switch (argc) {
case 1:
break;
case 2:
if (!strcmp(argv[1], "-t"))
while ((c = getopt(argc, argv, "ad:t")) != EOF)
switch (c) {
case 'a':
txrx = 0;
break;
txrx = 0;
if (!strcmp(argv[1], "-a"))
case 'd':
driver = optarg;
break;
/* fall through */
default:
case 't':
txrx = 1;
break;
default:
usage(*argv);
}
if (argc != optind)
usage(*argv);
}
dsc = atrf_open(NULL);
dsc = atrf_open(driver);
if (!dsc)
return 1;