From 7d26c9416bd4638c8a25469579bd39c852da7317 Mon Sep 17 00:00:00 2001 From: kaisenl Date: Sat, 16 Feb 2008 10:56:07 +0000 Subject: [PATCH] changed() gets signaled from local changes --- tos/lib/net/dip/Dip.h | 17 ++++++++++------- tos/lib/net/dip/DisseminatorP.nc | 9 ++++++--- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/tos/lib/net/dip/Dip.h b/tos/lib/net/dip/Dip.h index 6d988607..fd3226bb 100644 --- a/tos/lib/net/dip/Dip.h +++ b/tos/lib/net/dip/Dip.h @@ -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 diff --git a/tos/lib/net/dip/DisseminatorP.nc b/tos/lib/net/dip/DisseminatorP.nc index b3c2ed1b..b7b67a9f 100644 --- a/tos/lib/net/dip/DisseminatorP.nc +++ b/tos/lib/net/dip/DisseminatorP.nc @@ -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(); } -- 2.39.2