Interface: tos.interfaces.ReceiveMsg

interface ReceiveMsg

TinyOS AM packet reception interface.

Author:
Jason Hill
David Gay
Philip Levis
Modified:
6/25/02

Events
event TOS_MsgPtr receive(TOS_MsgPtr m) A packet has been received.

Events - Details

receive

event TOS_MsgPtr receive(TOS_MsgPtr m)

A packet has been received. The packet received is passed as a pointer parameter. The event handler should return a pointer to a packet buffer for the reception layer to use for the next reception. This allows an application to swap buffers back and forth with the messaging layer, preventing the need for copying. The signaled component should not maintain a reference to the buffer that it returns. It may return the buffer it was passed. For example:
 event TOS_MsgPtr ReceiveMsg.receive(TOS_MsgPtr m) {
    return m;
 }
 
A more common example:
 TOS_MsgPtr buffer;
 event TOS_MsgPtr ReceiveMsg.receive(TOS_MsgPtr m) {
    TOS_MsgPtr tmp;
    tmp = buffer;
    buffer = m;
	post receiveTask();
	return tmp;
 }
 

Returns:
A buffer for the provider to use for the next packet.