Packet.clear() does not clear the packet payload, only the control fields. Your problem was probably something else.
What platform do you use? Janos On Thu, Jun 18, 2009 at 12:58 AM, Dongzhen Piao<[email protected]> wrote: > Hi all, > > I was writing a simple program to send commands from a base station to > sensor motes. I defined several fields in the command packet, and set them > to predefined command value before sending the packet. > > But when the sensor motes received the command message, all the fields are > 0. After a long period of debugging, I finally found that the problem > happens in the standard BaseStation application shipped with TinyOS 2.1.0. > > Here's the function in BaseStationP.nc file, where the problem occurs: > > task void radioSendTask() { > uint8_t len; > am_id_t id; > am_addr_t addr,source; > message_t* msg; > > atomic > if (radioIn == radioOut && !radioFull) > { > radioBusy = FALSE; > return; > } > > msg = radioQueue[radioOut]; > len = call UartPacket.payloadLength(msg); > addr = call UartAMPacket.destination(msg); > source = call UartAMPacket.source(msg); > id = call UartAMPacket.type(msg); > > call RadioPacket.clear(msg); > call RadioAMPacket.setSource(msg, source); > > if (call RadioSend.send[id](addr, msg, len) == SUCCESS) > call Leds.led0Toggle(); > else > { > failBlink(); > post radioSendTask(); > } > } > > In the line bolded, the function clears all fields in the packet received > from UART, and forwards it to the radio. The behaviour is strangely set to > clear the packet, which is not desirable in such a "bridging" application. > > After commenting out the line, my program worked just fine. > > Does anybody have some idea about this? Is this a bug, or is this some > behaviour desired by the application author? > > Thanks. > > Dongzhen Piao > > > _______________________________________________ > Tinyos-help mailing list > [email protected] > https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help > _______________________________________________ Tinyos-help mailing list [email protected] https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
