]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
changed() gets signaled from local changes
authorkaisenl <kaisenl>
Sat, 16 Feb 2008 10:56:07 +0000 (10:56 +0000)
committerkaisenl <kaisenl>
Sat, 16 Feb 2008 10:56:07 +0000 (10:56 +0000)
tos/lib/net/dip/Dip.h
tos/lib/net/dip/DisseminatorP.nc

index 6d9886076dc74b9f2470870ac8fed7faf2a7fdac..fd3226bbbb9a86475512f9431b79111733f7699e 100644 (file)
@@ -19,7 +19,10 @@ typedef enum {
 } dip_msgid_t;
 
 enum {
-  AM_DIP = 0x84
+  AM_DIP = 0x84,
+  AM_DIP_DATA_MSG = 0x84, // For MIG tool
+  AM_DIP_MSG = 0x84, // For MIG tool
+  AM_DIP_DATA = 0x84 // For MIG tool
 };
 
 typedef uint16_t dip_index_t;
@@ -30,24 +33,24 @@ typedef nx_uint32_t nx_dip_version_t;
 typedef uint8_t dip_estimate_t;
 typedef dip_index_t dip_hashlen_t;
 
-typedef nx_struct dip_msg_t {
+typedef nx_struct dip_msg {
   nx_uint8_t type; // dip_msgid_t
   nx_uint8_t content[0];
 } dip_msg_t;
 
-typedef nx_struct dip_data_msg_t {
+typedef nx_struct dip_data_msg {
   nx_dip_key_t key;
   nx_dip_version_t version;
   nx_uint8_t size;
   nx_uint8_t data[0];
 } dip_data_msg_t;
 
-typedef nx_struct dip_vector_msg_t {
+typedef nx_struct dip_vector_msg {
   nx_uint8_t unitLen;
   nx_uint32_t vector[0];
 } dip_vector_msg_t;
 
-typedef nx_struct dip_summary_msg_t {
+typedef nx_struct dip_summary_msg {
   nx_uint8_t unitLen;
   nx_uint32_t salt;
   nx_uint32_t info[0];
@@ -64,8 +67,8 @@ dip_estimate_t DIP_VECTOR_ESTIMATE;
 
 /* TUNABLE PARAMETERS */
 
-typedef struct dip_data_t {
-  uint8_t data[16];
+typedef nx_struct dip_data {
+  nx_uint8_t data[16];
 } dip_data_t;
 
 #define DIP_SUMMARY_VALUES_PER_PACKET 2
index b3c2ed1b824de43aa4242c90c2e1aa243bf2a1de..b7b67a9f8a6663f5c462dd4c11271e05c788ff5a 100644 (file)
@@ -57,11 +57,11 @@ generic module DisseminatorP(typedef t, dip_key_t key) {
 }
 implementation {
   dip_data_t valueCache;
-
+  
   task void signalNewData() {
     signal AppDisseminationValue.changed();
   }
-
+  
   command error_t Init.init() {
     call DipHelp.registerKey(key);
     return SUCCESS;
@@ -77,6 +77,8 @@ implementation {
 
   command void AppDisseminationValue.set( const t* val ) {
     memcpy( &valueCache, val, sizeof(t) );
+    // must signal here instead of posting task to prevent race condition
+    signal AppDisseminationValue.changed();
   }
 
   command void AppDisseminationUpdate.change( t* newVal ) {
@@ -85,6 +87,7 @@ implementation {
     /* DipLogicC doesn't care what the data actually is,
        it just wants the key, so we cast it recklessly */
     call DipDisseminationUpdate.change((dip_data_t*)newVal);
+    post signalNewData();
   }
 
   command const dip_data_t* DataDisseminationValue.get() {
@@ -95,7 +98,7 @@ implementation {
 
   command void DataDisseminationUpdate.change( dip_data_t* newVal ) {
     memcpy( &valueCache, newVal, sizeof(dip_data_t) );
-    //post signalNewData();
+    // don't post the task, this came from the network
     signal AppDisseminationValue.changed();
   }