mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2024-11-22 07:45:56 +02: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:
parent
1175923df7
commit
7ff1a32ccf
@ -13,6 +13,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef HAVE_USB
|
||||
#include <usb.h>
|
||||
@ -157,18 +158,29 @@ static void show_info(struct atrf_dsc *dsc)
|
||||
|
||||
static void usage(const char *name)
|
||||
{
|
||||
fprintf(stderr, "usage: %s\n", name);
|
||||
fprintf(stderr, "usage: [-d driver[:arg]] %s\n", 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 c;
|
||||
|
||||
if (argc != 1)
|
||||
while ((c = getopt(argc, argv, "d:")) != EOF)
|
||||
switch (c) {
|
||||
case 'd':
|
||||
driver = optarg;
|
||||
break;
|
||||
default:
|
||||
usage(*argv);
|
||||
}
|
||||
if (argc != optind)
|
||||
usage(*argv);
|
||||
dsc = atrf_open(NULL);
|
||||
|
||||
dsc = atrf_open(driver);
|
||||
if (!dsc)
|
||||
return 1;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -64,11 +64,11 @@ static void die(int sig)
|
||||
static void usage(const char *name)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"usage: %s [-n] sweeps\n", name);
|
||||
"usage: %s [-d driver[:arg]] [-n] sweeps\n", name);
|
||||
|
||||
#ifdef HAVE_GFX
|
||||
fprintf(stderr,
|
||||
"%6s %s -g\n", "", name);
|
||||
"%6s %s driver[:arg]] -g\n", "", name);
|
||||
#endif
|
||||
|
||||
exit(1);
|
||||
@ -77,14 +77,18 @@ static void usage(const char *name)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *driver = NULL;
|
||||
struct atrf_dsc *dsc;
|
||||
unsigned long arg = 0, i;
|
||||
char *end;
|
||||
int c;
|
||||
int graphical = 0;
|
||||
|
||||
while ((c = getopt(argc, argv, "gn")) != EOF)
|
||||
while ((c = getopt(argc, argv, "d:gn")) != EOF)
|
||||
switch (c) {
|
||||
case 'd':
|
||||
driver = optarg;
|
||||
break;
|
||||
#ifdef HAVE_GFX
|
||||
case 'g':
|
||||
graphical = 1;
|
||||
@ -115,7 +119,7 @@ int main(int argc, char **argv)
|
||||
|
||||
signal(SIGINT, die);
|
||||
|
||||
dsc = atrf_open(NULL);
|
||||
dsc = atrf_open(driver);
|
||||
if (!dsc)
|
||||
return 1;
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "at86rf230.h"
|
||||
@ -21,22 +22,35 @@
|
||||
|
||||
static void usage(const char *name)
|
||||
{
|
||||
fprintf(stderr, "%s [trim_value]\n", name);
|
||||
fprintf(stderr, "%s [-d driver[:arg]] [trim_value]\n", 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 trim = -1;
|
||||
char *end;
|
||||
int c;
|
||||
|
||||
switch (argc) {
|
||||
case 1:
|
||||
while ((c = getopt(argc, argv, "d:")) != EOF)
|
||||
switch (c) {
|
||||
case 'd':
|
||||
driver = optarg;
|
||||
break;
|
||||
default:
|
||||
usage(*argv);
|
||||
}
|
||||
if (argc != optind)
|
||||
usage(*argv);
|
||||
|
||||
switch (argc-optind) {
|
||||
case 0:
|
||||
break;
|
||||
case 2:
|
||||
trim = strtoul(argv[1], &end, 0);
|
||||
case 1:
|
||||
trim = strtoul(argv[optind], &end, 0);
|
||||
if (*end || trim > 15)
|
||||
usage(*argv);
|
||||
break;
|
||||
@ -44,7 +58,7 @@ int main(int argc, const char **argv)
|
||||
usage(*argv);
|
||||
}
|
||||
|
||||
dsc = atrf_open(NULL);
|
||||
dsc = atrf_open(driver);
|
||||
if (!dsc)
|
||||
return 1;
|
||||
|
||||
|
@ -86,11 +86,11 @@ static volatile int run = 1;
|
||||
* >0 output 2^(clkm-1) MHz signal
|
||||
*/
|
||||
|
||||
static struct atrf_dsc *init_txrx(int trim, unsigned mhz)
|
||||
static struct atrf_dsc *init_txrx(const char *driver, int trim, unsigned mhz)
|
||||
{
|
||||
struct atrf_dsc *dsc;
|
||||
|
||||
dsc = atrf_open(NULL);
|
||||
dsc = atrf_open(driver);
|
||||
if (!dsc)
|
||||
exit(1);
|
||||
|
||||
@ -588,17 +588,20 @@ static void usage(const char *name)
|
||||
" wave in MHz: -2, -0.5, or +0.5\n"
|
||||
" command shell command to run while transmitting (default: wait for\n"
|
||||
" SIGINT instead)\n\n"
|
||||
" common options: [-c channel|-f freq] [-C mhz] [-o file] [-p power]\n"
|
||||
" [-r rate] [-t trim]\n"
|
||||
" common options: [-c channel|-f freq] [-C mhz] [-d driver[:arg]] [-o file]\n"
|
||||
" [-p power] [-r rate] [-t trim]\n"
|
||||
" -c channel channel number, 11 to 26 (default %d)\n"
|
||||
" -C mhz output clock at 1, 2, 4, 8, or 16 MHz (default: off)\n"
|
||||
" -d driver[:arg]\n"
|
||||
" use the specified driver (default: %s)\n"
|
||||
" -f freq frequency in MHz, 2405 to 2480 (default %d)\n"
|
||||
" -o file write received data to a file in pcap format\n"
|
||||
" -p power transmit power, -17.2 to 3.0 dBm (default %.1f)\n"
|
||||
" -r rate data rate, 250k, 500k, 1M, or 2M (default: 250k)\n"
|
||||
" -t trim trim capacitor, 0 to 15 (default %d)\n"
|
||||
, name, name, name, name,
|
||||
DEFAULT_CHANNEL, 2405+5*(DEFAULT_CHANNEL-11), DEFAULT_POWER,
|
||||
DEFAULT_CHANNEL, atrf_default_driver_name(),
|
||||
2405+5*(DEFAULT_CHANNEL-11), DEFAULT_POWER,
|
||||
DEFAULT_TRIM);
|
||||
exit(1);
|
||||
}
|
||||
@ -612,6 +615,7 @@ int main(int argc, char *const *argv)
|
||||
mode_ping,
|
||||
mode_cont_tx,
|
||||
} mode = mode_msg;
|
||||
const char *driver = NULL;
|
||||
int channel = DEFAULT_CHANNEL;
|
||||
double power = DEFAULT_POWER;
|
||||
uint8_t rate = OQPSK_DATA_RATE_250;
|
||||
@ -625,7 +629,7 @@ int main(int argc, char *const *argv)
|
||||
const char *pcap_file = NULL;
|
||||
struct atrf_dsc *dsc;
|
||||
|
||||
while ((c = getopt(argc, argv, "c:C:f:o:p:r:E:Pt:T:")) != EOF)
|
||||
while ((c = getopt(argc, argv, "c:C:d:f:o:p:r:E:Pt:T:")) != EOF)
|
||||
switch (c) {
|
||||
case 'c':
|
||||
channel = strtoul(optarg, &end, 0);
|
||||
@ -634,6 +638,9 @@ int main(int argc, char *const *argv)
|
||||
if (channel < 11 || channel > 26)
|
||||
usage(*argv);
|
||||
break;
|
||||
case 'd':
|
||||
driver = optarg;
|
||||
break;
|
||||
case 'f':
|
||||
freq = strtoul(optarg, &end, 0);
|
||||
if (*end)
|
||||
@ -706,7 +713,7 @@ int main(int argc, char *const *argv)
|
||||
|
||||
switch (argc-optind) {
|
||||
case 0:
|
||||
dsc = init_txrx(trim, clkm);
|
||||
dsc = init_txrx(driver, trim, clkm);
|
||||
set_channel(dsc, channel);
|
||||
set_rate(dsc, rate);
|
||||
switch (mode) {
|
||||
@ -746,7 +753,7 @@ int main(int argc, char *const *argv)
|
||||
usage(*argv);
|
||||
/* fall through */
|
||||
case 1:
|
||||
dsc = init_txrx(trim, clkm);
|
||||
dsc = init_txrx(driver, trim, clkm);
|
||||
set_channel(dsc, channel);
|
||||
set_rate(dsc, rate);
|
||||
switch (mode) {
|
||||
|
@ -83,18 +83,20 @@ static void eval(unsigned *res, int rep)
|
||||
static void usage(const char *name)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s [-r] [-s size] [-t trim] [repetitions]\n"
|
||||
" -r instead of printing a mean value, dump the raw samples\n"
|
||||
" -s size payload size in bytes, 0-127 (default: %d bytes)\n"
|
||||
" -t trim trim capacitor setting, 0-15 (default: %d)\n"
|
||||
" repetitions number of measurements (default: 1)\n"
|
||||
, name, DEFAULT_SIZE, DEFAULT_TRIM);
|
||||
"%s [-d driver[:arg]] [-r] [-s size] [-t trim] [repetitions]\n\n"
|
||||
" -d driver[:arg] use the specified driver (default: %s)\n"
|
||||
" -r instead of printing a mean value, dump the raw samples\n"
|
||||
" -s size payload size in bytes, 0-127 (default: %d bytes)\n"
|
||||
" -t trim trim capacitor setting, 0-15 (default: %d)\n"
|
||||
" repetitions number of measurements (default: 1)\n"
|
||||
, name, atrf_default_driver_name(), DEFAULT_SIZE, DEFAULT_TRIM);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *const *argv)
|
||||
{
|
||||
const char *driver = NULL;
|
||||
struct atrf_dsc *dsc;
|
||||
int size = DEFAULT_SIZE;
|
||||
int trim = DEFAULT_TRIM;
|
||||
@ -104,8 +106,11 @@ int main(int argc, char *const *argv)
|
||||
unsigned *res;
|
||||
int c, i;
|
||||
|
||||
while ((c = getopt(argc, argv, "rs:t:")) != EOF)
|
||||
while ((c = getopt(argc, argv, "d:rs:t:")) != EOF)
|
||||
switch (c) {
|
||||
case 'd':
|
||||
driver = optarg;
|
||||
break;
|
||||
case 'r':
|
||||
dump_raw = 1;
|
||||
break;
|
||||
@ -145,7 +150,7 @@ int main(int argc, char *const *argv)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
dsc = atrf_open(NULL);
|
||||
dsc = atrf_open(driver);
|
||||
if (!dsc)
|
||||
return 1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user