1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-11-23 02:05:55 +02:00

atspi-txrx: new option -f to set the channel by frequency

- atspi-txrx/atspi-txrx.c (usage): rearranged description of -T
- atspi-txrx/atspi-txrx.c (usage, main): option -f freq to specify the
  channel by frequency
This commit is contained in:
Werner Almesberger 2010-11-11 02:44:33 -03:00
parent d4fe0277c2
commit 1e78135bf4

View File

@ -191,14 +191,17 @@ static void die(int sig)
static void usage(const char *name) static void usage(const char *name)
{ {
fprintf(stderr, fprintf(stderr,
"usage: %s [-c channel] [-p power] [-t trim] [message [repetitions]]\n" "usage: %s [-c channel|-f freq] [-p power] [-t trim] [message [repetitions]]\n"
" %s [-c channel] [-p power] [-t trim] -T delta\n" " %s [-c channel|-f freq] [-p power] [-t trim] -T delta\n"
" -c channel channel number, 11 to 26 (default %d)\n" " -c channel channel number, 11 to 26 (default %d)\n"
" -f freq frequency in MHz, 2405 to 2480 (default %d)\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"
" -t trim trim capacitor, 0 to 15 (default 0)\n" " -t trim trim capacitor, 0 to 15 (default 0)\n"
" -t trim trim capacitor, 0 to 15 (default 0)\n" " -t trim trim capacitor, 0 to 15 (default 0)\n"
" -T delta_MHz test mode. delta_MHz is -2, -0.5, or +0.5\n" " -T delta test mode. delta is the frequency offset of the constant wave\n"
, name, name, DEFAULT_CHANNEL, DEFAULT_POWER); " in MHz: -2, -0.5, or +0.5\n"
, name, name, DEFAULT_CHANNEL, 2405+5*(DEFAULT_CHANNEL-11),
DEFAULT_POWER);
exit(1); exit(1);
} }
@ -210,10 +213,10 @@ int main(int argc, char *const *argv)
int trim = 0, times = 1; int trim = 0, times = 1;
uint8_t cont_tx = 0; uint8_t cont_tx = 0;
char *end; char *end;
int c; int c, freq;
struct atspi_dsc *dsc; struct atspi_dsc *dsc;
while ((c = getopt(argc, argv, "c:p:t:T:")) != EOF) while ((c = getopt(argc, argv, "c:f:p:t:T:")) != EOF)
switch (c) { switch (c) {
case 'c': case 'c':
channel = strtoul(optarg, &end, 0); channel = strtoul(optarg, &end, 0);
@ -222,6 +225,16 @@ int main(int argc, char *const *argv)
if (channel < 11 || channel > 26) if (channel < 11 || channel > 26)
usage(*argv); usage(*argv);
break; break;
case 'f':
freq = strtoul(optarg, &end, 0);
if (*end)
usage(*argv);
if (freq % 5)
usage(*argv);
channel = (freq-2405)/5+11;
if (channel < 11 || channel > 26)
usage(*argv);
break;
case 'p': case 'p':
power = strtod(optarg, &end); power = strtod(optarg, &end);
if (*end) if (*end)