[Tinyos-help] A possible bug in BaseStation application, TinyOS 2.1.0
Philip Levis
pal at cs.stanford.edu
Thu Jun 18 14:50:25 PDT 2009
On Jun 17, 2009, at 10:58 PM, Dongzhen Piao 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?
What platform (radio) are you using? The call to clear() should not
clear the packet payload, only the header and metadata. Otherwise
metadata settings from another link layer may be incorrectly
interpreted by the radio stack.
Phil
More information about the Tinyos-help
mailing list