Date:2011-01-20 23:32:40 (8 years 7 months ago)
Author:Werner Almesberger
Commit:705864d0763fbeb1d6716c3ce8aa27726f0ec21f
Message:atrf-txrx: new option -r to select data rate

- atrf-txrx.c (set_rate, main): allow setting a non-standard high data
rate on the AT86RF231
- atrf-txrx.c (usage, main): added option -r to select the data rate
Files: tools/atrf-txrx/atrf-txrx.c (8 diffs)

Change Details

tools/atrf-txrx/atrf-txrx.c
125125}
126126
127127
128static void set_rate(struct atrf_dsc *dsc, uint8_t rate)
129{
130    if (!rate)
131        return;
132    switch (atrf_identify(dsc)) {
133    case artf_at86rf230:
134        fprintf(stderr, "AT86RF230 only supports 250 kbps\n");
135        break;
136    case artf_at86rf231:
137        atrf_reg_write(dsc, REG_TRX_CTRL_2, rate);
138        break;
139    default:
140        abort();
141    }
142}
143
144
128145static void set_power(struct atrf_dsc *dsc, double power, int crc)
129146{
130147    const double *tx_pwr;
...... 
141158    default:
142159        abort();
143160    }
144
161
145162    for (n = 0; n != sizeof(tx_pwr_230)/sizeof(*tx_pwr_230)-1; n++)
146163        if (tx_pwr[n] <= power)
147164            break;
...... 
568585" wave in MHz: -2, -0.5, or +0.5\n"
569586" command shell command to run while transmitting (default: wait for\n"
570587" SIGINT instead)\n\n"
571" common options: [-c channel|-f freq] [-C mhz] [-o file] [-p power] "
572"[-t trim]\n"
588" common options: [-c channel|-f freq] [-C mhz] [-o file] [-p power]\n"
589" [-r rate] [-t trim]\n"
573590" -c channel channel number, 11 to 26 (default %d)\n"
574591" -C mhz output clock at 1, 2, 4, 8, or 16 MHz (default: off)\n"
575592" -f freq frequency in MHz, 2405 to 2480 (default %d)\n"
576593" -o file write received data to a file in pcap format\n"
577594" -p power transmit power, -17.2 to 3.0 dBm (default %.1f)\n"
595" -r rate data rate, 250k, 500k, 1M, or 2M (default: 250k)\n"
578596" -t trim trim capacitor, 0 to 15 (default 0)\n"
579597        , name, name, name, name,
580598        DEFAULT_CHANNEL, 2405+5*(DEFAULT_CHANNEL-11), DEFAULT_POWER);
...... 
592610    } mode = mode_msg;
593611    int channel = DEFAULT_CHANNEL;
594612    double power = DEFAULT_POWER;
613    uint8_t rate = OQPSK_DATA_RATE_250;
595614    int trim = 0, times = 1;
596615    uint8_t cont_tx = 0;
597616    double pause_s = 0;
...... 
602621    const char *pcap_file = NULL;
603622    struct atrf_dsc *dsc;
604623
605    while ((c = getopt(argc, argv, "c:C:f:o:p:E:Pt:T:")) != EOF)
624    while ((c = getopt(argc, argv, "c:C:f:o:p:r:E:Pt:T:")) != EOF)
606625        switch (c) {
607626        case 'c':
608627            channel = strtoul(optarg, &end, 0);
...... 
629648            if (*end)
630649                usage(*argv);
631650            break;
651        case 'r':
652            if (!strcmp(optarg, "250k"))
653                rate = OQPSK_DATA_RATE_250;
654            else if (!strcmp(optarg, "500k"))
655                rate = OQPSK_DATA_RATE_500;
656            else if (!strcmp(optarg, "1M"))
657                rate = OQPSK_DATA_RATE_1000;
658            else if (!strcmp(optarg, "2M"))
659                rate = OQPSK_DATA_RATE_2000;
660            else
661                usage(*argv);
662            break;
632663        case 't':
633664            trim = strtoul(optarg, &end, 0);
634665            if (*end)
...... 
677708    case 0:
678709        dsc = init_txrx(trim, clkm);
679710        set_channel(dsc, channel);
711        set_rate(dsc, rate);
680712        switch (mode) {
681713        case mode_msg:
682714            receive(dsc, pcap_file);
...... 
716748    case 1:
717749        dsc = init_txrx(trim, clkm);
718750        set_channel(dsc, channel);
751        set_rate(dsc, rate);
719752        switch (mode) {
720753        case mode_msg:
721754            set_power(dsc, power, 1);

Archive Download the corresponding diff file



interactive