renamed radio driver

This commit is contained in:
fros4943 2009-04-01 13:44:34 +00:00
parent afed9bb2d0
commit eddd8350c5
2 changed files with 21 additions and 21 deletions

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: cooja-radio.c,v 1.8 2008/03/18 16:22:00 fros4943 Exp $ * $Id: cooja-radio.c,v 1.9 2009/04/01 13:44:34 fros4943 Exp $
*/ */
#include <string.h> #include <string.h>
@ -65,7 +65,7 @@ int inSendFunction = 0;
static void (* receiver_callback)(const struct radio_driver *); static void (* receiver_callback)(const struct radio_driver *);
const struct radio_driver cooja_driver = const struct radio_driver cooja_radio =
{ {
radio_send, radio_send,
radio_read, radio_read,
@ -129,28 +129,28 @@ doInterfaceActionsBeforeTick(void)
simInPolled = 0; simInPolled = 0;
return; return;
} }
// Don't fall asleep while receiving (in main file) // Don't fall asleep while receiving (in main file)
if (simReceiving) { if (simReceiving) {
simLastSignalStrength = simSignalStrength; simLastSignalStrength = simSignalStrength;
simDontFallAsleep = 1; simDontFallAsleep = 1;
return; return;
} }
// If no incoming radio data, do nothing // If no incoming radio data, do nothing
if (simInSize == 0) { if (simInSize == 0) {
simInPolled = 0; simInPolled = 0;
return; return;
} }
// Check size of received packet // Check size of received packet
if (simInSize > COOJA_RADIO_BUFSIZE) { if (simInSize > COOJA_RADIO_BUFSIZE) {
// Drop packet by not delivering // Drop packet by not delivering
return; return;
} }
// ** Good place to add explicit manchester/gcr-encoding // ** Good place to add explicit manchester/gcr-encoding
if(receiver_callback != NULL && !simInPolled) { if(receiver_callback != NULL && !simInPolled) {
simDoReceiverCallback = 1; simDoReceiverCallback = 1;
simInPolled = 1; simInPolled = 1;
@ -165,7 +165,7 @@ radio_read(void *buf, unsigned short bufsize)
{ {
int tmpInSize = simInSize; int tmpInSize = simInSize;
if(simInSize > 0) { if(simInSize > 0) {
memcpy(buf, simInDataBuffer, simInSize); memcpy(buf, simInDataBuffer, simInSize);
simInSize = 0; simInSize = 0;
return tmpInSize; return tmpInSize;
@ -190,31 +190,31 @@ radio_send(const void *payload, unsigned short payload_len)
if(inSendFunction) { if(inSendFunction) {
return COOJA_RADIO_DROPPED; return COOJA_RADIO_DROPPED;
} }
inSendFunction = 1; inSendFunction = 1;
/* If radio is turned off, do nothing */ /* If radio is turned off, do nothing */
if(!simRadioHWOn) { if(!simRadioHWOn) {
inSendFunction = 0; inSendFunction = 0;
return COOJA_RADIO_DROPPED; return COOJA_RADIO_DROPPED;
} }
/* Drop packet if data size too large */ /* Drop packet if data size too large */
if(payload_len > COOJA_RADIO_BUFSIZE) { if(payload_len > COOJA_RADIO_BUFSIZE) {
inSendFunction = 0; inSendFunction = 0;
return COOJA_RADIO_TOOLARGE; return COOJA_RADIO_TOOLARGE;
} }
/* Drop packet if no data length */ /* Drop packet if no data length */
if(payload_len <= 0) { if(payload_len <= 0) {
inSendFunction = 0; inSendFunction = 0;
return COOJA_RADIO_ZEROLEN; return COOJA_RADIO_ZEROLEN;
} }
/* Copy packet data to temporary storage */ /* Copy packet data to temporary storage */
memcpy(simOutDataBuffer, payload, payload_len); memcpy(simOutDataBuffer, payload, payload_len);
simOutSize = payload_len; simOutSize = payload_len;
#if USING_CCA_BUSYWAIT #if USING_CCA_BUSYWAIT
/* Busy-wait until both radio HW and ether is ready */ /* Busy-wait until both radio HW and ether is ready */
{ {
@ -237,15 +237,15 @@ radio_send(const void *payload, unsigned short payload_len)
return COOJA_RADIO_DROPPED; return COOJA_RADIO_DROPPED;
} }
#endif /* USING_CCA */ #endif /* USING_CCA */
if(simOutSize <= 0) { if(simOutSize <= 0) {
inSendFunction = 0; inSendFunction = 0;
return COOJA_RADIO_DROPPED; return COOJA_RADIO_DROPPED;
} }
// - Initiate transmission - // - Initiate transmission -
simTransmitting = 1; simTransmitting = 1;
// Busy-wait while transmitting // Busy-wait while transmitting
while(simTransmitting && !simNoYield) { while(simTransmitting && !simNoYield) {
cooja_mt_yield(); cooja_mt_yield();
@ -253,14 +253,14 @@ radio_send(const void *payload, unsigned short payload_len)
if (simTransmitting) { if (simTransmitting) {
simDontFallAsleep = 1; simDontFallAsleep = 1;
} }
inSendFunction = 0; inSendFunction = 0;
return COOJA_RADIO_OK; return COOJA_RADIO_OK;
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
void radio_call_receiver() void radio_call_receiver()
{ {
receiver_callback(&cooja_driver); receiver_callback(&cooja_radio);
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
SIM_INTERFACE(radio_interface, SIM_INTERFACE(radio_interface,

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: cooja-radio.h,v 1.4 2007/11/25 22:44:40 fros4943 Exp $ * $Id: cooja-radio.h,v 1.5 2009/04/01 13:44:34 fros4943 Exp $
*/ */
#ifndef __COOJA_RADIO_H__ #ifndef __COOJA_RADIO_H__
@ -48,7 +48,7 @@
#define COOJA_RADIO_ZEROLEN UIP_FW_ZEROLEN #define COOJA_RADIO_ZEROLEN UIP_FW_ZEROLEN
#define COOJA_RADIO_OK UIP_FW_OK #define COOJA_RADIO_OK UIP_FW_OK
extern const struct radio_driver cooja_driver; extern const struct radio_driver cooja_radio;
/** /**
* Turn radio hardware on. * Turn radio hardware on.