Date:2011-07-12 18:32:18 (9 years 1 month ago)
Author:Werner Almesberger
Commit:5621282eb8491e754e1cd431a1713a096219b5f3
Message: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
Files: tools/atrf-txrx/atrf-txrx.c (9 diffs)

Change Details

tools/atrf-txrx/atrf-txrx.c
284284}
285285
286286
287static void receive_hmac(struct atrf_dsc *dsc)
288{
289    uint8_t buf[MAX_PSDU];
290    uint8_t lqi;
291    int n, i;
292
293    atrf_rx_mode(dsc, 1);
294    n = atrf_rx(dsc, buf, sizeof(buf), &lqi);
295    atrf_rx_mode(dsc, 0);
296
297    if (n < 2) {
298        fprintf(stderr, "%d bytes received\n", n);
299        exit(1);
300    }
301    for (i = 0; i != n-2; i++)
302        putchar(buf[i] < ' ' || buf[i] > '~' ? '?' : buf[i]);
303    putchar('\n');
304}
305
306
307static void transmit_hmac(struct atrf_dsc *dsc, const char *msg)
308{
309    atrf_rx_mode(dsc, 1);
310    atrf_tx(dsc, msg, strlen(msg));
311    atrf_rx_mode(dsc, 0);
312}
313
314
287315static void transmit_pattern(struct atrf_dsc *dsc, double pause_s, int times)
288316{
289317    uint8_t buf[MAX_PSDU];
...... 
433461{
434462    fprintf(stderr,
435463"usage: %s [common_options] [message [repetitions]]\n"
464" %s [common_options] -H [message]\n"
436465" %s [common_options] -E pause_s [repetitions]\n"
437466" %s [common_options] -P [max_wait_s]\n"
438467" %s [common_options] -T offset [command]\n\n"
439468" text message mode:\n"
440469" message message string to send (if absent, receive)\n"
441470" repetitions number of times the message is sent (default 1)\n\n"
471" text message mode (hard MAC):\n"
472" -H use hard MAC mode\n"
473" message message string to send (if absent, receive)\n"
442474" PER test mode (transmit only):\n"
443475" -E pause_s seconds to pause between frames (floating-point)\n"
444476" repetitions number of messages to send (default: infinite)\n\n"
...... 
461493" -p power transmit power, -17.2 to 3.0 dBm (default %.1f)\n"
462494" -r rate data rate, 250k, 500k, 1M, or 2M (default: 250k)\n"
463495" -t trim trim capacitor, 0 to 15 (default %d)\n"
464        , name, name, name, name,
496        , name, name, name, name, name,
465497        DEFAULT_CHANNEL, atrf_default_driver_name(),
466498        2405+5*(DEFAULT_CHANNEL-11), DEFAULT_POWER,
467499        DEFAULT_TRIM);
...... 
473505{
474506    enum {
475507        mode_msg,
508        mode_hmac,
476509        mode_per,
477510        mode_ping,
478511        mode_cont_tx,
...... 
491524    const char *pcap_file = NULL;
492525    struct atrf_dsc *dsc;
493526
494    while ((c = getopt(argc, argv, "c:C:d:f:o:p:r:E:Pt:T:")) != EOF)
527    while ((c = getopt(argc, argv, "c:C:d:f:Ho:p:r:E:Pt:T:")) != EOF)
495528        switch (c) {
496529        case 'c':
497530            channel = strtoul(optarg, &end, 0);
...... 
513546            if (channel < 11 || channel > 26)
514547                usage(*argv);
515548            break;
549        case 'H':
550            mode = mode_hmac;
551            break;
516552        case 'o':
517553            pcap_file = optarg;
518554            break;
...... 
582618        case mode_msg:
583619            receive(dsc, pcap_file);
584620            break;
621        case mode_hmac:
622while(1)
623            receive_hmac(dsc);
624            break;
585625        case mode_per:
586626            set_power_dBm(dsc, power, 0);
587627            transmit_pattern(dsc, pause_s, 0);
...... 
601641    case 2:
602642        switch (mode) {
603643        case mode_msg:
644        case mode_hmac:
604645            break;
605646        case mode_per:
606647        case mode_ping:
...... 
623664            set_power_dBm(dsc, power, 1);
624665            transmit(dsc, argv[optind], times);
625666            break;
667        case mode_hmac:
668            set_power_dBm(dsc, power, 1);
669            transmit_hmac(dsc, argv[optind]);
670            break;
626671        case mode_per:
627672            times = strtoul(argv[optind], &end, 0);
628673            if (*end)

Archive Download the corresponding diff file



interactive