Date:2012-06-21 21:17:47 (7 years 7 months ago)
Author:Werner Almesberger
Commit:8eca4c99c74a195272740ee944affd783734fff5
Message:fw/sample.c: fix logic in handler() and filter incomplete samples

An incomplete sample would be an X value followed by another X value,
or Y followed by Y. Not entirely sure why this happens in the first
place, but it does happen.
Files: fw/sample.c (2 diffs)

Change Details

fw/sample.c
2323#include "proto.h"
2424#include "dispatch.h"
2525
26#include "io.h"
2627
2728/* @@@ keep it small for now - we're running out of RAM :-( */
2829//#define MAX_PACKET 120 /* <- MAX_PSDU -3 (hdr) -2 (CRC) */
29#define MAX_PACKET 60 /* <- MAX_PSDU -3 (hdr) -2 (CRC) */
30#define MAX_PACKET 50 /* <- MAX_PSDU -3 (hdr) -2 (CRC) */
3031
3132static uint8_t buf[MAX_PACKET+3] = { SAMPLES, 0, 0 };
3233static uint16_t *p;
34static bool expect_x;
3335
3436
3537static void handler(bool x, uint16_t v)
3638{
37    bool first;
3839    uint32_t t;
3940
40    first = p == (uint16_t *) (buf+3);
41    if (first && !x)
41    if (x != expect_x)
4242        return;
43    t = uptime();
44    if (first)
43    t = 0; //uptime_irq();
44    if (p == (uint16_t *) (buf+3))
4545        *p++ = t >> 16;
4646    *p++ = t;
4747    *p++ = v;
48    expect_x = !expect_x;
49
4850    if (x)
4951        return;
5052    if ((uint8_t *) (p+4) <= buf+MAX_PACKET)
5153        return;
54
5255    rf_send(buf, (uint8_t *) p-buf);
56    buf[1]++;
5357    p = (uint16_t *) (buf+3);
5458}
5559
...... 
6165        cli();
6266        sample = handler;
6367        p = (uint16_t *) (buf+3);
68        expect_x = 1;
6469        sei();
6570    } else {
6671        cli();

Archive Download the corresponding diff file

Branches:
master
tornado-v1



interactive