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

tools/atrf-xmit/atrf-xmit.c (xfer_one, usage, main): new option -v (verbose)

This commit is contained in:
Werner Almesberger 2011-05-18 16:49:38 -03:00
parent 430a29695d
commit 558017e34d

View File

@ -28,6 +28,9 @@
#define PSDU_SIZE 127 #define PSDU_SIZE 127
static int verbose = 0;
static void init_common(struct atrf_dsc *dsc, int trim, int channel) static void init_common(struct atrf_dsc *dsc, int trim, int channel)
{ {
atrf_reg_write(dsc, REG_TRX_STATE, TRX_CMD_TRX_OFF); atrf_reg_write(dsc, REG_TRX_STATE, TRX_CMD_TRX_OFF);
@ -100,7 +103,14 @@ static int xfer_one(struct atrf_dsc *tx, struct atrf_dsc *rx)
* @@@ We should analyze the CRC here to see if the first or the second * @@@ We should analyze the CRC here to see if the first or the second
* byte got corrupted. * byte got corrupted.
*/ */
if (verbose) {
printf("%d", i+1);
for (i = 0; i != n-2; i++)
printf("%s%02x", i ? " " : "\t", buf[i]);
printf("\n");
} else {
printf("%d\n", i+1); printf("%d\n", i+1);
}
return 0; return 0;
} }
@ -119,11 +129,12 @@ static void xfer(struct atrf_dsc *tx, struct atrf_dsc *rx, int packets)
static void usage(const char *name) static void usage(const char *name)
{ {
fprintf(stderr, fprintf(stderr,
"usage: %s [-c channel] [-p power] [-t trim_tx [-t trim_rx]]\n" "usage: %s [-c channel] [-p power] [-t trim_tx [-t trim_rx]] [-v]\n"
"%15s driver_tx[:arg] driver_rx[:arg] [packets]\n\n" "%15s driver_tx[:arg] driver_rx[:arg] [packets]\n\n"
" -c channel transmit/receive channel, 11 to 26 (default %d)\n" " -c channel transmit/receive channel, 11 to 26 (default %d)\n"
" -p power transmit power, 0 to 15 (default %d)\n" " -p power transmit power, 0 to 15 (default %d)\n"
" -t trim trim capacitor, 0 to 15 (default %d)\n" " -t trim trim capacitor, 0 to 15 (default %d)\n"
" -v verbose reporting of transmission errors\n"
, name, "", , name, "",
DEFAULT_CHANNEL, DEFAULT_POWER, DEFAULT_TRIM); DEFAULT_CHANNEL, DEFAULT_POWER, DEFAULT_TRIM);
exit(1); exit(1);
@ -142,7 +153,7 @@ int main(int argc, char **argv)
char *end; char *end;
int c; int c;
while ((c = getopt(argc, argv, "c:p:t:")) != EOF) while ((c = getopt(argc, argv, "c:p:t:v")) != EOF)
switch (c) { switch (c) {
case 'c': case 'c':
tmp = strtoul(optarg, &end, 0); tmp = strtoul(optarg, &end, 0);
@ -150,6 +161,9 @@ int main(int argc, char **argv)
usage(*argv); usage(*argv);
channel = tmp; channel = tmp;
break; break;
case 'v':
verbose++;
break;
case 'p': case 'p':
tmp = strtoul(optarg, &end, 0); tmp = strtoul(optarg, &end, 0);
if (*end || tmp > 15) if (*end || tmp > 15)