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