]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Added AM group.
authorscipio <scipio>
Wed, 20 Jun 2007 23:49:02 +0000 (23:49 +0000)
committerscipio <scipio>
Wed, 20 Jun 2007 23:49:02 +0000 (23:49 +0000)
tos/chips/atm128/timer/Atm128AlarmAsyncP.nc
tos/chips/cc1000/CC1000ActiveMessageP.nc
tos/chips/cc1000_lpl/CC1000ActiveMessageP.nc
tos/chips/cc2420/CC2420ActiveMessageP.nc
tos/chips/tda5250/Tda5250ActiveMessageP.nc
tos/chips/xe1205/XE1205ActiveMessageP.nc
tos/interfaces/AMPacket.nc

index 326f6cd000c81afb3487748abacb136d1c93009d..c5b80b41beb788ff30e52bdf8c22a6afdd7568e1 100644 (file)
@@ -97,17 +97,27 @@ implementation
           3, the interrupt will happen whjen TCNT0 is 4) */
        uint8_t interrupt_in = 1 + call Compare.get() - call Timer.get();
        uint8_t newOcr0;
-
-       if (interrupt_in < MINDT || (call TimerCtrl.getInterruptFlag()).bits.ocf0)
+       uint8_t tifr = (uint8_t)((call TimerCtrl.getInterruptFlag()).flat);
+       dbg("Atm128AlarmAsyncP", "Atm128AlarmAsyncP: TIFR is %hhx\n", tifr);
+       if ((interrupt_in != 0 && interrupt_in < MINDT) || (tifr & (1 << OCF0))) {
+         if (interrupt_in < MINDT) {
+           dbg("Atm128AlarmAsyncP", "Atm128AlarmAsyncP: under min: %hhu.\n", interrupt_in);
+         }
+         else {
+           dbg("Atm128AlarmAsyncP", "Atm128AlarmAsyncP: OCF set.\n");
+         }
          return; // wait for next interrupt
+       }
 
        /* When no alarm is set, we just ask for an interrupt every MAXT */
-       if (!set)
+       if (!set) {
          newOcr0 = MAXT;
+         dbg("Atm128AlarmAsyncP", "Atm128AlarmAsyncP: no alarm set, set at max.\n");
+       }
        else
          {
            uint32_t now = call Counter.get();
-
+           dbg("Atm128AlarmAsyncP", "Atm128AlarmAsyncP: now-t0 = %llu, dt = %llu\n", (now-t0), dt);
            /* Check if alarm expired */
            if ((uint32_t)(now - t0) >= dt)
              {
index ce09e7b4bc74c8c4e4334483446933c1af190134..a7a02da337a678d3ee34b02391bc041bb7176898 100644 (file)
@@ -148,9 +148,19 @@ implementation {
     header->type = type;
   }
   
-  //command am_group_t AMPacket.group(message_t* amsg) {
-  //  return amsg->header.group;
-  //}
+  command void AMPacket.setGroup(message_t* msg, am_group_t group) {
+    cc1000_header_t* header = getHeader(msg);
+    header->group = group;
+  }
+
+  command am_group_t AMPacket.group(message_t* msg) {
+    cc1000_header_t* header = getHeader(msg);
+    return header->group;
+  }
+
+  command am_group_t AMPacket.localGroup() {
+    return TOS_AM_GROUP;
+  }
   
  default event message_t* Receive.receive[am_id_t id](message_t* msg, void* payload, uint8_t len) {
     return msg;
index 734d562f85b0e09a41f1e661e872c9070f9cee96..6ce93bad733ca3ffd9edd66ef66122b898dbd8c4 100644 (file)
@@ -147,11 +147,21 @@ implementation {
     cc1000_header_t* header = getHeader(amsg);\r
     header->type = type;\r
   }\r
-  \r
-  //command am_group_t AMPacket.group(message_t* amsg) {\r
-  //  return amsg->header.group;\r
-  //}\r
-  \r
+\r
+  command void AMPacket.setGroup(message_t* msg, am_group_t group) {\r
+    cc1000_header_t* header = getHeader(msg);\r
+    header->group = group;\r
+  }\r
+\r
+  command am_group_t AMPacket.group(message_t* msg) {\r
+    cc1000_header_t* header = getHeader(msg);\r
+    return header->group;\r
+  }\r
+\r
+  command am_group_t AMPacket.localGroup() {\r
+    return TOS_AM_GROUP;\r
+  }\r
+\r
  default event message_t* Receive.receive[am_id_t id](message_t* msg, void* payload, uint8_t len) {\r
     return msg;\r
   }\r
index 45a245f49288b17f35d0f4f3e10e007bf1fcd28e..a4b86251ed615323a69160fd55e38f2b1fc2144a 100644 (file)
@@ -149,6 +149,20 @@ implementation {
     header->type = type;
   }
 
+  command void AMPacket.setGroup(message_t* msg, am_group_t group) {
+    cc2420_header_t* header = call CC2420Packet.getHeader(msg);
+    header->destpan = group;
+  }
+
+  command am_group_t AMPacket.group(message_t* msg) {
+    cc2420_header_t* header = call CC2420Packet.getHeader(msg);
+    return header->destpan;
+  }
+
+  command am_group_t AMPacket.localGroup() {
+    return TOS_AM_GROUP;
+  }
+  
   default event message_t* Receive.receive[am_id_t id](message_t* msg, void* payload, uint8_t len) {
     return msg;
   }
index a0513609f8256bd1cd3351ef2c89b11a03d80d09..149bc0803c1af1205192be657553f3c2093cafa2 100644 (file)
@@ -153,6 +153,21 @@ implementation {
     header->type = type;
   }
 
+  command void AMPacket.setGroup(message_t* msg, am_group_t group) {
+    //tda5250_header_t* header = getHeader(msg);
+    //header->group = group;
+  }
+
+  command am_group_t AMPacket.group(message_t* msg) {
+    //tda5250_header_t* header = getHeader(msg);
+    //return header->group;
+    return TOS_AM_GROUP;
+  }
+
+  command am_group_t AMPacket.localGroup() {
+    return TOS_AM_GROUP;
+  }
+  
  default event message_t* Receive.receive[am_id_t id](message_t* msg, void* payload, uint8_t len) {
     return msg;
   }
index 5281280c2e4d05e1f6ca939a5d3430b3ca0ffdee..09039d76ea512d23185ff166412b9d8ba4fccd84 100644 (file)
@@ -92,6 +92,20 @@ implementation {
     header->type = type;
   }
 
+  command void AMPacket.setGroup(message_t* msg, am_group_t group) {
+    xe1205_header_t* header = getHeader(msg);
+    header->group = group;
+  }
+
+  command am_group_t AMPacket.group(message_t* msg) {
+    xe1205_header_t* header = getHeader(msg);
+    return header->group;
+  }
+
+  command am_group_t AMPacket.localGroup() {
+    return TOS_AM_GROUP;
+  }
+
   command uint8_t AMSend.maxPayloadLength[am_id_t id]() {
     return call Packet.maxPayloadLength();
   }
index 05140a768eeecc3b5b1d18605e6058c3c9b8a432..f403c21d18b84a5b28fa7ace4d5243b351a4ecc7 100644 (file)
@@ -150,4 +150,36 @@ interface AMPacket {
   
   command void setType(message_t* amsg, am_id_t t);
 
+  /**
+   * Get the AM group of the AM packet. The AM group is a logical
+   * identifier that distinguishes sets of nodes which may share
+   * a physical communication medium but wish to not communicate.
+   * The AM group logically separates the sets of nodes. When
+   * a node sends a packet, it fills in its AM group, and typically
+   * nodes only receive packets whose AM group field matches their
+   * own.
+   *
+   * @param amsg the packet
+   * @return the AM group of this packet
+   */
+  
+  command am_group_t group(message_t* amsg);
+
+  /**
+   * Set the AM group field of a packet. Note that most data link
+   * stacks will set this field automatically on a send request, which
+   * may overwrite changes made with this command.
+   *
+   * @param amsg the packet
+   * @param group the packet's new AM group value
+   */
+  command void setGroup(message_t* amsg, am_group_t grp);
+
+  /**
+   * Provides the current AM group of this communication interface.
+   *
+   * @return The AM group.
+   */
+  
+  command am_group_t localGroup();
 }