Date:2012-06-23 19:35:44 (11 years 9 months ago)
Author:Werner Almesberger
Commit:5b1f72256803c64a287b7b44ce27bf252e12447c
Message:tools/: -S now dumps samples to stdout; -S -S produces graphical output

Files: tools/antorcha.c (7 diffs)

Change Details

tools/antorcha.c
1616#include <stdio.h>
1717#include <unistd.h>
1818#include <string.h>
19#include <signal.h>
1920#include <assert.h>
2021
2122#include <at86rf230.h>
...... 
280281/* ----- Samples ----------------------------------------------------------- */
281282
282283
284static volatile int run = 1;
285
286
287static void sigint(int sig)
288{
289    run = 0;
290}
291
292
283293static int read_sample(uint8_t **s, uint16_t *t_high, uint16_t *t_low,
284294    uint16_t *last)
285295{
...... 
296306}
297307
298308
299static void samples(struct atrf_dsc *dsc)
309static void samples(struct atrf_dsc *dsc, int gui)
300310{
301311    uint8_t buf[MAX_PSDU] = { 0, };
302312    int got;
303313    uint8_t *s;
304314    uint16_t t_high, t_low, last;
305315    int x, y;
316    double t;
306317
307318    buf[0] = 1;
308319    packet(dsc, SAMPLE, 0, 0, buf, PAYLOAD);
309    plot_init();
310    while (1) {
320    if (gui)
321        plot_init();
322    else
323        signal(SIGINT, sigint);
324    while (run) {
311325        got = rf_recv(dsc, buf, sizeof(buf));
312326        if (got <= 3)
313327            continue;
...... 
328342        last = 0;
329343        while (s < buf+got-2) {
330344            x = read_sample(&s, &t_high, &t_low, &last);
345            t = (t_high << 16 | t_low)/1000000.0;
331346            if (debug)
332                fprintf(stderr, "\t%11.6f %d",
333                    (t_high << 16 | t_low)/1000000.0, x);
347                fprintf(stderr, "\t%11.6f %d", t, x);
348            if (!gui)
349                printf("%11.6f\t%d\t", t, x);
334350
335351            y = read_sample(&s, &t_high, &t_low, &last);
352            t = (t_high << 16 | t_low)/1000000.0;
336353            if (debug)
337                fprintf(stderr, "\t%11.6f %d\n",
338                    (t_high << 16 | t_low)/1000000.0, y);
354                fprintf(stderr, "\t%11.6f %d\n", t, y);
355            if (!gui)
356                printf("%11.6f\t%d\n", t, y);
339357
340            if (!plot(x, y))
358            if (gui && !plot(x, y))
341359                goto quit;
342360        }
343361    }
...... 
356374"usage: %s [-d] image_file\n"
357375   "%6s %s [-d] -F firmware_file\n"
358376   "%6s %s [-d] -P\n"
359   "%6s %s [-d] -S\n"
377   "%6s %s [-d] -S [-S]\n"
360378    , name, "", name, "", name, "", name);
361379    exit(1);
362380}
...... 
381399            do_ping = 1;
382400            break;
383401        case 'S':
384            do_sample = 1;
402            do_sample++;
385403            break;
386404        default:
387405            usage(*argv);
388406        }
389407
390    if (do_ping+do_sample+!!fw > 1)
408    if (do_ping+!!do_sample+!!fw > 1)
391409        usage(*argv);
392410    if (do_ping || do_sample || fw) {
393411        if (argc != optind)
...... 
405423    if (do_ping)
406424        ping(dsc);
407425    else if (do_sample)
408        samples(dsc);
426        samples(dsc, do_sample > 1);
409427    else if (fw)
410428        firmware(dsc, fw);
411429    else

Archive Download the corresponding diff file

Branches:
master
tornado-v1



interactive