]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
automaticaly call Packet.clear if user forgot to do so
authormmaroti <mmaroti>
Tue, 6 Oct 2009 01:32:10 +0000 (01:32 +0000)
committermmaroti <mmaroti>
Tue, 6 Oct 2009 01:32:10 +0000 (01:32 +0000)
tos/chips/rf2xx/layers/ActiveMessageConfig.nc
tos/chips/rf2xx/layers/ActiveMessageLayerP.nc
tos/chips/rf2xx/rf212/RF212RadioP.nc
tos/chips/rf2xx/rf230/RF230RadioP.nc

index 1de4576bd668c07d83f0275b01241be20f431c29..d5ba7b8ebb989410c97f9a929a15ab6677eef04e 100755 (executable)
@@ -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);
 }
index a652486ebc7a1feb553d084b0b1744df5bd3d45f..1f75d36b6337ce76a31fa41a075844b241de7ef0 100644 (file)
@@ -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());
index 699aeb56368d1f3626accc3de66e26e12a7ea1bd..14f32949e41972f09e09a622f2ee093b2958412e 100644 (file)
@@ -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)
index 57ad57a9b4c48ace9f68173b733afd1783c3f997..db37bee3d07df52a59684eeb5a7137bbe345b16b 100644 (file)
@@ -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)