]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
fixing TimeSyncMessage for the IRIS
authormmaroti <mmaroti>
Sat, 29 Mar 2008 20:10:33 +0000 (20:10 +0000)
committermmaroti <mmaroti>
Sat, 29 Mar 2008 20:10:33 +0000 (20:10 +0000)
14 files changed:
tos/chips/rf230/DefaultMacC.nc
tos/chips/rf230/DefaultMacP.nc
tos/chips/rf230/DefaultPacket.h
tos/chips/rf230/DefaultPacketC.nc
tos/chips/rf230/DefaultPacketP.nc
tos/chips/rf230/PacketLastTouch.nc
tos/chips/rf230/PacketTimeSynch.nc [deleted file]
tos/chips/rf230/RF230Config.nc
tos/chips/rf230/RF230LayerC.nc
tos/chips/rf230/RF230LayerP.nc
tos/chips/rf230/TimeSyncMessageC.nc
tos/chips/rf230/TimeSyncMessageP.nc
tos/platforms/iris/ActiveMessageC.nc
tos/platforms/iris/chips/rf230/HplRF230C.nc

index 2143adc35a34ce0f7825140b587098f0ac2815eb..9db81a0d8d8bb60793c206b9a1ed87a54de46cc4 100644 (file)
@@ -39,6 +39,8 @@ configuration DefaultMacC
 
                interface PacketField<uint8_t> as PacketLinkQuality;
                interface PacketTimeStamp<TRF230, uint16_t>;
+
+               interface PacketLastTouch;
        }
 }
 
@@ -60,6 +62,9 @@ implementation
        PacketLinkQuality = DefaultPacketC.PacketLinkQuality;
        PacketTimeStamp = DefaultPacketC.PacketTimeStamp;
 
+       PacketLastTouch = DefaultPacketC;
+       RF230LayerC.lastTouch -> DefaultPacketC.lastTouch;
+
        components ActiveMessageLayerC;
        components MessageBufferLayerC;
        components UniqueLayerC;
index 1ab43da41b710a34ee01c39e9c77be15fea4f3d0..ddd131fb314eada8a8c9cfac5d1f69a2dc213b8f 100644 (file)
@@ -295,5 +295,4 @@ implementation
        async command void DummyConfig.nothing()
        {
        }
-
 }
index 65ab1fe5acb7b6f19753efea7143e122d4248010..ff29c0e8ea4fc1f1f4fbbb08bc9431e1c6a06772 100644 (file)
@@ -43,8 +43,9 @@ typedef nx_struct defpacket_metadata_t
 
 enum defpacket_metadata_flags
 {
-       DEFPACKET_WAS_ACKED = 0x01,
-       DEFPACKET_TIMESTAMP = 0x02,
+       DEFPACKET_WAS_ACKED = 0x01,             // PacketAcknowledgements
+       DEFPACKET_TIMESTAMP = 0x02,             // PacketTimeStamp
+       DEFPACKET_LAST_TOUCH = 0x04,    // PacketLastTouch.touch
 
        DEFPACKET_CLEAR_METADATA = 0x00,
 };
index 3c32ee332561af81aa669fbb526356e20938c611..1658139d7f14af21161431a6c388ce3212d19bdb 100644 (file)
@@ -34,6 +34,9 @@ configuration DefaultPacketC
                interface PacketField<uint8_t> as PacketTransmitPower;
 
                interface PacketTimeStamp<TRF230, uint16_t>;
+               interface PacketLastTouch;
+
+               async event void lastTouch(message_t* msg);
        }
 }
 
@@ -48,5 +51,8 @@ implementation
        PacketAcknowledgements = DefaultPacketP;
        PacketLinkQuality = DefaultPacketP.PacketLinkQuality;
        PacketTransmitPower = DefaultPacketP.PacketTransmitPower;
-       PacketTimeStamp = DefaultPacketP.PacketTimeStamp;
+       PacketTimeStamp = DefaultPacketP;
+
+       PacketLastTouch = DefaultPacketP;
+       lastTouch = DefaultPacketP;
 }
index a0cb16f36623ddaa520e80d94b8e64879879f3af..577ff252ca8f17219935c1cb2fdccc0170f5d20d 100644 (file)
@@ -33,6 +33,9 @@ module DefaultPacketP
                interface PacketField<uint8_t> as PacketTransmitPower;
 
                interface PacketTimeStamp<TRF230, uint16_t>;
+               interface PacketLastTouch;
+
+               async event void lastTouch(message_t* msg);
        }
 
        uses
@@ -190,4 +193,31 @@ implementation
                flags |= FLAG_TXPOWER;
                transmitPower = value;
        }
+
+/*----------------- PacketLastTouch -----------------*/
+       
+       async command void PacketLastTouch.request(message_t* msg)
+       {
+               getMeta(msg)->flags |= DEFPACKET_LAST_TOUCH;
+       }
+
+       async command void PacketLastTouch.cancel(message_t* msg)
+       {
+               getMeta(msg)->flags &= ~DEFPACKET_LAST_TOUCH;
+       }
+
+       async command bool PacketLastTouch.isPending(message_t* msg)
+       {
+               return getMeta(msg)->flags & DEFPACKET_LAST_TOUCH;
+       }
+
+       async event void lastTouch(message_t* msg)
+       {
+               if( getMeta(msg)->flags & DEFPACKET_LAST_TOUCH )
+                       signal PacketLastTouch.touch(msg);
+       }
+
+       default async event void PacketLastTouch.touch(message_t* msg)
+       {
+       }
 }
index af51caf7a2108765037702bc7b18e52ff3bc58c8..a090bcc98f284c0c38d475802394b7bcda5096fa 100644 (file)
@@ -34,6 +34,11 @@ interface PacketLastTouch
         */
        async command void cancel(message_t* msg);
 
+       /**
+        * Returns TRUE if the touch callback is already scheduled.
+        */
+       async command bool isPending(message_t* msg);
+
        /**
         * This event is called by the MAC layer when the tranmission of the
         * message starts (the SFD byte is already transmitted and the packet
diff --git a/tos/chips/rf230/PacketTimeSynch.nc b/tos/chips/rf230/PacketTimeSynch.nc
deleted file mode 100644 (file)
index 42ff676..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2007, Vanderbilt University
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose, without fee, and without written agreement is
- * hereby granted, provided that the above copyright notice, the following
- * two paragraphs and the author appear in all copies of this software.
- * 
- * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
- * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT
- * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * 
- * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Author: Miklos Maroti
- */
-
-interface PacketTimeSynch<precision_tag, size_type>
-{
-       /**
-        * The recveiver should call this method to ensure that the received 
-        * message contains an embedded timestamp and that is correct (for the 
-        * same reason as for PacketTimeStamp.isSet). If this method returns 
-        * TRUE, then the eventTime returned by the get command is correct,
-        * and reflects the event time in the local clock of the receiver.
-        */
-       async command bool isSet(message_t* msg);
-
-       /**
-        * This command should be called by the receiver. The time stamp of the
-        * received message is added to the embedded time difference to get the
-        * eventTime as measured by the clock of the receiver. The caller should
-        * call the isSet command before to make sure that the returned time is
-        * correct.
-        */
-       async command size_type get(message_t* msg);
-
-       /**
-        * Clears the time stamp in the message. 
-        */
-       async command void clear(message_t* msg);
-
-       /**
-        * This command should be called by the sender on packets used for sender- 
-        * receiver time synchronization. The eventTime parameter should be as 
-        * close to the current time as possible (precision and size of the stamp 
-        * permitting) to avoid large time synchronization errors resulting from
-        * the time skew between the clocks of the sender and receiver. The
-        * time difference between the sending time and eventTime is stored in 
-        * the message just before it is transmitted over the air.
-        */
-       async command void set(message_t* msg, size_type eventTime);
-}
index 9f5f044cbf254fe9673be53d55eb0d6f46afb848..0bd2e40915b5bca70dc03523a448f9a44d8acf03 100644 (file)
@@ -48,7 +48,9 @@ interface RF230Config
        /**
         * Gets the number of bytes we should read before the RadioReceive.header
         * event is fired. If the length of the packet is less than this amount, 
-        * then that event is fired earlier.
+        * then that event is fired earlier. The last touch event is not signaled 
+        * for packets whose length is less than or equal to this header length.
+        * The header length must be at least 1.
         */
        async command uint8_t getHeaderLength();
 
index 7e12df94004b4c060e133d8ee3b9451aa769399f..3cd59d8a254fad08d04a332868f88ff355b942ba 100644 (file)
@@ -37,6 +37,8 @@ configuration RF230LayerC
                interface PacketField<uint8_t> as PacketLinkQuality;
                interface PacketField<uint8_t> as PacketTransmitPower;
                interface PacketTimeStamp<TRF230, uint16_t>;
+
+               async event void lastTouch(message_t* msg);
        }
 }
 
@@ -69,6 +71,8 @@ implementation
        RF230LayerP.Tasklet -> TaskletC;
        RF230LayerP.BusyWait -> BusyWaitMicroC;
 
+       lastTouch = RF230LayerP.lastTouch;
+
 #ifdef RF230_DEBUG
        components DiagMsgC;
        RF230LayerP.DiagMsg -> DiagMsgC;
index 2796fd4e17a1f213be99b5375a87fad66ecebb87..153b9ee1679f665cd58288b7f4f5729022c2ef35 100644 (file)
@@ -61,6 +61,8 @@ module RF230LayerP
                interface Tasklet;
                interface RadioAlarm;
 
+               async event void lastTouch(message_t* msg);
+
 #ifdef RF230_DEBUG
                interface DiagMsg;
 #endif
@@ -380,6 +382,7 @@ implementation
                uint16_t time;
                uint8_t length;
                uint8_t* data;
+               uint8_t header;
 
                if( cmd != CMD_NONE || state != STATE_RX_ON || ! isSpiAcquired() || radioIrq )
                        return EBUSY;
@@ -427,9 +430,24 @@ implementation
                // length | data[0] ... data[length-3] | automatically generated FCS
                call HplRF230.spiSplitReadWrite(length);
 
-               // the FCS is atomatically generated
+               // the FCS is atomatically generated (2 bytes)
                length -= 2;
 
+               header = call RF230Config.getHeaderLength();
+               if( header > length )
+                       header = length;
+
+               length -= header;
+
+               // first upload the header
+               do {
+                       call HplRF230.spiSplitReadWrite(*(data++));
+               }
+               while( --header != 0 );
+
+               call PacketTimeStamp.set(msg, time);
+               signal lastTouch(msg);
+
                do {
                        call HplRF230.spiSplitReadWrite(*(data++));
                }
@@ -537,8 +555,10 @@ implementation
 
                        length -= read;
 
-                       while( read-- != 0 )
+                       do {
                                crc = call HplRF230.crcByte(crc, *(data++) = call HplRF230.spiSplitReadWrite(0));
+                       }
+                       while( --read != 0  );
 
                        if( signal RadioReceive.header(rxMsg) )
                        {
index 5876b0cf69d399bac6be2e04ae21b64ff041f89d..79ad086717be82b771899f9959d22b0dbe8978fc 100644 (file)
@@ -30,7 +30,7 @@ configuration TimeSyncMessageC
        {
                interface TimeSyncSend<TMicro> as TimeSyncSendMicro[am_id_t id];
                interface TimeSyncPacket<TMicro> as TimeSyncPacketMicro;
-               interface LocalTime<TMicro> as LocalTimeMicro;
+//             interface LocalTime<TMicro> as LocalTimeMicro;
 
                interface TimeSyncSend<TMilli> as TimeSyncSendMilli[am_id_t id];
                interface TimeSyncPacket<TMilli> as TimeSyncPacketMilli;
@@ -51,7 +51,7 @@ implementation
 
        TimeSyncSendMicro = TimeSyncMessageP;
        TimeSyncPacketMicro = TimeSyncMessageP;
-       LocalTimeMicro = ActiveMessageC;
+//     LocalTimeMicro = LocalTimeMicroC;
 
        TimeSyncSendMilli = TimeSyncMessageP;
        TimeSyncPacketMilli = TimeSyncMessageP;
@@ -60,9 +60,12 @@ implementation
        Packet = TimeSyncMessageP;
        TimeSyncMessageP.SubSend -> ActiveMessageC.AMSend;
        TimeSyncMessageP.SubPacket -> ActiveMessageC.Packet;
+       TimeSyncMessageP.PacketTimeStamp -> ActiveMessageC;
 
        TimeSyncMessageP.LocalTimeMilli -> LocalTimeMilliC;
 
+       TimeSyncMessageP.PacketLastTouch -> ActiveMessageC;
+
        SplitControl = ActiveMessageC;
        Receive = ActiveMessageC.Receive;
        Snoop = ActiveMessageC.Snoop;
index 9a936c80266df4cf48fa5671b140ff26b2556746..310a097483c9593945967b74ce436a56e9f8c760 100644 (file)
@@ -38,7 +38,7 @@ module TimeSyncMessageP
        {
                interface AMSend as SubSend[uint8_t id];
                interface Packet as SubPacket;
-               interface PacketTimeStamp<TMicro,uint32_t>;
+               interface PacketTimeStamp<TMicro,uint16_t>;             // TODO: change this to 32-bit
                interface PacketLastTouch;
 
                interface LocalTime<TMicro> as LocalTimeMicro;
@@ -55,6 +55,7 @@ implementation
                uint32_t event_time;            // in microsec
        } timesync_local_t;
 
+       // TODO: change the Packet.payloadLength and Packet.maxPayloadLength commands to async
        inline timesync_footer_t* getFooter(message_t* msg)
        {
                return (timesync_footer_t*)(msg->data + call SubPacket.payloadLength(msg) - sizeof(timesync_footer_t));
@@ -101,7 +102,7 @@ implementation
 
                call PacketLastTouch.request(msg);
 
-               return call SubSend.send[id](addr, msg, len);
+               return call SubSend.send[id](addr, msg, len + sizeof(timesync_footer_t));
        }
 
        command error_t TimeSyncSendMicro.cancel[am_id_t id](message_t* msg)
@@ -137,7 +138,7 @@ implementation
 
                call PacketLastTouch.request(msg);
 
-               return call SubSend.send[id](addr, msg, len);
+               return call SubSend.send[id](addr, msg, len + sizeof(timesync_footer_t));
        }
 
        command error_t TimeSyncSendMilli.cancel[am_id_t id](message_t* msg)
index 3253e611d0ae2e52e6046d31c25e332b44c46d08..eda2370c05f570ab66ddf0413f2f9c1feccb2935 100644 (file)
@@ -36,6 +36,7 @@ configuration ActiveMessageC
                interface PacketAcknowledgements;
                interface PacketField<uint8_t> as PacketLinkQuality;
                interface PacketTimeStamp<TMicro, uint16_t>;
+               interface PacketLastTouch;
        }
 }
 
@@ -53,4 +54,5 @@ implementation
        PacketAcknowledgements = MAC;
        PacketLinkQuality = MAC;
        PacketTimeStamp = MAC;
+       PacketLastTouch = MAC;
 }
index 65459b40c9aab4bdc5bb11712a4a76a129c375e7..113d47cd7030e53747e70d313afa0b0a4a30b055 100644 (file)
@@ -36,7 +36,6 @@ configuration HplRF230C
 
                interface GpioCapture as IRQ;
                interface Alarm<TRF230, uint16_t> as Alarm;
-               interface LocalTime<TRF230>;
 
                interface HplRF230;
        }
@@ -71,12 +70,4 @@ implementation
 
        components RealMainP;
        RealMainP.PlatformInit -> HplRF230P.PlatformInit;
-
-       components CounterOne16C;
-       components new TransformCounterC(TRF230, uint32_t, TRF230, uint16_t, 0, uint32_t);
-       components new CounterToLocalTimeC(TRF230);
-
-       LocalTime = CounterToLocalTimeC;
-       CounterToLocalTimeC.Counter -> TransformCounterC;
-       TransformCounterC.CounterFrom -> CounterOne16C;
 }