mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-23 01:29:33 +00:00
add an offset to packet_t to compensate for the added length byte on
reception
This commit is contained in:
parent
8421031d4a
commit
024448e65e
@ -12,6 +12,10 @@ struct packet {
|
||||
uint8_t length;
|
||||
volatile struct packet * left;
|
||||
volatile struct packet * right;
|
||||
/* offset into data for first byte of the packet payload */
|
||||
/* On TX this should be 0 */
|
||||
/* On RX this should be 1 since the maca puts the length as the first byte*/
|
||||
uint8_t offset;
|
||||
uint8_t data[MAX_PACKET_SIZE+1]; /* + 1 since maca returns the length as the first byte */
|
||||
};
|
||||
typedef struct packet packet_t;
|
||||
|
@ -167,7 +167,7 @@ void post_tx(void) {
|
||||
last_post = TX_POST;
|
||||
dma_tx = tx_head;
|
||||
*MACA_TXLEN = (uint32_t)((dma_tx->length) + 2);
|
||||
*MACA_DMATX = (uint32_t)&(dma_tx->data[0]);
|
||||
*MACA_DMATX = (uint32_t)&(dma_tx->data[ 0 + dma_tx->offset]);
|
||||
if(dma_rx == 0) {
|
||||
dma_rx = get_free_packet();
|
||||
if (dma_rx == 0)
|
||||
@ -255,8 +255,9 @@ void free_tx_head(void) {
|
||||
|
||||
void add_to_rx(volatile packet_t *p) {
|
||||
safe_irq_disable(MACA);
|
||||
|
||||
|
||||
if(!p) { PRINTF("add_to_rx passed packet 0\n\r"); return; }
|
||||
p->offset = 1; /* first byte is the length */
|
||||
if(rx_head == 0) {
|
||||
/* start a new queue if empty */
|
||||
rx_end = p;
|
||||
|
@ -47,7 +47,7 @@ uint32_t get_time(void) {
|
||||
#define random_short_addr() (*MACA_RANDOM & ones(sizeof(short_addr_t)*8))
|
||||
|
||||
void build_session_req(volatile packet_t *p) {
|
||||
p->length = 4;
|
||||
p->length = 4; p->offset = 0;
|
||||
p->data[0] = 0x01;
|
||||
p->data[1] = 0x02;
|
||||
p->data[2] = 0x03;
|
||||
|
@ -14,6 +14,7 @@ void fill_packet(volatile packet_t *p) {
|
||||
static volatile uint8_t count=0;
|
||||
volatile uint8_t i;
|
||||
p->length = PAYLOAD_LEN;
|
||||
p->offset = 0;
|
||||
for(i=0; i<PAYLOAD_LEN; i++) {
|
||||
p->data[i] = count++;
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ void print_packet(volatile packet_t *p) {
|
||||
for(j=0, k=0; j <= ((p->length)%PER_ROW); j++) {
|
||||
for(i=0; i < PER_ROW; i++, k++) {
|
||||
if(k >= (p->length + 1) ) { goto out; } /* + 1 since first byte is len+2 */
|
||||
printf("%02x ",p->data[j*PER_ROW+i]);
|
||||
printf("%02x ",p->data[j*PER_ROW + i + p->offset]);
|
||||
}
|
||||
printf("\n\r");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user