On Fri, Feb 11, 2011 at 4:37 AM, Osterloh, Martin <[email protected]> wrote: > Hi all, > > I have a little problem here. I want to read the header (specifically > the AM_ID of the packet). > In my BaseStation program (which pretty much the standard one), I am > doing the following: > > message_t* receive( message_t *msg, void *payload, uint8_t len ) > { > message_t *ret = msg; > > atomic > { > if( !uartFull ) > { > // OK the queue is not full, so extract the data > cc2420_header_t* header = call > CC2420PacketBody.getHeader( msg ); > > switch( header->type ) > { > case 6: > { > report_msg *r_msg = (report_msg*) payload; > r_msg->base_id = TOS_NODE_ID; > > call Leds.led0Toggle(); > > break; > } > > case 7: > { > loc_msg *l_msg = (loc_msg*) payload; > > // overwrite the base_id field > l_msg->base_id = TOS_NODE_ID; > > // get the RSSI value > l_msg->rssi = call CC2420Packet.getRssi( msg ); > l_msg->lqi = call CC2420Packet.getLqi( msg ); > > call Leds.led1Toggle(); > > break; > } > > default: > break; > } > > ret = uartQueue[uartIn]; > uartQueue[uartIn] = msg; > > uartIn = (uartIn + 1) % UART_QUEUE_LEN; > > // check, if the queue is full now > if( uartIn == uartOut ) > uartFull = TRUE; > > if( !uartBusy ) > { > // OK message can be send to the serial port > post uartSendTask(); > uartBusy = TRUE; > } > } > else dropBlink(); // queue was full, so discard packet > } > return ret; > } > > The packet comes from a TMote Sky with a CC2420 radio interface. Based > on this, I am looking up the CC2420 packet header. > In case it's am_id 6, I am just overwriting one packet field. In case > it's 7 I am overwriting this field as well plus the RSS and LQI value. > > Unfortunately, when I receive packets the base_id field is never > overwritten. > > Is there anything wrong in the logic/programming?
Do you make sure you copy over the AM ID to the serial active message before sending it over the UART? - om_p _______________________________________________ Tinyos-help mailing list [email protected] https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
