Date:2011-04-13 19:01:12 (8 years 4 months ago)
Author:Werner Almesberger
Commit:e2a9c9d06894bd7180a1f88b6fcfc4dba21fdd51
Message:atrf-path: new option -T to sweep only one offset

atrf-path -T +0.5 -g ... 10 10 time:

before (both offsets) 0.65 s
after (one offset) 0.32-0.33 s (50%)

- atrf-path.c (usage, main): new option -T to specify which offset to
sweep (default: sweep both)
- atrf-path.c (do_half_sweep): only sample points with the desired offset
- atrf-path.c (print_sweep): only prints points we've sweeped
- gui.c (segment, draw): inverted flag logic from "have_last" to "first"
- gui.c (draw): only plot points we've sweeped
- gui.c (gui): pass the offset selection to "draw"
Files: tools/atrf-path/atrf-path.c (7 diffs)
tools/atrf-path/gui.c (3 diffs)
tools/atrf-path/sweep.h (2 diffs)

Change Details

tools/atrf-path/atrf-path.c
1414#include <stdlib.h>
1515#include <stdio.h>
1616#include <unistd.h>
17#include <string.h>
1718
1819#include "at86rf230.h"
1920
...... 
111112{
112113    int chan;
113114
115    if (sweep->cont_tx && sweep->cont_tx != cont_tx)
116        return;
114117    for (chan = 11; chan <= 26; chan++) {
115118        set_channel(sweep->rx, chan);
116119        set_channel(sweep->tx, chan);
...... 
134137    int chan;
135138
136139    for (chan = 11; chan <= 26; chan++) {
137        printf("%.1f %.2f %.0f %.0f\n",
138            2350+5*chan-0.5, res->avg, res->min, res->max);
140        if (sweep->cont_tx != CONT_TX_P500K)
141            printf("%.1f %.2f %.0f %.0f\n",
142                2350+5*chan-0.5, res->avg, res->min, res->max);
139143        res++;
140        printf("%.1f %.2f %.0f %.0f\n",
141            2350+5*chan+0.5, res->avg, res->min, res->max);
144        if (sweep->cont_tx != CONT_TX_M500K)
145            printf("%.1f %.2f %.0f %.0f\n",
146                2350+5*chan+0.5, res->avg, res->min, res->max);
142147        res++;
143148    }
144149}
...... 
167172"%6s %s -g common_args [[sweeps] samples]\n"
168173#endif
169174    "\n"
170" common args: [-p power] [-t trim_tx [-t trim_rx]] driver_tx[:arg]\n"
171" driver_rx[:arg]\n\n"
175" common args: [-p power] [-t trim_tx [-t trim_rx]] [-T offset]\n"
176" driver_tx[:arg] driver_rx[:arg]\n\n"
172177
173178#ifdef HAVE_GFX
174" -g display results graphically\n"
179" -g display results graphically\n"
175180#endif
176" -p power transmit power, 0 to 15 (default %d)\n"
177" -t trim trim capacitor, 0 to 15 (default %d)\n"
181" -p power transmit power, 0 to 15 (default %d)\n"
182" -t trim trim capacitor, 0 to 15 (default %d)\n"
183" -T offset constant wave offset in MHz, -0.5 or +0.5 (default: scan both)\n"
178184
179185    , name,
180186#ifdef HAVE_GFX
...... 
192198    struct sweep sweep = {
193199        .trim_tx = -1,
194200        .trim_rx = DEFAULT_TRIM,
201        .cont_tx = 0,
195202        .samples = 1,
196203    };
197204    int graphical = 0;
...... 
201208    char *end;
202209    int c;
203210
204    while ((c = getopt(argc, argv, "gp:t:")) != EOF)
211    while ((c = getopt(argc, argv, "gp:t:T:")) != EOF)
205212        switch (c) {
206213        case'g':
207214            graphical = 1;
...... 
222229            else
223230                sweep.trim_rx = tmp;
224231            break;
232        case 'T':
233            if (!strcmp(optarg, "-0.5"))
234                sweep.cont_tx = CONT_TX_M500K;
235            else if (!strcmp(optarg, "+0.5"))
236                sweep.cont_tx = CONT_TX_P500K;
237            else
238                usage(*argv);
239            break;
225240        default:
226241            usage(*argv);
227242        }
tools/atrf-path/gui.c
4747
4848
4949static void segment(SDL_Surface *s, int *last_x, int *last_y, int x,
50    const struct sample *res, int have_last)
50    const struct sample *res, int first)
5151{
5252    int y = YRES-(res->avg-Y_MIN)/(Y_MAX-Y_MIN)*YRES-1;
5353
54    if (have_last) {
54    if (!first) {
5555        aalineColor(s, *last_x, *last_y, x, y, FG_RGBA);
5656}
5757    *last_x = x;
...... 
5959}
6060
6161
62static void draw(SDL_Surface *s, const struct sample *res)
62static void draw(SDL_Surface *s, const struct sample *res, int cont_tx)
6363{
6464    int last_x, last_y;
65    int x, i;
65    int first, x, i;
6666
6767    x = CHAN_X_OFFSET;
68    first = 1;
6869    for (i = 0; i != N_CHAN; i++) {
69        segment(s, &last_x, &last_y, x, res++, i);
70        if (cont_tx != CONT_TX_P500K) {
71            segment(s, &last_x, &last_y, x, res, first);
72            first = 0;
73        }
74        res++;
7075        x += 2*SIDE_STEP;
71        segment(s, &last_x, &last_y, x, res++, 1);
76
77        if (cont_tx != CONT_TX_M500K) {
78            segment(s, &last_x, &last_y, x, res, first);
79            first = 0;
80        }
81        res++;
7282        x += CHAN_STEP-2*SIDE_STEP;
7383    }
7484}
...... 
148158            aacircleColor(surf, STATUS_X, STATUS_Y, STATUS_R,
149159                OK_RGBA);
150160        }
151        draw(surf, res);
161        draw(surf, res, sweep->cont_tx);
152162
153163        SDL_UnlockSurface(surf);
154164        SDL_UpdateRect(surf, 0, 0, 0, 0);
tools/atrf-path/sweep.h
1414#ifndef SWEEP_H
1515#define SWEEP_H
1616
17#include <stdint.h>
18
1719#include "atrf.h"
1820
1921
...... 
2325    int trim_tx;
2426    int trim_rx;
2527    int power;
28    uint8_t cont_tx;
2629    int samples;
2730};
2831

Archive Download the corresponding diff file



interactive