From e8550f26ba54e6d8ef03d59ee774e210776a2454 Mon Sep 17 00:00:00 2001 From: Mariano Alvira Date: Sat, 6 Mar 2010 19:14:55 -0500 Subject: [PATCH] this receive seems to work well. It has checksum errors at 123 byte payloads, but this was tested with the old rftest-tx --- so the transmit side could be the problem. --- lib/include/packet.h | 2 +- lib/maca.c | 10 +++++----- tests/per.c | 13 ++++++++----- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/include/packet.h b/lib/include/packet.h index 8cbecc8ac..cf336458f 100644 --- a/lib/include/packet.h +++ b/lib/include/packet.h @@ -12,7 +12,7 @@ struct packet { uint8_t length; volatile struct packet * left; volatile struct packet * right; - uint8_t data[MAX_PACKET_SIZE]; + uint8_t data[MAX_PACKET_SIZE+1]; /* + 1 since maca returns the length as the first byte */ }; typedef struct packet packet_t; diff --git a/lib/maca.c b/lib/maca.c index 28dc8af57..38fe0ce4e 100644 --- a/lib/maca.c +++ b/lib/maca.c @@ -14,16 +14,16 @@ #define NUM_PACKETS 8 #endif -#ifndef RECV_SOFTIMEOUT -#define RECV_SOFTIMEOUT 4096 /* about 3.5 128 byte packets */ -#endif - /* for 250kHz clock */ +#define MACA_CLOCK_DIV 95 /* (32 chips/sym) * (sym/4bits) * (8bits/byte) = (64 chips/byte) */ /* (8 chips/clk) * (byte/64 chips) = byte/8clks */ #define CLK_PER_BYTE 8 -#define MACA_CLOCK_DIV 95 +#ifndef RECV_SOFTIMEOUT +#define RECV_SOFTIMEOUT 4*128*CLK_PER_BYTE /* 4 128 byte packets */ +#endif + #define reg(x) (*(volatile uint32_t *)(x)) diff --git a/tests/per.c b/tests/per.c index c2fcd4989..ac7f562d4 100644 --- a/tests/per.c +++ b/tests/per.c @@ -70,15 +70,18 @@ void session_req(short_addr_t addr) { } void print_packet(packet_t *p) { - volatile uint8_t i,j; + volatile uint8_t i,j,k; +#define PER_ROW 16 if(p) { - printf("len 0x%02x:",p->length); - for(j=0; j < ((p->length)%16)-1; j++) { - for(i=0; ilength; i++) { - printf("%02x ",p->data[j*16+i]); + printf("len 0x%02x\n\r",p->length); + for(j=0, k=0; j < ((p->length)%PER_ROW)-1; j++) { + for(i=0; i < PER_ROW; i++, k++) { + if(k>=p->length) { break; } + printf("%02x ",p->data[j*PER_ROW+i]); } printf("\n\r"); } + printf("\n\r"); } return; }