Date:2011-04-13 14:31:57 (9 years 3 months ago)
Author:Werner Almesberger
Commit:436c9faed55cac5f224d31dec2bf608efe580674
Message:atrf-path: the GUI is now activated with -g; also changed arguments in GUI mode

- atrf-path.c (usage, main): new option -g to invoke the GUI
- atrf-path.c (usage, main): in GUI mode, the number of sweeps is optional
(default: infinite)
- atrf-path.c (main), gui.h (gui), gui.c (gui): exit after the specified
number of sweeps
Files: tools/atrf-path/atrf-path.c (4 diffs)
tools/atrf-path/gui.c (2 diffs)
tools/atrf-path/gui.h (1 diff)

Change Details

tools/atrf-path/atrf-path.c
139139{
140140    fprintf(stderr,
141141"usage: %s [-p power] [-t trim_tx [-t trim_rx]] driver_tx[:arg]\n"
142"%16s driver_rx[:arg] [sweeps [samples]]\n\n"
142"%16s driver_rx[:arg] [sweeps [samples]]\n"
143
144#ifdef HAVE_GFX
145"%6s %s -g [-p power] [-t trim_tx [-t trim_rx]] driver_tx[:arg]\n"
146"%16s driver_rx[:arg] [[sweeps] samples]\n"
147#endif
148    "\n"
149
150#ifdef HAVE_GFX
151" -g display results graphically\n"
152#endif
143153" -p power transmit power, 0 to 15 (default %d)\n"
144154" -t trim trim capacitor, 0 to 15 (default %d)\n"
145    , name, "", DEFAULT_POWER, DEFAULT_TRIM);
155
156    , name, "",
157#ifdef HAVE_GFX
158    "", name, "",
159#endif
160    DEFAULT_POWER, DEFAULT_TRIM);
161
146162    exit(1);
147163}
148164
...... 
155171        .trim_rx = DEFAULT_TRIM,
156172        .samples = 1,
157173    };
174    int graphical = 0;
158175    int power = DEFAULT_POWER;
159176    int sweeps = 1;
160177    unsigned long tmp;
161178    char *end;
162179    int c;
163180
164    while ((c = getopt(argc, argv, "p:t:")) != EOF)
181    while ((c = getopt(argc, argv, "gp:t:")) != EOF)
165182        switch (c) {
183        case'g':
184            graphical = 1;
185            sweeps = 0;
186            break;
166187        case 'p':
167188            tmp = strtoul(optarg, &end, 0);
168189            if (*end || tmp > 15)
...... 
195216        sweeps = strtoul(argv[optind+2], &end, 0);
196217        if (*end)
197218            usage(*argv);
219        if (graphical && argc-optind == 3) {
220            sweep.samples = sweeps;
221            sweeps = 0;
222        }
198223        /* fall through */
199224    case 2:
200225        tx_drv = argv[optind];
...... 
212237        return 1;
213238
214239    sweep.power = 15-power;
215    if (sweeps) /* @@@ hack */
216        do_sweeps(&sweep, sweeps);
240    if (graphical)
241        gui(&sweep, sweeps);
217242    else
218        gui(&sweep);
243        do_sweeps(&sweep, sweeps);
219244
220245    atrf_reg_write(sweep.tx, REG_TRX_STATE, TRX_CMD_TRX_OFF);
221246    atrf_reg_write(sweep.rx, REG_TRX_STATE, TRX_CMD_TRX_OFF);
tools/atrf-path/gui.c
109109}
110110
111111
112void gui(const struct sweep *sweep)
112void gui(const struct sweep *sweep, int sweeps)
113113{
114114    SDL_Surface *surf;
115115    SDL_Event event;
...... 
127127        exit(1);
128128    }
129129
130    while (1) {
130    while (cycle != sweeps || !sweeps) {
131131        struct sample res[N_CHAN*2];
132132
133133        while (SDL_PollEvent(&event))
tools/atrf-path/gui.h
1919
2020
2121#ifdef HAVE_GFX
22void gui(const struct sweep *sweep);
22void gui(const struct sweep *sweep, int sweeps);
2323#else
24#define gui(sweep) abort()
24#define gui(sweep, sweeps) abort()
2525#endif
2626
2727#endif /* !GUI_H */

Archive Download the corresponding diff file



interactive