From: mmaroti Date: Tue, 6 Oct 2009 01:32:10 +0000 (+0000) Subject: automaticaly call Packet.clear if user forgot to do so X-Git-Tag: rc_6_tinyos_2_1_1~208 X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=commitdiff_plain;h=cbfff2298f777dba6fe7651567e466d79ead172c automaticaly call Packet.clear if user forgot to do so --- diff --git a/tos/chips/rf2xx/layers/ActiveMessageConfig.nc b/tos/chips/rf2xx/layers/ActiveMessageConfig.nc index 1de4576b..d5ba7b8e 100755 --- a/tos/chips/rf2xx/layers/ActiveMessageConfig.nc +++ b/tos/chips/rf2xx/layers/ActiveMessageConfig.nc @@ -42,4 +42,12 @@ interface ActiveMessageConfig /** Same as AMPacket.setGroup */ command void setGroup(message_t* msg, am_group_t grp); + + /** + * Check if the packet is properly formatted, and if the user + * forgot to call Packet.clear then format it properly. + * Return SUCCESS if the frame is now properly set up, + * or FAIL of the send operation should be aborted. + */ + command error_t checkFrame(message_t* msg); } diff --git a/tos/chips/rf2xx/layers/ActiveMessageLayerP.nc b/tos/chips/rf2xx/layers/ActiveMessageLayerP.nc index a652486e..1f75d36b 100644 --- a/tos/chips/rf2xx/layers/ActiveMessageLayerP.nc +++ b/tos/chips/rf2xx/layers/ActiveMessageLayerP.nc @@ -65,6 +65,9 @@ implementation if( len > call Packet.maxPayloadLength() ) return EINVAL; + if( call Config.checkFrame(msg) != SUCCESS ) + return FAIL; + call Packet.setPayloadLength(msg, len); call AMPacket.setSource(msg, call AMPacket.address()); call AMPacket.setGroup(msg, call AMPacket.localGroup()); diff --git a/tos/chips/rf2xx/rf212/RF212RadioP.nc b/tos/chips/rf2xx/rf212/RF212RadioP.nc index 699aeb56..14f32949 100644 --- a/tos/chips/rf2xx/rf212/RF212RadioP.nc +++ b/tos/chips/rf2xx/rf212/RF212RadioP.nc @@ -189,6 +189,14 @@ implementation call Ieee154PacketLayer.setDestPan(msg, grp); } + command error_t ActiveMessageConfig.checkFrame(message_t* msg) + { + if( ! call Ieee154PacketLayer.isDataFrame(msg) ) + call Ieee154PacketLayer.createDataFrame(msg); + + return SUCCESS; + } + /*----------------- CsmaConfig -----------------*/ async command bool CsmaConfig.requiresSoftwareCCA(message_t* msg) diff --git a/tos/chips/rf2xx/rf230/RF230RadioP.nc b/tos/chips/rf2xx/rf230/RF230RadioP.nc index 57ad57a9..db37bee3 100644 --- a/tos/chips/rf2xx/rf230/RF230RadioP.nc +++ b/tos/chips/rf2xx/rf230/RF230RadioP.nc @@ -189,6 +189,14 @@ implementation call Ieee154PacketLayer.setDestPan(msg, grp); } + command error_t ActiveMessageConfig.checkFrame(message_t* msg) + { + if( ! call Ieee154PacketLayer.isDataFrame(msg) ) + call Ieee154PacketLayer.createDataFrame(msg); + + return SUCCESS; + } + /*----------------- CsmaConfig -----------------*/ async command bool CsmaConfig.requiresSoftwareCCA(message_t* msg)