1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-11-22 19:20:41 +02:00

tools/atrf-txrx/atrf-txrx.c: new option -q for quiet capture

This commit is contained in:
Werner Almesberger 2013-07-30 13:48:55 -03:00
parent 0706773e38
commit d1b65cb058

View File

@ -11,6 +11,7 @@
*/ */
#include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
@ -74,6 +75,7 @@ enum mode {
static volatile int run = 1; static volatile int run = 1;
static bool quiet = 0;
/* ----- Helper functions -------------------------------------------------- */ /* ----- Helper functions -------------------------------------------------- */
@ -237,7 +239,8 @@ static void receive_pcap(struct atrf_dsc *dsc, const char *name)
write_pcap_hdr(file); write_pcap_hdr(file);
while (run) { while (run) {
wait_for_interrupt(dsc, wait_for_interrupt(dsc,
IRQ_TRX_END, IRQ_TRX_END | IRQ_RX_START | IRQ_AMI, 0); IRQ_TRX_END,
quiet ? 0xff : IRQ_TRX_END | IRQ_RX_START | IRQ_AMI, 0);
if (!run) if (!run)
break; break;
gettimeofday(&now, NULL); gettimeofday(&now, NULL);
@ -249,6 +252,7 @@ static void receive_pcap(struct atrf_dsc *dsc, const char *name)
continue; continue;
} }
write_pcap_rec(file, &now, buf, n-1); write_pcap_rec(file, &now, buf, n-1);
if (!quiet)
(void) write(2, ".", 1); (void) write(2, ".", 1);
count++; count++;
} }
@ -666,7 +670,7 @@ static void usage(const char *name)
" 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] [-d driver[:arg]] [-o file]\n" " common options: [-c channel|-f freq] [-C mhz] [-d driver[:arg]] [-o file]\n"
" [-p power] [-r rate] [-t trim]\n" " [-p power] [-q] [-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" " -d driver[:arg]\n"
@ -674,6 +678,8 @@ static void usage(const char *name)
" -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"
" -q quiet - suppress progress reports and warnings\n"
" (currently only used when capturing)\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, name, name, name, name,
@ -718,7 +724,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:d:E:f:Ho:p:Pr:Rt:T:x")) != EOF) while ((c = getopt(argc, argv, "c:C:d:E:f:Ho:p:Pqr:Rt:T:x")) != EOF)
switch (c) { switch (c) {
case 'c': case 'c':
channel = strtoul(optarg, &end, 0); channel = strtoul(optarg, &end, 0);
@ -767,6 +773,9 @@ int main(int argc, char *const *argv)
case 'P': case 'P':
set_mode(&mode, mode_ping); set_mode(&mode, mode_ping);
break; break;
case 'q':
quiet = 1;
break;
case 'r': case 'r':
if (!strcmp(optarg, "250k")) if (!strcmp(optarg, "250k"))
rate = OQPSK_DATA_RATE_250; rate = OQPSK_DATA_RATE_250;