[Tinyos-devel] BaseStation clears packet payload on mica2

Philipp Sommer sommer at tik.ee.ethz.ch
Tue Jul 29 01:26:24 PDT 2008


We observed a problem when using the BaseStation application on the
mica2 platform. The current implementation (from CVS) clears the packet
payload (setting it to all zeros) when packets are bridged between the
radio and the UART.

The problem seems to arise from a call to the Packet.clear() method
which is implemented differently for mica2. On the mica2 platform
(CC1000SendReceiveP.nc) the whole message_t struct is cleared whereas
on the micaz platform (CC2420ActiveMessageP.nc) only the header and the
metadata fields are cleared (see code snippets below). 

Removing the call to Packet.clear() in BaseStationP.nc seems to solve
the problem with the empty packet payload on the mica2 platform.
However, this quick fix might possibly lead to problems on other
platforms.

Philipp


Here are the relevant code snippets:


tos/chips/cc1000/CC1000SendReceiveP.nc:
***************************************************************
command void Packet.clear(message_t *msg) {
  memset(msg, 0, sizeof(message_t));
}


tos/chips/cc2420/CC2420ActiveMessageP.nc:
***************************************************************
command void Packet.clear(message_t* msg) {
  memset(call CC2420PacketBody.getHeader(msg), 0x0,
sizeof(cc2420_header_t));
  memset(call CC2420PacketBody.getMetadata(msg), 0x0,
sizeof(cc2420_metadata_t));
}


tos/apps/BaseStation/BaseStationP.nc:
***************************************************************

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();
      }
  }




More information about the Tinyos-devel mailing list