mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2024-11-22 18:50:37 +02:00
tools/atrf-txrx/: added option -H to enter simple HardMAC mode
- atrf-txrx.c (receive_hmac, transmit_hmac): HardMAC send/receive functions - atrf-txrx.c (usage, main): new option -H to use HardMAC
This commit is contained in:
parent
49d6067e88
commit
5621282eb8
@ -284,6 +284,34 @@ static void transmit(struct atrf_dsc *dsc, const char *msg, int times)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void receive_hmac(struct atrf_dsc *dsc)
|
||||||
|
{
|
||||||
|
uint8_t buf[MAX_PSDU];
|
||||||
|
uint8_t lqi;
|
||||||
|
int n, i;
|
||||||
|
|
||||||
|
atrf_rx_mode(dsc, 1);
|
||||||
|
n = atrf_rx(dsc, buf, sizeof(buf), &lqi);
|
||||||
|
atrf_rx_mode(dsc, 0);
|
||||||
|
|
||||||
|
if (n < 2) {
|
||||||
|
fprintf(stderr, "%d bytes received\n", n);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
for (i = 0; i != n-2; i++)
|
||||||
|
putchar(buf[i] < ' ' || buf[i] > '~' ? '?' : buf[i]);
|
||||||
|
putchar('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void transmit_hmac(struct atrf_dsc *dsc, const char *msg)
|
||||||
|
{
|
||||||
|
atrf_rx_mode(dsc, 1);
|
||||||
|
atrf_tx(dsc, msg, strlen(msg));
|
||||||
|
atrf_rx_mode(dsc, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void transmit_pattern(struct atrf_dsc *dsc, double pause_s, int times)
|
static void transmit_pattern(struct atrf_dsc *dsc, double pause_s, int times)
|
||||||
{
|
{
|
||||||
uint8_t buf[MAX_PSDU];
|
uint8_t buf[MAX_PSDU];
|
||||||
@ -433,12 +461,16 @@ static void usage(const char *name)
|
|||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"usage: %s [common_options] [message [repetitions]]\n"
|
"usage: %s [common_options] [message [repetitions]]\n"
|
||||||
|
" %s [common_options] -H [message]\n"
|
||||||
" %s [common_options] -E pause_s [repetitions]\n"
|
" %s [common_options] -E pause_s [repetitions]\n"
|
||||||
" %s [common_options] -P [max_wait_s]\n"
|
" %s [common_options] -P [max_wait_s]\n"
|
||||||
" %s [common_options] -T offset [command]\n\n"
|
" %s [common_options] -T offset [command]\n\n"
|
||||||
" text message mode:\n"
|
" text message mode:\n"
|
||||||
" message message string to send (if absent, receive)\n"
|
" message message string to send (if absent, receive)\n"
|
||||||
" repetitions number of times the message is sent (default 1)\n\n"
|
" repetitions number of times the message is sent (default 1)\n\n"
|
||||||
|
" text message mode (hard MAC):\n"
|
||||||
|
" -H use hard MAC mode\n"
|
||||||
|
" message message string to send (if absent, receive)\n"
|
||||||
" PER test mode (transmit only):\n"
|
" PER test mode (transmit only):\n"
|
||||||
" -E pause_s seconds to pause between frames (floating-point)\n"
|
" -E pause_s seconds to pause between frames (floating-point)\n"
|
||||||
" repetitions number of messages to send (default: infinite)\n\n"
|
" repetitions number of messages to send (default: infinite)\n\n"
|
||||||
@ -461,7 +493,7 @@ static void usage(const char *name)
|
|||||||
" -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, name,
|
||||||
DEFAULT_CHANNEL, atrf_default_driver_name(),
|
DEFAULT_CHANNEL, atrf_default_driver_name(),
|
||||||
2405+5*(DEFAULT_CHANNEL-11), DEFAULT_POWER,
|
2405+5*(DEFAULT_CHANNEL-11), DEFAULT_POWER,
|
||||||
DEFAULT_TRIM);
|
DEFAULT_TRIM);
|
||||||
@ -473,6 +505,7 @@ int main(int argc, char *const *argv)
|
|||||||
{
|
{
|
||||||
enum {
|
enum {
|
||||||
mode_msg,
|
mode_msg,
|
||||||
|
mode_hmac,
|
||||||
mode_per,
|
mode_per,
|
||||||
mode_ping,
|
mode_ping,
|
||||||
mode_cont_tx,
|
mode_cont_tx,
|
||||||
@ -491,7 +524,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:f:o:p:r:E:Pt:T:")) != EOF)
|
while ((c = getopt(argc, argv, "c:C:d:f:Ho:p:r:E:Pt:T:")) != EOF)
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'c':
|
case 'c':
|
||||||
channel = strtoul(optarg, &end, 0);
|
channel = strtoul(optarg, &end, 0);
|
||||||
@ -513,6 +546,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 'H':
|
||||||
|
mode = mode_hmac;
|
||||||
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
pcap_file = optarg;
|
pcap_file = optarg;
|
||||||
break;
|
break;
|
||||||
@ -582,6 +618,10 @@ int main(int argc, char *const *argv)
|
|||||||
case mode_msg:
|
case mode_msg:
|
||||||
receive(dsc, pcap_file);
|
receive(dsc, pcap_file);
|
||||||
break;
|
break;
|
||||||
|
case mode_hmac:
|
||||||
|
while(1)
|
||||||
|
receive_hmac(dsc);
|
||||||
|
break;
|
||||||
case mode_per:
|
case mode_per:
|
||||||
set_power_dBm(dsc, power, 0);
|
set_power_dBm(dsc, power, 0);
|
||||||
transmit_pattern(dsc, pause_s, 0);
|
transmit_pattern(dsc, pause_s, 0);
|
||||||
@ -601,6 +641,7 @@ int main(int argc, char *const *argv)
|
|||||||
case 2:
|
case 2:
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case mode_msg:
|
case mode_msg:
|
||||||
|
case mode_hmac:
|
||||||
break;
|
break;
|
||||||
case mode_per:
|
case mode_per:
|
||||||
case mode_ping:
|
case mode_ping:
|
||||||
@ -623,6 +664,10 @@ int main(int argc, char *const *argv)
|
|||||||
set_power_dBm(dsc, power, 1);
|
set_power_dBm(dsc, power, 1);
|
||||||
transmit(dsc, argv[optind], times);
|
transmit(dsc, argv[optind], times);
|
||||||
break;
|
break;
|
||||||
|
case mode_hmac:
|
||||||
|
set_power_dBm(dsc, power, 1);
|
||||||
|
transmit_hmac(dsc, argv[optind]);
|
||||||
|
break;
|
||||||
case mode_per:
|
case mode_per:
|
||||||
times = strtoul(argv[optind], &end, 0);
|
times = strtoul(argv[optind], &end, 0);
|
||||||
if (*end)
|
if (*end)
|
||||||
|
Loading…
Reference in New Issue
Block a user