reimplemented receiver calls (earlier tcpip_input) from inside multithreaded environment

This commit is contained in:
fros4943 2007-08-21 13:09:40 +00:00
parent fa6748f45a
commit d272b062f0
5 changed files with 21 additions and 11 deletions

View File

@ -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 <string.h>
@ -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);

View File

@ -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__ */

View File

@ -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 <stdio.h>
@ -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;

View File

@ -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) \

View File

@ -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();