From d272b062f08b9daf0d27d78a6b673f0e45bfe242 Mon Sep 17 00:00:00 2001 From: fros4943 Date: Tue, 21 Aug 2007 13:09:40 +0000 Subject: [PATCH] reimplemented receiver calls (earlier tcpip_input) from inside multithreaded environment --- platform/cooja/dev/cooja-radio.c | 9 +++++++-- platform/cooja/dev/cooja-radio.h | 7 ++++++- platform/cooja/lib/simEnvChange.c | 4 ++-- platform/cooja/lib/simEnvChange.h | 4 ++-- tools/cooja/config/contiki_template.c | 8 ++++---- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/platform/cooja/dev/cooja-radio.c b/platform/cooja/dev/cooja-radio.c index 31317b4b2..94ee4ecaa 100644 --- a/platform/cooja/dev/cooja-radio.c +++ b/platform/cooja/dev/cooja-radio.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: cooja-radio.c,v 1.4 2007/05/29 12:53:49 fros4943 Exp $ + * $Id: cooja-radio.c,v 1.5 2007/08/21 13:09:40 fros4943 Exp $ */ #include @@ -148,7 +148,7 @@ doInterfaceActionsBeforeTick(void) // ** Good place to add explicit manchester/gcr-encoding if(receiver_callback != NULL && !simInPolled) { - receiver_callback(&cooja_driver); + simDoReceiverCallback = 1; simInPolled = 1; } else { simInPolled = 0; @@ -252,6 +252,11 @@ radio_send(const u8_t *payload, u16_t payload_len) return COOJA_RADIO_OK; } /*-----------------------------------------------------------------------------------*/ +void radio_call_receiver() +{ + receiver_callback(&cooja_driver); +} +/*-----------------------------------------------------------------------------------*/ SIM_INTERFACE(radio_interface, doInterfaceActionsBeforeTick, doInterfaceActionsAfterTick); diff --git a/platform/cooja/dev/cooja-radio.h b/platform/cooja/dev/cooja-radio.h index 9ad2c6f07..d88bb2ea8 100644 --- a/platform/cooja/dev/cooja-radio.h +++ b/platform/cooja/dev/cooja-radio.h @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: cooja-radio.h,v 1.2 2007/05/18 15:20:20 fros4943 Exp $ + * $Id: cooja-radio.h,v 1.3 2007/08/21 13:09:40 fros4943 Exp $ */ #ifndef __COOJA_RADIO_H__ @@ -113,4 +113,9 @@ int radio_sstrength(void); */ int radio_current_sstrength(void); +/** + * Internal COOJA function, calls the current receiver function. + */ +void radio_call_receiver(void); + #endif /* __COOJA_RADIO_H__ */ diff --git a/platform/cooja/lib/simEnvChange.c b/platform/cooja/lib/simEnvChange.c index 1b38a6d84..b820a8d91 100644 --- a/platform/cooja/lib/simEnvChange.c +++ b/platform/cooja/lib/simEnvChange.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: simEnvChange.c,v 1.6 2006/10/09 14:42:38 fros4943 Exp $ + * $Id: simEnvChange.c,v 1.7 2007/08/21 13:09:55 fros4943 Exp $ */ #include @@ -39,7 +39,7 @@ extern const struct simInterface *simInterfaces[]; char simDontFallAsleep = 0; char simNoYield = 0; -char simDoTcpipInput = 0; +char simDoReceiverCallback = 0; int simProcessRunValue; int simEtimerPending; diff --git a/platform/cooja/lib/simEnvChange.h b/platform/cooja/lib/simEnvChange.h index ea743cdae..7f5ac8c00 100644 --- a/platform/cooja/lib/simEnvChange.h +++ b/platform/cooja/lib/simEnvChange.h @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: simEnvChange.h,v 1.6 2006/10/09 14:42:38 fros4943 Exp $ + * $Id: simEnvChange.h,v 1.7 2007/08/21 13:09:55 fros4943 Exp $ */ #ifndef __SIMENVCHANGE_H__ @@ -46,7 +46,7 @@ extern int simNextExpirationTime; // Variable that when set to != 0, stops the mote from falling asleep next tick extern char simDontFallAsleep; extern char simNoYield; -extern char simDoTcpipInput; +extern char simDoReceiverCallback; // Definition for registering an interface #define SIM_INTERFACE(name, doActionsBeforeTick, doActionsAfterTick) \ diff --git a/tools/cooja/config/contiki_template.c b/tools/cooja/config/contiki_template.c index d76cbdfb1..3e11ae036 100644 --- a/tools/cooja/config/contiki_template.c +++ b/tools/cooja/config/contiki_template.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: contiki_template.c,v 1.3 2007/05/21 15:00:13 fros4943 Exp $ + * $Id: contiki_template.c,v 1.4 2007/08/21 13:10:19 fros4943 Exp $ */ /** @@ -111,9 +111,9 @@ start_process_run_loop(void *data) /* Always pretend we have processes left while inside process_run() */ simProcessRunValue = 1; - if (simDoTcpipInput) { - simDoTcpipInput = 0; - tcpip_input(); + if (simDoReceiverCallback) { + simDoReceiverCallback = 0; + radio_call_receiver(); } simProcessRunValue = process_run();