void *payload,
uint8_t len) {
message_t *ret = msg;
-#if 0
- if (!msg->crc || msg->group != TOS_AM_GROUP)
- return msg;
-#endif
atomic {
if (!uartFull)
COMPONENT=BaseStationC
-CFLAGS += -I%T/oski
include $(MAKERULES)
Known bugs/limitations:
On CC2420 platforms, BaseStation can only overhear packets transmitted
-to it or to the broadcast address. This is due to how the CC2420 hardware
-filters packets based on address and how the CC2420 stack uses that
-functionality; future versions will not have this limitation.
+to it or to the broadcast address. For these platforms (e.g., micaz,
+telos, intel mote 2), you should use BaseStationCC2420.
Known bugs/limitations:
-None.
+On CC2420 platforms, BaseStation can only overhear packets transmitted
+to it or to the broadcast address. For these platforms (e.g., micaz,
+telos, intel mote 2), you should use BaseStationCC2420.
+
+
COMPONENT=MultihopOscilloscopeAppC
-CFLAGS += -I$(TOSDIR)/lib/net/collection
+CFLAGS += -I$(TOSDIR)/lib/net/ -I$(TOSDIR)/lib/net/ctp -I$(TOSDIR)/lib/net/le -I.
include $(MAKERULES)
increase the message_t size. */
NREADINGS = 5,
/* Default sampling period. */
- DEFAULT_INTERVAL = 256,
+ DEFAULT_INTERVAL = 1024,
AM_OSCILLOSCOPE = 0x93
};
components MainC, MultihopOscilloscopeC, LedsC, new TimerMilliC(),
new DemoSensorC() as Sensor;
+ //MainC.SoftwareInit -> Sensor;
+
MultihopOscilloscopeC.Boot -> MainC;
MultihopOscilloscopeC.Timer -> TimerMilliC;
MultihopOscilloscopeC.Read -> Sensor;
// Communication components. These are documented in TEP 113:
// Serial Communication, and TEP 119: Collection.
//
- components TreeCollectionC as Collector, // Collection layer
+ components CollectionC as Collector, // Collection layer
ActiveMessageC, // AM layer
new CollectionSenderC(AM_OSCILLOSCOPE), // Sends multihop RF
SerialActiveMessageC, // Serial messaging
MultihopOscilloscopeC.Receive -> Collector.Receive[AM_OSCILLOSCOPE];
MultihopOscilloscopeC.RootControl -> Collector;
+ components new PoolC(message_t, 10) as UARTMessagePoolP,
+ new QueueC(message_t*, 10) as UARTQueueP;
+
+ MultihopOscilloscopeC.UARTMessagePool -> UARTMessagePoolP;
+ MultihopOscilloscopeC.UARTQueue -> UARTQueueP;
+
//
// Components for debugging collection.
//
- components new PoolC(message_t, 10) as DebugMessagePool,
- new QueueC(message_t*, 10) as DebugSendQueue,
- new SerialAMSenderC(AM_COLLECTION_DEBUG) as DebugSerialSender,
+ components new PoolC(message_t, 20) as DebugMessagePool,
+ new QueueC(message_t*, 20) as DebugSendQueue,
+ new SerialAMSenderC(AM_CTP_DEBUG) as DebugSerialSender,
UARTDebugSenderP as DebugSender;
DebugSender.Boot -> MainC;
interface CollectionPacket;
interface RootControl;
+ interface Queue<message_t *> as UARTQueue;
+ interface Pool<message_t> as UARTMessagePool;
+
// Miscalleny:
interface Timer<TMilli>;
interface Read<uint16_t>;
event void Boot.booted() {
local.interval = DEFAULT_INTERVAL;
local.id = TOS_NODE_ID;
+ local.version = 0;
// Beginning our initialization phases:
if (call RadioControl.start() != SUCCESS)
}
static void startTimer() {
+ if (call Timer.isRunning()) call Timer.stop();
call Timer.startPeriodic(local.interval);
reading = 0;
}
//
event message_t*
Receive.receive(message_t* msg, void *payload, uint8_t len) {
+ oscilloscope_t* in = (oscilloscope_t*)payload;
+ oscilloscope_t* out;
if (uartbusy == FALSE) {
- oscilloscope_t* in = (oscilloscope_t*)payload;
- oscilloscope_t* out = (oscilloscope_t*)call SerialSend.getPayload(&uartbuf);
+ out = (oscilloscope_t*)call SerialSend.getPayload(&uartbuf);
if (len != sizeof(oscilloscope_t)) {
return msg;
}
else {
memcpy(out, in, sizeof(oscilloscope_t));
}
- uartbusy = TRUE;
uartlen = sizeof(oscilloscope_t);
post uartSendTask();
+ } else {
+ // The UART is busy; queue up messages and service them when the
+ // UART becomes free.
+ message_t *newmsg = call UARTMessagePool.get();
+ if (newmsg == NULL) {
+ // drop the message on the floor if we run out of queue space.
+ report_problem();
+ return msg;
+ }
+
+ //Prepare message to be sent over the uart
+ out = (oscilloscope_t*)call SerialSend.getPayload(newmsg);
+ memcpy(out, in, sizeof(oscilloscope_t));
+
+ if (call UARTQueue.enqueue(newmsg) != SUCCESS) {
+ // drop the message on the floor and hang if we run out of
+ // queue space without running out of queue space first (this
+ // should not occur).
+ call UARTMessagePool.put(newmsg);
+ fatal_problem();
+ return msg;
+ }
}
return msg;
task void uartSendTask() {
if (call SerialSend.send(0xffff, &uartbuf, uartlen) != SUCCESS) {
- uartbusy = FALSE;
+ report_problem();
+ } else {
+ uartbusy = TRUE;
}
}
+
+ event void SerialSend.sendDone(message_t *msg, error_t error) {
+ uartbusy = FALSE;
+ if (call UARTQueue.empty() == FALSE) {
+ // We just finished a UART send, and the uart queue is
+ // non-empty. Let's start a new one.
+ message_t *queuemsg = call UARTQueue.dequeue();
+ if (queuemsg == NULL) {
+ fatal_problem();
+ return;
+ }
+ memcpy(&uartbuf, queuemsg, sizeof(message_t));
+ if (call UARTMessagePool.put(queuemsg) != SUCCESS) {
+ fatal_problem();
+ return;
+ }
+ post uartSendTask();
+ }
+ }
+
//
// Overhearing other traffic in the network.
//
local.readings[reading++] = data;
}
- event void SerialSend.sendDone(message_t *msg, error_t error) {
- uartbusy = FALSE;
- }
// Use LEDs to report various status issues.
static void fatal_problem() {
}
implementation
{
- event void Boot.booted()
- {
+ event void Boot.booted() {
+ // Do nothing.
}
}
Null is an empty skeleton application. It is useful to test that the
build environment is functional in its most minimal sense, i.e., you
-can correctly compile an application.
+can correctly compile an application. It is also useful to test the
+minimum power consumption of a node when it has absolutely no
+interrupts or resources active.
Tools:
* 94704. Attention: Intel License Inquiry.
*/
-//@author Cory Sharp <cssharp@eecs.berkeley.edu>
+/**
+ * Configuration for the PowerUp application.
+ *
+ * @author Cory Sharp <cssharp@eecs.berkeley.edu>
+ */
configuration PowerupAppC{}
implementation {
* 94704. Attention: Intel License Inquiry.
*/
-//@author Cory Sharp <cssharp@eecs.berkeley.edu>
-
+/**
+ * This module turns on Led0 when the system boots.
+ *
+ * @author Cory Sharp <cssharp@eecs.berkeley.edu>
+ */
module PowerupC
{
uses interface Boot;
BUILD_EXTRA_DEPS = RadioCountMsg.py RadioCountMsg.class
RadioCountMsg.py: RadioCountToLeds.h
- mig python -target=$(PLATFORM) $(CFLAGS) -python-classname=RadioCountMsg RadioCountToLeds.h RadioCountMsg -o $@
+ mig python -target=$(PLATFORM) $(CFLAGS) -python-classname=RadioCountMsg RadioCountToLeds.h radio_count_msg -o $@
RadioCountMsg.class: RadioCountMsg.java
javac RadioCountMsg.java
RadioCountMsg.java: RadioCountToLeds.h
- mig java -target=$(PLATFORM) $(CFLAGS) -java-classname=RadioCountMsg RadioCountToLeds.h RadioCountMsg -o $@
+ mig java -target=$(PLATFORM) $(CFLAGS) -java-classname=RadioCountMsg RadioCountToLeds.h radio_count_msg -o $@
include $(MAKERULES)
Description:
-RadioCountToLeds maintains a 4Hz counter and broadcsts its value. A
-RadioCountToLeds node that hears a counter displays the bottom three bits
-on its LEDs. This application is a useful test to show that basic AM
-communication and timers work.
+RadioCountToLeds maintains a 4Hz counter, broadcasting its value in
+an AM packet every time it gets updated. A RadioCountToLeds node that
+hears a counter displays the bottom three bits on its LEDs. This
+application is a useful test to show that basic AM communication and
+timers work.
Tools:
#ifndef RADIO_COUNT_TO_LEDS_H
#define RADIO_COUNT_TO_LEDS_H
-typedef nx_struct RadioCountMsg {
+typedef nx_struct radio_count_msg {
nx_uint16_t counter;
-} RadioCountMsg;
+} radio_count_msg_t;
enum {
- AM_RADIOCOUNTMSG = 6,
+ AM_RADIO_COUNT_MSG = 6,
};
#endif
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
- * Copyright (c) 2002-2005 Intel Corporation
+ * Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
+
+#include "RadioCountToLeds.h"
/**
- * This application sends OSKI broadcasts at 1Hz and blinks LED 0 when
- * it receives a broadcast.
+ * Configuration for the RadioCountToLeds application. RadioCountToLeds
+ * maintains a 4Hz counter, broadcasting its value in an AM packet
+ * every time it gets updated. A RadioCountToLeds node that hears a counter
+ * displays the bottom three bits on its LEDs. This application is a useful
+ * test to show that basic AM communication and timers work.
*
* @author Philip Levis
* @date June 6 2005
*/
-#include "RadioCountToLeds.h"
-
configuration RadioCountToLedsAppC {}
implementation {
components MainC, RadioCountToLedsC as App, LedsC;
- components new AMSenderC(AM_RADIOCOUNTMSG);
- components new AMReceiverC(AM_RADIOCOUNTMSG);
+ components new AMSenderC(AM_RADIO_COUNT_MSG);
+ components new AMReceiverC(AM_RADIO_COUNT_MSG);
components new TimerMilliC();
components ActiveMessageC;
-
-
App.Boot -> MainC.Boot;
App.Receive -> AMReceiverC;
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
-
-/**
- * Implementation of the OSKI RadioCountToLeds application. This
- * application periodically broadcasts a 16-bit counter, and displays
- * broadcasts it hears on its LEDs.
- *
- * @author Philip Levis
- * @date June 6 2005
- *
- **/
-
+
#include "Timer.h"
#include "RadioCountToLeds.h"
+
+/**
+ * Implementation of the RadioCountToLeds application. RadioCountToLeds
+ * maintains a 4Hz counter, broadcasting its value in an AM packet
+ * every time it gets updated. A RadioCountToLeds node that hears a counter
+ * displays the bottom three bits on its LEDs. This application is a useful
+ * test to show that basic AM communication and timers work.
+ *
+ * @author Philip Levis
+ * @date June 6 2005
+ */
module RadioCountToLedsC {
uses {
event void AMControl.startDone(error_t err) {
if (err == SUCCESS) {
- call MilliTimer.startPeriodic(1000);
+ call MilliTimer.startPeriodic(250);
}
else {
call AMControl.start();
return;
}
else {
- RadioCountMsg* rcm = (RadioCountMsg*)call Packet.getPayload(&packet, NULL);
- if (call Packet.maxPayloadLength() < sizeof(RadioCountMsg)) {
+ radio_count_msg_t* rcm = (radio_count_msg_t*)call Packet.getPayload(&packet, NULL);
+ if (call Packet.maxPayloadLength() < sizeof(radio_count_msg_t)) {
return;
}
rcm->counter = counter;
- if (call AMSend.send(AM_BROADCAST_ADDR, &packet, sizeof(RadioCountMsg)) == SUCCESS) {
+ if (call AMSend.send(AM_BROADCAST_ADDR, &packet, sizeof(radio_count_msg_t)) == SUCCESS) {
dbg("RadioCountToLedsC", "RadioCountToLedsC: packet sent.\n", counter);
locked = TRUE;
}
event message_t* Receive.receive(message_t* bufPtr,
void* payload, uint8_t len) {
dbg("RadioCountToLedsC", "Received packet of length %hhu.\n", len);
- if (len != sizeof(RadioCountMsg)) {return bufPtr;}
+ if (len != sizeof(radio_count_msg_t)) {return bufPtr;}
else {
- RadioCountMsg* rcm = (RadioCountMsg*)payload;
+ radio_count_msg_t* rcm = (radio_count_msg_t*)payload;
if (rcm->counter & 0x1) {
call Leds.led0On();
}
BUILD_EXTRA_DEPS = RadioSenseMsg.py RadioSenseMsg.class
RadioSenseMsg.py: RadioSenseToLeds.h
- mig python -target=$(PLATFORM) $(CFLAGS) -python-classname=RadioSenseMsg RadioSenseToLeds.h RadioSenseMsg -o $@
+ mig python -target=$(PLATFORM) $(CFLAGS) -python-classname=RadioSenseMsg RadioSenseToLeds.h radio_sense_msg -o $@
RadioSenseMsg.class: RadioSenseMsg.java
javac RadioSenseMsg.java
RadioSenseMsg.java: RadioSenseToLeds.h
- mig java -target=$(PLATFORM) $(CFLAGS) -java-classname=RadioSenseMsg RadioSenseToLeds.h RadioSenseMsg -o $@
+ mig java -target=$(PLATFORM) $(CFLAGS) -java-classname=RadioSenseMsg RadioSenseToLeds.h radio_sense_msg -o $@
include $(MAKERULES)
Description:
RadioSenseToLeds samples a platform's default sensor at 4Hz and broadcasts
-this value in an AM packet.
-A RadioSenseToLeds node that hears a counter displays the bottom three bits
-on its LEDs. This application is a useful test to show that basic AM
-communication, timers, and the default sensor work.
+this value in an AM packet. A RadioSenseToLeds node that hears a broadcast
+displays the bottom three bits of the value it has received. This application
+is a useful test to show that basic AM communication, timers, and the default
+sensor work.
Tools:
#ifndef RADIO_SENSE_TO_LEDS_H
#define RADIO_SENSE_TO_LEDS_H
-typedef nx_struct RadioSenseMsg {
+typedef nx_struct radio_sense_msg {
nx_uint16_t error;
nx_uint16_t data;
-} RadioSenseMsg;
+} radio_sense_msg_t;
enum {
- AM_RADIOSENSEMSG = 7,
+ AM_RADIO_SENSE_MSG = 7,
};
#endif
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
+
+#include "RadioSenseToLeds.h"
/**
- *
+ * Configuration for the RadioSenseToLeds application. RadioSenseToLeds samples
+ * a platform's default sensor at 4Hz and broadcasts this value in an AM packet.
+ * A RadioSenseToLeds node that hears a broadcast displays the bottom three bits
+ * of the value it has received. This application is a useful test to show that
+ * basic AM communication, timers, and the default sensor work.
+ *
* @author Philip Levis
* @date June 6 2005
*/
-#include "RadioSenseToLeds.h"
-
configuration RadioSenseToLedsAppC {}
implementation {
components MainC, RadioSenseToLedsC as App, LedsC, new DemoSensorC();
components ActiveMessageC;
- components new AMSenderC(AM_RADIOSENSEMSG);
- components new AMReceiverC(AM_RADIOSENSEMSG);
+ components new AMSenderC(AM_RADIO_SENSE_MSG);
+ components new AMReceiverC(AM_RADIO_SENSE_MSG);
components new TimerMilliC();
-
-
App.Boot -> MainC.Boot;
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
-
-/**
- * Implementation of the OSKI RadioSenseToLeds application. This
- * application periodically broadcasts a reading from its platform's
- * demo sensor, and displays broadcasts it hears on its LEDs. It displays
- * the two most signficant bits of the value on LEDs 1 and 2; if there is
- * an error, it lights LED 0.
- *
- * @author Philip Levis
- * @date June 12 2005
- *
- **/
-
+
#include "Timer.h"
#include "RadioSenseToLeds.h"
+/**
+ * Implementation of the RadioSenseToLeds application. RadioSenseToLeds samples
+ * a platform's default sensor at 4Hz and broadcasts this value in an AM packet.
+ * A RadioSenseToLeds node that hears a broadcast displays the bottom three bits
+ * of the value it has received. This application is a useful test to show that
+ * basic AM communication, timers, and the default sensor work.
+ *
+ * @author Philip Levis
+ * @date June 6 2005
+ */
+
module RadioSenseToLedsC {
uses {
interface Leds;
event void RadioControl.startDone(error_t err) {
if (err == SUCCESS) {
- call MilliTimer.startPeriodic(1000);
+ call MilliTimer.startPeriodic(250);
}
}
event void RadioControl.stopDone(error_t err) {}
return;
}
else {
- RadioSenseMsg* rsm;
+ radio_sense_msg_t* rsm;
- rsm = (RadioSenseMsg*)call Packet.getPayload(&packet, NULL);
- if (call Packet.maxPayloadLength() < sizeof(RadioSenseMsg)) {
+ rsm = (radio_sense_msg_t*)call Packet.getPayload(&packet, NULL);
+ if (call Packet.maxPayloadLength() < sizeof(radio_sense_msg_t)) {
return;
}
rsm->error = result;
rsm->data = data;
- if (call AMSend.send(AM_BROADCAST_ADDR, &packet, sizeof(RadioSenseMsg)) == SUCCESS) {
+ if (call AMSend.send(AM_BROADCAST_ADDR, &packet, sizeof(radio_sense_msg_t)) == SUCCESS) {
locked = TRUE;
}
}
event message_t* Receive.receive(message_t* bufPtr,
void* payload, uint8_t len) {
call Leds.led1Toggle();
- if (len != sizeof(RadioSenseMsg)) {return bufPtr;}
+ if (len != sizeof(radio_sense_msg_t)) {return bufPtr;}
else {
- RadioSenseMsg* rsm = (RadioSenseMsg*)payload;
+ radio_sense_msg_t* rsm = (radio_sense_msg_t*)payload;
uint16_t val = rsm->data;
call Leds.led0Toggle();
if (val & 0x8000) {
}
implementation
{
- // sampling frequency in milliseconds
+ // sampling frequency in binary milliseconds
#define SAMPLING_FREQUENCY 100
event void Boot.booted() {
event void Read.readDone(error_t result, uint16_t data)
{
if (result == SUCCESS){
- if (data & 0x8000)
+ if (data & 0x0004)
call Leds.led2On();
else
call Leds.led2Off();
- if (data & 0x4000)
+ if (data & 0x0002)
call Leds.led1On();
else
call Leds.led1Off();
- if (data & 0x2000)
+ if (data & 0x0001)
call Leds.led0On();
else
call Leds.led0Off();
COMPONENT=RadioStressAppC
-PFLAGS += -I%T/lib/oski
#PFLAGS += -g
include $(MAKERULES)
+#ifndef RADIO_COUNT_MSG_H
+#define RADIO_COUNT_MSG_H
+
typedef nx_struct RadioCountMsg {
nx_uint16_t counter;
} RadioCountMsg;
enum {
AM_RADIOCOUNTMSG = 6,
};
+
+#endif
COMPONENT=TestAMAppC
-PFLAGS += -I%T/lib/oski
include $(MAKERULES)
*/
/**
- * This application sends active message broadcasts at 1Hz and blinks
- * LED 0 when it receives a broadcast. It uses the radio HIL component
- * <tt>ActiveMessageC</tt>, and its packets are AM type 240.
+ * Configuration for the TestAM application. TestAM sends active message
+ * broadcasts at 1Hz and blinks LED 0 whenever it has sucessfully sent a
+ * broadcast. Whenever it receives one of these broadcasts from another
+ * node, it blinks LED 1. It uses the radio HIL component <tt>ActiveMessageC</tt>,
+ * and its packets are AM type 240. This application is useful for testing
+ * AM communication and the ActiveMessageC component.
*
* @author Philip Levis
* @date May 16 2005
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
+
+#include "Timer.h"
/**
- * Implementation of the TestAM application.
- *
- * @author Philip Levis
- * @date May 16 2005
+ * Implementation of the TestAM application. TestAM sends active message
+ * broadcasts at 1Hz and blinks LED 0 whenever it has sucessfully sent a
+ * broadcast. Whenever it receives one of these broadcasts from another
+ * node, it blinks LED 1. It uses the radio HIL component <tt>ActiveMessageC</tt>,
+ * and its packets are AM type 240. This application is useful for testing
+ * AM communication and the ActiveMessageC component.
*
- **/
-
-#include "Timer.h"
+ * @author Philip Levis
+ * @date May 16 2005
+ */
module TestAMC {
uses {
COMPONENT=TestAMServiceAppC
-PFLAGS += -I%T/lib/oski
include $(MAKERULES)
COMPONENT=TestAdcAppC
-CFLAGS += -I%T/oski
include $(MAKERULES)
-COMPONENT=TestArbiterAppC
-CFLAGS += -I%T/lib/oski
+COMPONENT=TestFcfsArbiterAppC
OPTFLAGS = -O0
include $(MAKERULES)
-- Resource 0
-- Resource 2
-- Resource 1
-It is expected then that using a round robin policy, control of the
+It is expected then that using a first-come-first-serve policy, control of the
resource will be granted in the order of 0,2,1 and the Leds
corresponding to each resource will flash whenever this occurs.
-- Led 0 -> Resource 0
-COMPONENT=TestArbiterAppC
-CFLAGS += -I%T/lib/oski
+COMPONENT=TestRoundRobinArbiterAppC
OPTFLAGS = -O0
include $(MAKERULES)
COMPONENT=TestBroadcastAppC
-PFLAGS += -I%T/lib/oski
include $(MAKERULES)
set_rate_msg.h
test_network_msg.c
test_network_msg.h
-tn-injector
COMPONENT=TestNetworkAppC
-CFLAGS += -I$(TOSDIR)/lib/net -I$(TOSDIR)/lib/net/collection
-TFLAGS += -I$(TOSDIR)/../apps/tests/TestDissemination \
+CFLAGS += -I$(TOSDIR)/lib/net \
+ -I$(TOSDIR)/lib/net/le \
+ -I$(TOSDIR)/lib/net/ctp #-DNO_DEBUG
+
+TFLAGS += -I$(TOSDIR)/../apps/tests/TestDissemination \
-I$(TOSDIR)/../support/sdk/c \
- -I$(TOSDIR)/types \
+ -I$(TOSDIR)/types \
-I.
LIBMOTE = $(TOSDIR)/../support/sdk/c/libmote.a
* and sends packets up a collection tree. The rate is configurable
* through dissemination.
*
- * See TEP118: Dissemination and TEP 119: Collection for details.
+ * See TEP118: Dissemination, TEP 119: Collection, and TEP 123: The
+ * Collection Tree Protocol for details.
*
* @author Philip Levis
* @version $Revision$ $Date$
*/
#include "TestNetwork.h"
-#include "Collection.h"
+#include "Ctp.h"
configuration TestNetworkAppC {}
implementation {
components TestNetworkC, MainC, LedsC, ActiveMessageC;
components new DisseminatorC(uint16_t, SAMPLE_RATE_KEY) as Object16C;
+ components CollectionC as Collector;
components new CollectionSenderC(CL_TEST);
- components TreeCollectionC as Collector;
components new TimerMilliC();
components new DemoSensorC();
components new SerialAMSenderC(CL_TEST);
components SerialActiveMessageC;
+#ifndef NO_DEBUG
components new SerialAMSenderC(AM_COLLECTION_DEBUG) as UARTSender;
components UARTDebugSenderP as DebugSender;
+#endif
components RandomC;
+ components new QueueC(message_t*, 12);
+ components new PoolC(message_t, 12);
TestNetworkC.Boot -> MainC;
TestNetworkC.RadioControl -> ActiveMessageC;
TestNetworkC.Receive -> Collector.Receive[CL_TEST];
TestNetworkC.UARTSend -> SerialAMSenderC.AMSend;
TestNetworkC.CollectionPacket -> Collector;
- TestNetworkC.TreeRoutingInspect -> Collector;
+ TestNetworkC.CtpInfo -> Collector;
+ TestNetworkC.CtpCongestion -> Collector;
TestNetworkC.Random -> RandomC;
+ TestNetworkC.Pool -> PoolC;
+ TestNetworkC.Queue -> QueueC;
+#ifndef NO_DEBUG
components new PoolC(message_t, 10) as DebugMessagePool;
components new QueueC(message_t*, 10) as DebugSendQueue;
DebugSender.Boot -> MainC;
DebugSender.MessagePool -> DebugMessagePool;
DebugSender.SendQueue -> DebugSendQueue;
Collector.CollectionDebug -> DebugSender;
+ TestNetworkC.CollectionDebug -> DebugSender;
+#endif
+ TestNetworkC.AMPacket -> ActiveMessageC;
}
AM_TESTNETWORKMSG = 0x05,
SAMPLE_RATE_KEY = 0x1,
CL_TEST = 0xee,
+ TEST_NETWORK_QUEUE_SIZE = 8,
};
#endif
#include <Timer.h>
#include "TestNetwork.h"
+#include "CtpDebugMsg.h"
module TestNetworkC {
uses interface Boot;
uses interface Receive;
uses interface AMSend as UARTSend;
uses interface CollectionPacket;
- uses interface TreeRoutingInspect;
+ uses interface CtpInfo;
+ uses interface CtpCongestion;
uses interface Random;
+ uses interface Queue<message_t*>;
+ uses interface Pool<message_t>;
+ uses interface CollectionDebug;
+ uses interface AMPacket;
}
implementation {
task void uartEchoTask();
message_t uartpacket;
message_t* recvPtr = &uartpacket;
uint8_t msglen;
- bool busy = FALSE, uartbusy = FALSE;
+ bool sendBusy = FALSE;
+ bool uartbusy = FALSE;
bool firstTimer = TRUE;
uint16_t seqno;
-
+ enum {
+ SEND_INTERVAL = 8192
+ };
+
+ event void ReadSensor.readDone(error_t err, uint16_t val) { }
+
event void Boot.booted() {
call SerialControl.start();
}
call RootControl.setRoot();
}
seqno = 0;
- call Timer.startOneShot(call Random.rand16() & 0x1ff);
+ call Timer.startOneShot(call Random.rand16() & 0x1ff);
}
}
event void RadioControl.stopDone(error_t err) {}
event void SerialControl.stopDone(error_t err) {}
-
- event void Timer.fired() {
- call Leds.led0Toggle();
- dbg("TestNetworkC", "TestNetworkC: Timer fired.\n");
- if (firstTimer) {
- firstTimer = FALSE;
- call Timer.startPeriodic(1024);
- }
- if (busy || call ReadSensor.read() != SUCCESS) {
- signal ReadSensor.readDone(SUCCESS, 0);
- return;
- }
- busy = TRUE;
- }
void failedSend() {
dbg("App", "%s: Send failed.\n", __FUNCTION__);
+ call CollectionDebug.logEvent(NET_C_DBG_1);
}
-
- event void ReadSensor.readDone(error_t err, uint16_t val) {
+
+
+ void sendMessage() {
TestNetworkMsg* msg = (TestNetworkMsg*)call Send.getPayload(&packet);
- uint8_t hopcount;
uint16_t metric;
am_addr_t parent;
- call TreeRoutingInspect.getParent(&parent);
- call TreeRoutingInspect.getHopcount(&hopcount);
- call TreeRoutingInspect.getMetric(&metric);
+ call CtpInfo.getParent(&parent);
+ call CtpInfo.getEtx(&metric);
msg->source = TOS_NODE_ID;
msg->seqno = seqno;
- msg->data = val;
+ msg->data = 0xCAFE;
msg->parent = parent;
- msg->hopcount = hopcount;
+ msg->hopcount = 0;
msg->metric = metric;
- if (err != SUCCESS) {
- dbg("App", "%s: read done failed.\n", __FUNCTION__);
- busy = FALSE;
- }
if (call Send.send(&packet, sizeof(TestNetworkMsg)) != SUCCESS) {
failedSend();
call Leds.led0On();
dbg("TestNetworkC", "%s: Transmission failed.\n", __FUNCTION__);
}
else {
+ sendBusy = TRUE;
seqno++;
dbg("TestNetworkC", "%s: Transmission succeeded.\n", __FUNCTION__);
-
}
}
+
+ event void Timer.fired() {
+ uint16_t nextInt;
+ call Leds.led0Toggle();
+ dbg("TestNetworkC", "TestNetworkC: Timer fired.\n");
+ nextInt = call Random.rand16() % SEND_INTERVAL;
+ nextInt += SEND_INTERVAL >> 1;
+ call Timer.startOneShot(nextInt);
+ if (!sendBusy)
+ sendMessage();
+ }
+
event void Send.sendDone(message_t* m, error_t err) {
if (err != SUCCESS) {
// call Leds.led0On();
}
- else {
- busy = FALSE;
- }
+ sendBusy = FALSE;
dbg("TestNetworkC", "Send completed.\n");
}
Receive.receive(message_t* msg, void* payload, uint8_t len) {
dbg("TestNetworkC", "Received packet at %s from node %hhu.\n", sim_time_string(), call CollectionPacket.getOrigin(msg));
call Leds.led1Toggle();
- if (!uartbusy) {
- message_t* tmp = recvPtr;
- recvPtr = msg;
- uartbusy = TRUE;
- msglen = len + 4;
- post uartEchoTask();
- call Leds.led2Toggle();
+ if (!call Pool.size() <= (TEST_NETWORK_QUEUE_SIZE < 4)? 1:3) {
+ call CtpCongestion.setClientCongested(TRUE);
+ }
+ if (!call Pool.empty() && call Queue.size() < call Queue.maxSize()) {
+ message_t* tmp = call Pool.get();
+ call Queue.enqueue(msg);
+ if (!uartbusy) {
+ post uartEchoTask();
+ }
return tmp;
}
return msg;
- }
+ }
- task void uartEchoTask() {
+ task void uartEchoTask() {
dbg("Traffic", "Sending packet to UART.\n");
- if (call UARTSend.send(0xffff, recvPtr, msglen) != SUCCESS) {
- uartbusy = FALSE;
- }
- }
+ if (call Queue.empty()) {
+ return;
+ }
+ else if (!uartbusy) {
+ message_t* msg = call Queue.dequeue();
+ dbg("Traffic", "Sending packet to UART.\n");
+ if (call UARTSend.send(0xffff, recvPtr, call Receive.payloadLength(msg) + 4) == SUCCESS) {
+ uartbusy = TRUE;
+ }
+ else {
+ call CollectionDebug.logEventMsg(NET_C_DBG_2,
+ call CollectionPacket.getSequenceNumber(recvPtr),
+ call CollectionPacket.getOrigin(recvPtr),
+ call AMPacket.destination(recvPtr));
+ }
+ }
+ }
event void UARTSend.sendDone(message_t *msg, error_t error) {
dbg("Traffic", "UART send done.\n");
uartbusy = FALSE;
+ call Pool.put(msg);
+ if (!call Queue.empty()) {
+ post uartEchoTask();
+ }
+ else {
+ call CtpCongestion.setClientCongested(FALSE);
+ }
}
+
+ /* Default implementations for CollectionDebug calls.
+ * These allow CollectionDebug not to be wired to anything if debugging
+ * is not desired. */
+
+ default command error_t CollectionDebug.logEvent(uint8_t type) {
+ return SUCCESS;
+ }
+ default command error_t CollectionDebug.logEventSimple(uint8_t type, uint16_t arg) {
+ return SUCCESS;
+ }
+ default command error_t CollectionDebug.logEventDbg(uint8_t type, uint16_t arg1, uint16_t arg2, uint16_t arg3) {
+ return SUCCESS;
+ }
+ default command error_t CollectionDebug.logEventMsg(uint8_t type, uint16_t msg, am_addr_t origin, am_addr_t node) {
+ return SUCCESS;
+ }
+ default command error_t CollectionDebug.logEventRoute(uint8_t type, am_addr_t parent, uint8_t hopcount, uint16_t metric) {
+ return SUCCESS;
+ }
+
}
COMPONENT=TestPowerManagerAppC
OPTFLAGS = -O0
-PFLAGS += -I%T/lib/oski -I%T/lib/power
include $(MAKERULES)
#define MYCOMPONENT_RESOURCE "MyComponent.Resource"
configuration MyComponentC{
provides {
- interface Init;
interface Resource[uint8_t];
}
}
new TimerMilliC() as StartTimer, new TimerMilliC() as StopTimer,
new FcfsArbiterC(MYCOMPONENT_RESOURCE) as Arbiter,
// new AsyncStdControlPowerManagerC() as PowerManager;
-// new AsyncStdControlDeferredPowerManagerC(750) as PowerManager;
+ new AsyncStdControlDeferredPowerManagerC(750) as PowerManager;
// new StdControlPowerManagerC() as PowerManager;
// new StdControlDeferredPowerManagerC(750) as PowerManager;
// new SplitControlPowerManagerC() as PowerManager;
- new SplitControlDeferredPowerManagerC(750) as PowerManager;
+// new SplitControlDeferredPowerManagerC(750) as PowerManager;
- Init = Arbiter;
- Init = PowerManager;
- Init = LedsC;
Resource = Arbiter;
-// PowerManager.AsyncStdControl -> MyComponentP.AsyncStdControl;
+ PowerManager.AsyncStdControl -> MyComponentP.AsyncStdControl;
// PowerManager.StdControl -> MyComponentP.StdControl;
- PowerManager.SplitControl -> MyComponentP.SplitControl;
- PowerManager.ArbiterInit -> Arbiter.Init;
+// PowerManager.SplitControl -> MyComponentP.SplitControl;
PowerManager.ResourceController -> Arbiter.ResourceController;
PowerManager.ArbiterInfo -> Arbiter.ArbiterInfo;
TestPowerManagerC -> MainC.Boot;
- MainC.SoftwareInit -> MyComponentC;
-
TestPowerManagerC.TimerMilli -> TimerMilliC;
TestPowerManagerC.Resource0 -> MyComponentC.Resource[unique("MyComponent.Resource")];
TestPowerManagerC.Resource1 -> MyComponentC.Resource[unique("MyComponent.Resource")];
event void TimerMilli.fired() {
if(waiting == TRUE) {
waiting = FALSE;
- if(whoHasIt == 0)
- call Resource1.request();
+ if(whoHasIt == 0) {
+ if(call Resource1.immediateRequest() == SUCCESS) {
+ whoHasIt = 1;
+ call Leds.led2On();
+ call TimerMilli.startOneShot(HOLD_PERIOD);
+ return;
+ }
+ else call Resource1.request();
+ }
if(whoHasIt == 1)
call Resource0.request();
}
-COMPONENT=TestSerialC
-CFLAGS += -I%T/lib/oski
+COMPONENT=TestSerialAppC
BUILD_EXTRA_DEPS += TestSerial.class
CLEAN_EXTRA = *.class TestSerialMsg.java
javac *.java
TestSerialMsg.java:
- mig java -target=null $(CFLAGS) -java-classname=TestSerialMsg TestSerial.h TestSerialMsg -o $@
+ mig java -target=null $(CFLAGS) -java-classname=TestSerialMsg TestSerial.h test_serial_msg -o $@
include $(MAKERULES)
#ifndef TEST_SERIAL_H
#define TEST_SERIAL_H
-typedef nx_struct TestSerialMsg {
+typedef nx_struct test_serial_msg {
nx_uint16_t counter;
-} TestSerialMsg;
+} test_serial_msg_t;
enum {
- AM_TESTSERIALMSG = 9,
+ AM_TEST_SERIAL_MSG = 9,
};
#endif
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
- * Copyright (c) 2002-2005 Intel Corporation
+ * Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
/**
* Application to test that the TinyOS java toolchain can communicate
- * with motes over the serial port. The application sends packets to
- * the serial port at 1Hz: the packet contains an incrementing
- * counter. When the application receives a counter packet, it
- * displays the bottom three bits on its LEDs. This application is
- * very similar to RadioCountToLeds, except that it operates over the
- * serial port. There is Java application for testing the mote
- * application: run TestSerial to print out the received packets and
- * send packets to the mote.
+ * with motes over the serial port.
*
* @author Gilman Tolle
* @author Philip Levis
*
**/
+#include "Timer.h"
#include "TestSerial.h"
-configuration TestSerialC {}
+module TestSerialC {
+ uses {
+ interface SplitControl as Control;
+ interface Leds;
+ interface Boot;
+ interface Receive;
+ interface AMSend;
+ interface Timer<TMilli> as MilliTimer;
+ interface Packet;
+ }
+}
implementation {
- components TestSerialP, LedsC, MainC;
- components SerialActiveMessageC as AM;
- components new TimerMilliC();
- TestSerialP.Boot -> MainC.Boot;
- TestSerialP.Control -> AM;
- TestSerialP.Receive -> AM.Receive[AM_TESTSERIALMSG];
- TestSerialP.AMSend -> AM.AMSend[AM_TESTSERIALMSG];
- TestSerialP.Leds -> LedsC;
- TestSerialP.MilliTimer -> TimerMilliC;
- TestSerialP.Packet -> AM;
+ message_t packet;
+
+ bool locked = FALSE;
+ uint16_t counter = 0;
+
+ event void Boot.booted() {
+ call Control.start();
+ }
+
+ event void MilliTimer.fired() {
+ counter++;
+ if (locked) {
+ return;
+ }
+ else {
+ test_serial_msg_t* rcm = (test_serial_msg_t*)call Packet.getPayload(&packet, NULL);
+ if (call Packet.maxPayloadLength() < sizeof(test_serial_msg_t)) {
+ return;
+ }
+
+ rcm->counter = counter;
+ if (call AMSend.send(AM_BROADCAST_ADDR, &packet, sizeof(test_serial_msg_t)) == SUCCESS) {
+ locked = TRUE;
+ }
+ }
+ }
+
+ event message_t* Receive.receive(message_t* bufPtr,
+ void* payload, uint8_t len) {
+ if (len != sizeof(test_serial_msg_t)) {return bufPtr;}
+ else {
+ test_serial_msg_t* rcm = (test_serial_msg_t*)payload;
+ if (rcm->counter & 0x1) {
+ call Leds.led0On();
+ }
+ else {
+ call Leds.led0Off();
+ }
+ if (rcm->counter & 0x2) {
+ call Leds.led1On();
+ }
+ else {
+ call Leds.led1Off();
+ }
+ if (rcm->counter & 0x4) {
+ call Leds.led2On();
+ }
+ else {
+ call Leds.led2Off();
+ }
+ return bufPtr;
+ }
+ }
+
+ event void AMSend.sendDone(message_t* bufPtr, error_t error) {
+ if (&packet == bufPtr) {
+ locked = FALSE;
+ }
+ }
+
+ event void Control.startDone(error_t err) {
+ if (err == SUCCESS) {
+ call MilliTimer.startPeriodic(1000);
+ }
+ }
+ event void Control.stopDone(error_t err) {}
}
+
+
COMPONENT=TestSerialAppC
-CFLAGS += -I%T/lib/oski
BUILD_EXTRA_DEPS += TestSerialMsg.class TestSerial.class
CFLAGS += -DTOSH_DATA_LENGTH=100
+#ifndef TEST_SERIAL_H
+#define TEST_SERIAL_H
typedef nx_struct TestSerialMsg {
nx_uint16_t counter;
nx_uint8_t x[TOSH_DATA_LENGTH-sizeof(nx_uint16_t)];
enum {
AM_TESTSERIALMSG = 9,
};
+#endif
components SerialActiveMessageC as AM;
components new TimerMilliC();
-
-
- MainC.SoftwareInit -> AM;
-
App.Boot -> MainC.Boot;
App.Control -> AM;
App.Receive -> AM.Receive[AM_TESTSERIALMSG];
--- /dev/null
+COMPONENT=TestSleepC
+include $(MAKERULES)
+
--- /dev/null
+/// $Id$
+
+/**
+ * "Copyright (c) 2005 Crossbow Technology, Inc.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and
+ * its documentation for any purpose, without fee, and without written
+ * agreement is hereby granted, provided that the above copyright
+ * notice, the following two paragraphs and the author appear in all
+ * copies of this software.
+ *
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE TO ANY
+ * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE COPYRIGHT HOLDERS AND CONTRIBUTORS HAVE BEEN ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE COPYRIGHT HOLDERS AND CONTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
+ * "AS IS" BASIS, AND THE COPYRIGHT HOLDERS AND CONTRIBUTORS HAVE NO OBLIGATION
+ * TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ */
+
+/// @author Martin Turon <mturon@xbow.com>
+
+/**
+ * TestSleep simple puts the processor into sleep mode and stays there.
+ * The instananeous and average current should be ~20 uA on the ATmega128.
+ */
+configuration TestSleepC
+{
+}
+implementation
+{
+ components MainC, TestSleepM,
+ HplSleepC; // Low-level control just for test purposes
+
+ TestSleepM -> MainC.Boot;
+
+ TestSleepM.PowerManager -> HplSleepC;
+}
+
--- /dev/null
+/// $Id$
+
+/**
+ * "Copyright (c) 2005 Crossbow Technology, Inc.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and
+ * its documentation for any purpose, without fee, and without written
+ * agreement is hereby granted, provided that the above copyright
+ * notice, the following two paragraphs and the author appear in all
+ * copies of this software.
+ *
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE TO ANY
+ * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE COPYRIGHT HOLDERS AND CONTRIBUTORS HAVE BEEN ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE COPYRIGHT HOLDERS AND CONTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
+ * "AS IS" BASIS, AND THE COPYRIGHT HOLDERS AND CONTRIBUTORS HAVE NO OBLIGATION
+ * TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ */
+
+/// @author Martin Turon <mturon@xbow.com>
+
+module TestSleepM
+{
+ uses interface Boot;
+
+ uses interface McuSleep as PowerManager;
+}
+implementation
+{
+ event void Boot.booted()
+ {
+ call PowerManager.enable();
+ }
+}
+
COMPONENT=TestTimerSyncAppC
-PFLAGS += -I%T/lib/oski
include $(MAKERULES)
COMPONENT=TestTrickleTimerAppC
-CFLAGS += -I%T/lib/oski -I%T/lib/net -I.
+CFLAGS += -I%T/lib/net -I.
include $(MAKERULES)
--- /dev/null
+COMPONENT=TestTDA5250ControlC
+include $(MAKERULES)
+
--- /dev/null
+COMPONENT=TestPacketSerializerC
+include $(MAKERULES)
+
--- /dev/null
+/* tab:4
+ * "Copyright (c) 2000-2003 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ *
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ *
+ * Copyright (c) 2002-2003 Intel Corporation
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached INTEL-LICENSE
+ * file. If you do not find these files, copies can be found by writing to
+ * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
+ * 94704. Attention: Intel License Inquiry.
+ */
+/**
+ *
+ **/
+
+#include <Timer.h>
+#include <message.h>
+
+configuration TestPacketSerializerC {
+}
+implementation {
+ components MainC, TestPacketSerializerP
+ , new AlarmMilliC() as TxTimer
+ , new AlarmMilliC() as RxTimer
+ , new AlarmMilliC() as CCATimer
+// , new AlarmMilliC() as TimerTimer
+ , new AlarmMilliC() as SelfPollingTimer
+// , new AlarmMilliC() as SleepTimer
+ , LedsC
+ , TDA5250RadioC
+ , RandomLfsrC
+ , UARTPhyP
+ , PacketSerializerP
+ ;
+
+ MainC.SoftwareInit -> TDA5250RadioC.Init;
+ MainC.SoftwareInit -> RandomLfsrC.Init;
+ MainC.SoftwareInit -> LedsC.Init;
+ MainC.SoftwareInit -> UARTPhyP.Init;
+ MainC.SoftwareInit -> PacketSerializerP.Init;
+ TestPacketSerializerP -> MainC.Boot;
+
+ TestPacketSerializerP.Random -> RandomLfsrC.Random;
+ TestPacketSerializerP.TxTimer -> TxTimer;
+ TestPacketSerializerP.RxTimer -> RxTimer;
+ TestPacketSerializerP.CCATimer -> CCATimer;
+// TestPacketSerializerP.TimerTimer -> TimerTimer;
+ TestPacketSerializerP.SelfPollingTimer -> SelfPollingTimer;
+// TestPacketSerializerP.SleepTimer -> SleepTimer;
+ TestPacketSerializerP.Leds -> LedsC;
+ TestPacketSerializerP.TDA5250Control -> TDA5250RadioC.TDA5250Control;
+ TestPacketSerializerP.RadioSplitControl -> TDA5250RadioC.SplitControl;
+ TestPacketSerializerP.Send -> PacketSerializerP.Send;
+ TestPacketSerializerP.Receive -> PacketSerializerP.Receive;
+
+ UARTPhyP.RadioByteComm -> TDA5250RadioC.RadioByteComm;
+
+ PacketSerializerP.RadioByteComm -> UARTPhyP.SerializerRadioByteComm;
+ PacketSerializerP.PhyPacketTx -> UARTPhyP.PhyPacketTx;
+ PacketSerializerP.PhyPacketRx -> UARTPhyP.PhyPacketRx;
+}
+
+
+
--- /dev/null
+COMPONENT=TestUARTPhyC
+include $(MAKERULES)
+
--- /dev/null
+/* tab:4
+ * "Copyright (c) 2000-2003 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ *
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ *
+ * Copyright (c) 2002-2003 Intel Corporation
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached INTEL-LICENSE
+ * file. If you do not find these files, copies can be found by writing to
+ * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
+ * 94704. Attention: Intel License Inquiry.
+ */
+/**
+ *
+ **/
+
+#include "Timer.h"
+configuration TestUARTPhyC {
+}
+implementation {
+ components MainC, TestUARTPhyP
+ , new AlarmMilliC() as TxTimer
+ , LedsC
+ , TDA5250RadioC
+ , RandomLfsrC
+ , UARTPhyP
+ ;
+
+ MainC.SoftwareInit -> TDA5250RadioC.Init;
+ MainC.SoftwareInit -> RandomLfsrC.Init;
+ MainC.SoftwareInit -> LedsC.Init;
+ MainC.SoftwareInit -> UARTPhyP.Init;
+ TestUARTPhyP -> MainC.Boot;
+
+ TestUARTPhyP.Random -> RandomLfsrC.Random;
+ TestUARTPhyP.TxTimer -> TxTimer;
+ TestUARTPhyP.Leds -> LedsC;
+ TestUARTPhyP.TDA5250Control -> TDA5250RadioC.TDA5250Control;
+ TestUARTPhyP.RadioSplitControl -> TDA5250RadioC.SplitControl;
+ TestUARTPhyP.RadioByteComm -> UARTPhyP.SerializerRadioByteComm;
+ TestUARTPhyP.PhyPacketTx -> UARTPhyP.PhyPacketTx;
+ TestUARTPhyP.PhyPacketRx -> UARTPhyP.PhyPacketRx;
+
+ UARTPhyP.RadioByteComm -> TDA5250RadioC.RadioByteComm;
+}
+
+
+
--- /dev/null
+COMPONENT=TestUARTPhyC
+include $(MAKERULES)
+
--- /dev/null
+/* tab:4
+ * "Copyright (c) 2000-2003 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ *
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ *
+ * Copyright (c) 2002-2003 Intel Corporation
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached INTEL-LICENSE
+ * file. If you do not find these files, copies can be found by writing to
+ * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
+ * 94704. Attention: Intel License Inquiry.
+ */
+/**
+ *
+ **/
+
+#include "Timer.h"
+configuration TestUARTPhyC {
+}
+implementation {
+ components MainC, TestUARTPhyP
+ , new AlarmMilliC() as TxTimer
+ , new AlarmMilliC() as RxTimer
+ , new AlarmMilliC() as CCATimer
+ , new AlarmMilliC() as TimerTimer
+// , new AlarmMilliC() as SelfPollingTimer
+// , new AlarmMilliC() as SleepTimer
+ , LedsC
+ , TDA5250RadioC
+ , RandomLfsrC
+ , UARTPhyP
+ ;
+
+ MainC.SoftwareInit -> TDA5250RadioC.Init;
+ MainC.SoftwareInit -> RandomLfsrC.Init;
+ MainC.SoftwareInit -> LedsC.Init;
+ MainC.SoftwareInit -> UARTPhyP.Init;
+ TestUARTPhyP -> MainC.Boot;
+
+ TestUARTPhyP.Random -> RandomLfsrC.Random;
+ TestUARTPhyP.TxTimer -> TxTimer;
+ TestUARTPhyP.RxTimer -> RxTimer;
+ TestUARTPhyP.CCATimer -> CCATimer;
+ TestUARTPhyP.TimerTimer -> TimerTimer;
+// TestUARTPhyP.SelfPollingTimer -> SelfPollingTimer;
+// TestUARTPhyP.SleepTimer -> SleepTimer;
+ TestUARTPhyP.Leds -> LedsC;
+ TestUARTPhyP.TDA5250Control -> TDA5250RadioC.TDA5250Control;
+ TestUARTPhyP.RadioSplitControl -> TDA5250RadioC.SplitControl;
+ TestUARTPhyP.RadioByteComm -> UARTPhyP.SerializerRadioByteComm;
+ TestUARTPhyP.PhyPacketTx -> UARTPhyP.PhyPacketTx;
+ TestUARTPhyP.PhyPacketRx -> UARTPhyP.PhyPacketRx;
+
+ UARTPhyP.RadioByteComm -> TDA5250RadioC.RadioByteComm;
+}
+
+
+
--- /dev/null
+COMPONENT=TestTimerC
+include $(MAKERULES)
+
--- /dev/null
+/* tab:4
+ * "Copyright (c) 2000-2003 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ *
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ *
+ * Copyright (c) 2002-2003 Intel Corporation
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached INTEL-LICENSE
+ * file. If you do not find these files, copies can be found by writing to
+ * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
+ * 94704. Attention: Intel License Inquiry.
+ */
+/**
+ *
+ **/
+
+#include "Timer.h"
+configuration TestTimerC {
+}
+implementation {
+ components Main, TestTimerM
+ , new AlarmMilliC() as Timer0
+ , new AlarmMilliC() as Timer1
+ , new AlarmMilliC() as Timer2
+ , new AlarmMilliC() as Timer3
+ , new AlarmMilliC() as Timer4
+ , new AlarmMilliC() as Timer5
+ , new AlarmMilliC() as Timer6
+ , new AlarmMilliC() as Timer7
+ , new AlarmMilliC() as Timer8
+ ;
+
+ TestTimerM -> Main.Boot;
+
+ TestTimerM.Timer0 -> Timer0;
+ TestTimerM.Timer1 -> Timer1;
+ TestTimerM.Timer2 -> Timer2;
+ TestTimerM.Timer3 -> Timer3;
+ TestTimerM.Timer4 -> Timer4;
+ TestTimerM.Timer5 -> Timer5;
+ TestTimerM.Timer6 -> Timer6;
+ TestTimerM.Timer7 -> Timer7;
+ TestTimerM.Timer8 -> Timer8;
+}
+
+
+
--- /dev/null
+// $Id$
+
+/* tab:4
+ * "Copyright (c) 2000-2003 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ *
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ *
+ * Copyright (c) 2002-2003 Intel Corporation
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached INTEL-LICENSE
+ * file. If you do not find these files, copies can be found by writing to
+ * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
+ * 94704. Attention: Intel License Inquiry.
+ */
+
+module TestTimerM {
+ uses {
+ interface Boot;
+ interface Alarm<TMilli, uint32_t> as Timer0;
+ interface Alarm<TMilli, uint32_t> as Timer1;
+ interface Alarm<TMilli, uint32_t> as Timer2;
+ interface Alarm<TMilli, uint32_t> as Timer3;
+ interface Alarm<TMilli, uint32_t> as Timer4;
+ interface Alarm<TMilli, uint32_t> as Timer5;
+ interface Alarm<TMilli, uint32_t> as Timer6;
+ interface Alarm<TMilli, uint32_t> as Timer7;
+ interface Alarm<TMilli, uint32_t> as Timer8;
+ }
+}
+
+implementation {
+
+ #define DELAY 20
+
+ event void Boot.booted() {
+ call Timer0.start(DELAY);
+ }
+
+ /***********************************************************************
+ * Commands and events
+ ***********************************************************************/
+
+ async event void Timer0.fired() {
+ call Timer1.start(DELAY);
+ }
+ async event void Timer1.fired() {
+ call Timer2.start(DELAY);
+ }
+ async event void Timer2.fired() {
+ call Timer3.start(DELAY);
+ }
+ async event void Timer3.fired() {
+ call Timer4.start(DELAY);
+ }
+ async event void Timer4.fired() {
+ call Timer5.start(DELAY);
+ }
+ async event void Timer5.fired() {
+ call Timer6.start(DELAY);
+ }
+ async event void Timer6.fired() {
+ call Timer7.start(DELAY);
+ }
+ async event void Timer7.fired() {
+ call Timer8.start(DELAY);
+ }
+ async event void Timer8.fired() {
+ call Timer0.start(DELAY);
+ }
+
+}
+
+
--- /dev/null
+COMPONENT=TestADCC\r
+include $(MAKERULES)\r
+\r
--- /dev/null
+// $Id$\r
+\r
+/* tab:4\r
+ * "Copyright (c) 2000-2005 The Regents of the University of California. \r
+ * All rights reserved.\r
+ *\r
+ * Permission to use, copy, modify, and distribute this software and its\r
+ * documentation for any purpose, without fee, and without written agreement is\r
+ * hereby granted, provided that the above copyright notice, the following\r
+ * two paragraphs and the author appear in all copies of this software.\r
+ * \r
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR\r
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT\r
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF\r
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * \r
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,\r
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY\r
+ * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS\r
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO\r
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."\r
+ *\r
+ * Copyright (c) 2002-2005 Intel Corporation\r
+ * All rights reserved.\r
+ *\r
+ * This file is distributed under the terms in the attached INTEL-LICENSE \r
+ * file. If you do not find these files, copies can be found by writing to\r
+ * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, \r
+ * 94704. Attention: Intel License Inquiry.\r
+ *\r
+ * Copyright (c) 2004-2005 Crossbow Technology, Inc. All rights reserved. \r
+ *\r
+ * Permission to use, copy, modify, and distribute this software and its\r
+ * documentation for any purpose, without fee, and without written agreement is\r
+ * hereby granted, provided that the above copyright notice, the following\r
+ * two paragraphs and the author appear in all copies of this software. \r
+ * IN NO EVENT SHALL CROSSBOW TECHNOLOGY OR ANY OF ITS LICENSORS BE LIABLE TO \r
+ * ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL \r
+ * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
+ * IF CROSSBOW OR ITS LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH \r
+ * DAMAGE. \r
+ *\r
+ * CROSSBOW TECHNOLOGY AND ITS LICENSORS SPECIFICALLY DISCLAIM ALL WARRANTIES,\r
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY \r
+ * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS \r
+ * ON AN "AS IS" BASIS, AND NEITHER CROSSBOW NOR ANY LICENSOR HAS ANY \r
+ * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR \r
+ * MODIFICATIONS. \r
+ */\r
+\r
+/**\r
+ *\r
+ * @author tinyos-help@millennium.berkeley.edu\r
+ * @author Hu Siquan <husq@xbow.com>\r
+ **/\r
+\r
+configuration TestADCC\r
+{\r
+}\r
+implementation\r
+{\r
+ components Main, TestADCM, DemoSensorC, LedsC;\r
+\r
+ TestADCM -> Main.Boot;\r
+ Main.SoftwareInit -> LedsC;\r
+ TestADCM.Leds -> LedsC;\r
+ TestADCM.SensorControl -> DemoSensorC; \r
+ TestADCM.AcquireData -> DemoSensorC; \r
+}\r
+\r
--- /dev/null
+// $Id$\r
+\r
+/* tab:4\r
+ * "Copyright (c) 2000-2005 The Regents of the University of California. \r
+ * All rights reserved.\r
+ *\r
+ * Permission to use, copy, modify, and distribute this software and its\r
+ * documentation for any purpose, without fee, and without written agreement is\r
+ * hereby granted, provided that the above copyright notice, the following\r
+ * two paragraphs and the author appear in all copies of this software.\r
+ * \r
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR\r
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT\r
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF\r
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * \r
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,\r
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY\r
+ * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS\r
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO\r
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."\r
+ *\r
+ * Copyright (c) 2002-2003 Intel Corporation\r
+ * All rights reserved.\r
+ *\r
+ * This file is distributed under the terms in the attached INTEL-LICENSE \r
+ * file. If you do not find these files, copies can be found by writing to\r
+ * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, \r
+ * 94704. Attention: Intel License Inquiry.\r
+ * \r
+ * Copyright (c) 2004-2005 Crossbow Technology, Inc. All rights reserved. \r
+ *\r
+ * Permission to use, copy, modify, and distribute this software and its\r
+ * documentation for any purpose, without fee, and without written agreement is\r
+ * hereby granted, provided that the above copyright notice, the following\r
+ * two paragraphs and the author appear in all copies of this software. \r
+ *\r
+ * IN NO EVENT SHALL CROSSBOW TECHNOLOGY OR ANY OF ITS LICENSORS BE LIABLE TO \r
+ * ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL \r
+ * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
+ * IF CROSSBOW OR ITS LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH \r
+ * DAMAGE. \r
+ *\r
+ * CROSSBOW TECHNOLOGY AND ITS LICENSORS SPECIFICALLY DISCLAIM ALL WARRANTIES,\r
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY \r
+ * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS \r
+ * ON AN "AS IS" BASIS, AND NEITHER CROSSBOW NOR ANY LICENSOR HAS ANY \r
+ * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR \r
+ * MODIFICATIONS. \r
+ */\r
+/**\r
+ *\r
+ * @author Hu Siquan <husq@xbow.com>\r
+ *\r
+ * Implementation for TestADC application. \r
+ * Toggle the green LED when a dataReady event fires.\r
+ **/\r
+\r
+\r
+module TestADCM\r
+{\r
+ uses interface StdControl as SensorControl;\r
+ uses interface AcquireData;\r
+ uses interface Leds;\r
+ uses interface Boot;\r
+}\r
+implementation\r
+{\r
+ event void Boot.booted()\r
+ {\r
+ call Leds.led0Toggle();\r
+ call SensorControl.start();\r
+ call AcquireData.getData();\r
+ }\r
+\r
+ event void AcquireData.dataReady(uint16_t data) {\r
+ call SensorControl.stop();\r
+ call Leds.led1Toggle();\r
+ if (data & 1)\r
+ call Leds.led2On();\r
+ else\r
+ call Leds.led2Off();\r
+ }\r
+\r
+ event void AcquireData.error(uint16_t info) {\r
+ call SensorControl.stop(); \r
+ }\r
+}\r
+\r
--- /dev/null
+COMPONENT=TestI2CC
+include $(MAKERULES)
+
--- /dev/null
+// $Id$
+
+/**
+ * Copyright (c) 2004-2005 Crossbow Technology, Inc. All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ *
+ * IN NO EVENT SHALL CROSSBOW TECHNOLOGY OR ANY OF ITS LICENSORS BE LIABLE TO
+ * ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
+ * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF CROSSBOW OR ITS LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * CROSSBOW TECHNOLOGY AND ITS LICENSORS SPECIFICALLY DISCLAIM ALL WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND NEITHER CROSSBOW NOR ANY LICENSOR HAS ANY
+ * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+ * MODIFICATIONS.
+ */
+
+/// @author Martin Turon <mturon@xbow.com>
+
+/** This version of TestI2C is designed to test the ATmega128 I2C subsystem. */
+configuration TestI2CC
+{
+}
+implementation
+{
+ components
+ MainC, TestI2CM, LedsC,
+ new TimerMilliC() as Timer0,
+ HplAtm128I2CBusC as I2C;
+ //new Atm128I2CMasterC(0x58) as I2CPot; // ad5242 for mag on MTS310
+
+ TestI2CM -> MainC.Boot;
+
+
+ TestI2CM.Timer0 -> Timer0;
+ TestI2CM.Leds -> LedsC;
+ TestI2CM.I2C -> I2C;
+}
+
--- /dev/null
+/**
+ * Copyright (c) 2004-2005 Crossbow Technology, Inc.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written
+ * agreement is hereby granted, provided that the above copyright
+ * notice, the (updated) modification history and the author appear in
+ * all copies of this source code.
+ *
+ * Permission is also granted to distribute this software under the
+ * standard BSD license as contained in the TinyOS distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA,
+ * OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @author Martin Turon <mturon@xbow.com>
+ *
+ * $Id$
+ */
+
+/**
+ * Implementation for TestI2C application:
+ * Yellow == Every timer, post task for I2C ping if not already running
+ * Red & GREEN == task started
+ * Red == Device ping FAIL
+ * Green == Device ping SUCCESS
+ *
+ * @version 2005/9/11 mturon Initial version
+ */
+
+#define I2C_DEVICE I2C_MTS300_MIC
+
+#define I2C_MTS310_MAG 0x58
+#define I2C_MTS300_MIC 0x5A
+#define I2C_MDA300_ADC 0x94
+#define I2C_MDA300_EE 0xAE
+
+#include "Timer.h"
+
+module TestI2CM
+{
+ uses interface Timer<TMilli> as Timer0;
+ uses interface Leds;
+ uses interface Boot;
+ uses interface HplAtm128I2CBus as I2C;
+}
+implementation
+{
+ bool working;
+
+ task void i2c_test() {
+ call Leds.led1On();
+ call Leds.led0On();
+
+ if (call I2C.ping(I2C_DEVICE) == SUCCESS) {
+ call Leds.led0Off();
+ } else {
+ call Leds.led1Off();
+ }
+
+ working = FALSE;
+ }
+
+ void i2c_test_start() {
+ atomic {
+ if (!working) {
+ working = TRUE;
+ post i2c_test();
+ }
+ }
+ }
+
+ event void Boot.booted() {
+ working = FALSE;
+ call I2C.init();
+
+ call Timer0.startPeriodic( 10000 );
+
+ call Leds.led2On();
+ i2c_test_start();
+ }
+
+ event void Timer0.fired() {
+ call Leds.led2Toggle();
+ i2c_test_start();
+ }
+
+ async event void I2C.symbolSent() { }
+
+}
+
--- /dev/null
+// $Id$
+
+/**
+ * Copyright (c) 2004-2005 Crossbow Technology, Inc. All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ *
+ * IN NO EVENT SHALL CROSSBOW TECHNOLOGY OR ANY OF ITS LICENSORS BE LIABLE TO
+ * ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
+ * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF CROSSBOW OR ITS LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * CROSSBOW TECHNOLOGY AND ITS LICENSORS SPECIFICALLY DISCLAIM ALL WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND NEITHER CROSSBOW NOR ANY LICENSOR HAS ANY
+ * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+ * MODIFICATIONS.
+ */
+
+/// @author Martin Turon <mturon@xbow.com>
+
+/** This version of Blink is designed to test ATmega128 AVR timers. */
+configuration BlinkC
+{
+}
+implementation
+{
+ components MainC, new BlinkM(uint8_t), LedsC, HplTimerC;
+
+ BlinkM.Boot -> MainC;
+
+ BlinkM.Leds -> LedsC;
+
+ BlinkM.Timer -> HplTimerC.Timer0;
+ BlinkM.Compare -> HplTimerC.Compare0;
+
+ BlinkM.FastTimer -> HplTimerC.Timer1;
+ BlinkM.FastCompare -> HplTimerC.Compare1A;
+}
+
--- /dev/null
+// $Id$
+
+/**
+ * Copyright (c) 2004-2005 Crossbow Technology, Inc. All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ *
+ * IN NO EVENT SHALL CROSSBOW TECHNOLOGY OR ANY OF ITS LICENSORS BE LIABLE TO
+ * ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
+ * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF CROSSBOW OR ITS LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * CROSSBOW TECHNOLOGY AND ITS LICENSORS SPECIFICALLY DISCLAIM ALL WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND NEITHER CROSSBOW NOR ANY LICENSOR HAS ANY
+ * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+ * MODIFICATIONS.
+ */
+
+/// @author Martin Turon <mturon@xbow.com>
+
+#define SLOW_COMPARE 50
+#define SLOW_COMPARE_ON_CYCLE 320
+#define SLOW_OVERFLOW_CYCLES 500
+
+#define FAST_COMPARE 16000
+#define FAST_COMPARE_ON_CYCLE 4
+#define FAST_OVERFLOW_CYCLES 5
+
+#include <ATm128Timer.h>
+
+/**
+ * This version of Blink is designed to test ATmega128 AVR timers.
+ */
+generic module BlinkM(typedef timer_size @integer())
+{
+ uses interface HplTimer<timer_size> as Timer;
+ uses interface HplCompare<timer_size> as Compare;
+ uses interface HplTimer<uint16_t> as FastTimer;
+ uses interface HplCompare<uint16_t> as FastCompare;
+ uses interface Boot;
+ uses interface Leds;
+}
+implementation
+{
+ norace int scycle = SLOW_OVERFLOW_CYCLES;
+ norace int fcycle = FAST_OVERFLOW_CYCLES;
+
+ void slow_timer_init() {
+ atomic {
+ CLR_BIT(ASSR, AS0); // set Timer/Counter0 to use 32,768khz crystal
+
+ call Timer.setScale(ATM128_CLK8_DIVIDE_32);
+ call Compare.set(SLOW_COMPARE); // trigger compare in middle of range
+ call Compare.start();
+
+ call Timer.start();
+ call Timer.set(0); // overflow after 256-6 = 250 cycles
+ }
+ }
+
+ void fast_timer_init() {
+
+ atomic {
+ call FastTimer.setScale(AVR_CLOCK_DIVIDE_8);
+ call FastCompare.set(FAST_COMPARE); // trigger compare mid pulse
+ call FastCompare.start();
+
+ call FastTimer.start();
+ call FastTimer.set(0); // overflow after 256-6 = 250 cycles
+ }
+ }
+
+ event void Boot.booted() {
+ slow_timer_init();
+ fast_timer_init();
+
+ while(1) {}
+ }
+
+ async event void Compare.fired() {
+ call Leds.led0On();
+ call Compare.stop();
+ }
+
+ async event void Timer.overflow() {
+ call Timer.reset();
+
+ if (scycle == SLOW_COMPARE_ON_CYCLE) {
+ call Compare.reset();
+ call Compare.start();
+ }
+
+ if (scycle++ > SLOW_OVERFLOW_CYCLES) {
+ scycle = 0;
+ call Leds.led0Off();
+ }
+ }
+
+ async event void FastCompare.fired() {
+ if (fcycle == FAST_COMPARE_ON_CYCLE) {
+ call Leds.led2On();
+ call FastCompare.stop();
+ }
+ }
+
+ async event void FastTimer.overflow() {
+ call FastTimer.reset();
+
+ if (fcycle == FAST_COMPARE_ON_CYCLE) {
+ call FastCompare.reset();
+ call FastCompare.start();
+ }
+
+ if (fcycle++ > FAST_OVERFLOW_CYCLES) {
+ fcycle = 0;
+ call Leds.led1Toggle(); // toggle overflow led
+ call Leds.led2Off(); // clear compare led
+ }
+ }
+}
+
--- /dev/null
+COMPONENT=BlinkC
+include $(MAKERULES)
+
--- /dev/null
+COMPONENT=TestMts300C
+SENSORBOARD=mts300
+#CFLAGS += -I%T/sensorboards/mts300
+include $(MAKERULES)
--- /dev/null
+/**
+ * Copyright (c) 2004-2005 Crossbow Technology, Inc.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written
+ * agreement is hereby granted, provided that the above copyright
+ * notice, the (updated) modification history and the author appear in
+ * all copies of this source code.
+ *
+ * Permission is also granted to distribute this software under the
+ * standard BSD license as contained in the TinyOS distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA,
+ * OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @author Martin Turon <mturon@xbow.com>
+ *
+ * $Id$
+ */
+
+/**
+ * This application tests the mts300 sensorboard.
+ * Specifically, this handles the thermistor and light sensors.
+ *
+ * @author Martin Turon
+ * @date October 19, 2005
+ */
+configuration TestMts300C {
+}
+implementation
+{
+ components MainC, TestMts300P, LedsC, new OskiTimerMilliC(),
+ SensorMts300C;
+
+
+ MainC.SoftwareInit -> SensorMts300C;
+
+ TestMts300P -> MainC.Boot;
+ TestMts300P.Leds -> LedsC;
+ TestMts300P.AppTimer -> OskiTimerMilliC;
+
+ TestMts300P.SensorControl -> SensorMts300C;
+ TestMts300P.Temp -> SensorMts300C.Temp;
+ TestMts300P.Light -> SensorMts300C.Light;
+}
+
--- /dev/null
+/**
+ * Copyright (c) 2004-2005 Crossbow Technology, Inc.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written
+ * agreement is hereby granted, provided that the above copyright
+ * notice, the (updated) modification history and the author appear in
+ * all copies of this source code.
+ *
+ * Permission is also granted to distribute this software under the
+ * standard BSD license as contained in the TinyOS distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA,
+ * OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @author Martin Turon <mturon@xbow.com>
+ *
+ * $Id$
+ */
+
+#include "Timer.h"
+
+/**
+ * This application tests the mts300 sensorboard.
+ * Specifically, this handles the thermistor and light sensors.
+ *
+ * @author Martin Turon
+ * @date October 19, 2005
+ */
+module TestMts300P
+{
+ uses {
+ interface Boot;
+ interface Leds;
+ interface Timer<TMilli> as AppTimer;
+
+ interface StdControl as SensorControl;
+ interface AcquireData as Temp;
+ interface AcquireData as Light;
+ }
+}
+implementation
+{
+ event void Boot.booted() {
+ call Leds.led0On();
+ call Leds.led1On(); // power led
+ call SensorControl.start();
+ }
+
+ event void AppTimer.fired() {
+ call Leds.led0Toggle(); // heartbeat indicator
+ call Light.getData();
+ call Temp.getData();
+ }
+
+ event void Light.dataReady(uint16_t data) {
+ call Leds.led1Toggle();
+ }
+
+ event void Temp.dataReady(uint16_t data) {
+ call Leds.led2Toggle();
+ }
+
+ event void Light.error(uint16_t info) {
+ }
+
+ event void Temp.error(uint16_t info) {
+ }
+}
+
then with an id of 210 to check that the data is correct. Or install
with an id of 10 to do a combined write+read test.
-A successful test will blink the yellow led a few times, then turn on the
-green led. A failed test will turn on the red led.
+A successful test will blink the yellow led a few times, then turn on
+the green led. A failed test will turn on the red led. A serial message
+whose last byte is 0x80 for success and all other values indicate
+failure is also sent at the end of the test.
Tools:
*
* @author David Gay
*/
-/*
- address & 3:
- 0, 2: r
- 1: w
- 3: r&w
-*/
module RandRWC {
uses {
interface Boot;
if (++count == NWRITES)
{
call Leds.led2Toggle();
- scheck(call BlockWrite.commit());
+ scheck(call BlockWrite.sync());
}
else
{
}
}
- event void BlockWrite.commitDone(error_t result) {
+ event void BlockWrite.syncDone(error_t result) {
if (scheck(result))
done();
}
nextRead();
}
- event void BlockRead.verifyDone(error_t result) {
- if (scheck(result))
- {
- call Leds.led2Toggle();
- nextRead();
- }
- }
-
event void BlockRead.computeCrcDone(storage_addr_t x, storage_len_t y, uint16_t z, error_t result) {
}
scheck(call BlockWrite.erase());
break;
case A_READ:
- scheck(call BlockRead.verify());
+ nextRead();
break;
}
}
to perform a full test.
A successful test will turn on the green led. A failed test will turn on
-the red led. The yellow led is turned on after erase is complete.
+the red led. The yellow led is turned on after erase is complete. A
+serial message whose last byte is 0x80 for success and all other values
+indicate failure is also sent at the end of the test.
Tools:
*
* @author David Gay
*/
-/*
- address & 3:
- 1: erase, write
- 2: read
- 3: write some more
-*/
module RandRWC {
uses {
interface Boot;
}
}
- event void LogWrite.appendDone(void *buf, storage_len_t y, error_t result) {
+ event void LogWrite.appendDone(void *buf, storage_len_t y, bool recordsLost, error_t result) {
if (scheck(result))
nextWrite();
}
a previous run with T = 0 and the same random seed
A successful test will turn on the green led. A failed test will turn on
-the red led. The yellow led blinks to indicate test progress
+the red led. The yellow led blinks to indicate test progress. A serial
+message whose last byte is 0x80 for success and all other values
+indicate failure is also sent at the end of the test.
Tools:
* 94704. Attention: Intel License Inquiry.
*/
/**
- * Log storage test application. Does a pattern of random reads and
+ * Config storage test application. Does a pattern of random reads and
* writes, based on mote id. See README.txt for more details.
*
* @author David Gay
will fail, but a subsequent read will succeed.
A successful test will turn on the green led. A failed test will turn on
-the red led. The yellow led blinks during the steps of the full test.
+the red led. The yellow led blinks during the steps of the full test. A
+serial message whose last byte is 0x80 for success and all other values
+indicate failure is also sent at the end of the test.
Tools:
*
* @author David Gay
*/
-/*
- address & 3:
- 1: erase, write
- 2: read
- 3: write some more
-*/
module RandRWC {
uses {
interface Boot;
}
}
- event void LogWrite.appendDone(void *buf, storage_len_t y, error_t result) {
+ event void LogWrite.appendDone(void *buf, storage_len_t y, bool recordsLost, error_t result) {
if (scheck(result))
nextWrite();
}
<tr>
<td>TinyOS</td>
- <td><a href="http://www.tinyos.net/dist-2.0.0/tinyos/windows/tinyos-2.0.0-2.cygwin.noarch.rpm">tinyos-2.0.0-2.cygwin.noarch.rpm</a></td>
- <td><a href="http://www.tinyos.net/dist-2.0.0/tinyos/linux/tinyos-2.0.0-2.noarch.rpm">tinyos-2.0.0-2.noarch.rpm</a></td>
+ <td><a href="http://www.tinyos.net/dist-2.0.0/tinyos/windows/tinyos-2.0.0-1.cygwin.noarch.rpm">tinyos-2.0.0-1.cygwin.noarch.rpm</a></td>
+ <td><a href="http://www.tinyos.net/dist-2.0.0/tinyos/linux/tinyos-2.0.0-1.noarch.rpm">tinyos-2.0.0-1.noarch.rpm</a></td>
</tr>
</tbody></table>
<td>Ben Greenstein and Philip Levis</td></tr>
<tr class="field"><th class="docinfo-name">Draft-Created:</th><td class="field-body">11-Jul-2005</td>
</tr>
-<tr class="field"><th class="docinfo-name">Draft-Version:</th><td class="field-body">1.1.2.5</td>
+<tr class="field"><th class="docinfo-name">Draft-Version:</th><td class="field-body">1.1.2.4</td>
</tr>
-<tr class="field"><th class="docinfo-name">Draft-Modified:</th><td class="field-body">2006-11-06</td>
+<tr class="field"><th class="docinfo-name">Draft-Modified:</th><td class="field-body">2006-06-14</td>
</tr>
<tr class="field"><th class="docinfo-name">Draft-Discuss:</th><td class="field-body">TinyOS Developer List <tinyos-devel at mail.millennium.berkeley.edu></td>
</tr>
provides interface DisseminationUpdate <t>;
}
</pre>
-<p>The t argument MUST be able to fit in a single message_t[<a class="reference" href="#id2">1</a>] after
+<p>The t argument MUST be able to fit in a single message_t[<a href="#id4" name="id5"><span class="problematic" id="id5">tep111_</span></a>] after
considering the headers that the dissemination protocol introduces.
A dissemination implementation SHOULD have a compile error if a larger
type than this is used.</p>
</tbody>
</table>
</div>
+<div class="system-messages section">
+<h1>Docutils System Messages</h1>
+<div class="system-message" id="id4">
+<p class="system-message-title">System Message: <a name="id4">ERROR/3</a> (<tt class="docutils">txt/tep118.txt</tt>, line 116); <em><a href="#id5">backlink</a></em></p>
+Unknown target name: "tep111".</div>
+</div>
</div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
+<meta name="generator" content="Docutils 0.4: http://docutils.sourceforge.net/" />
<title>Collection</title>
<meta name="author" content="Rodrigo Fonseca, Omprakash Gnawali, Kyle Jamieson, and Philip Levis" />
<style type="text/css">
</style>
</head>
<body>
+<div class="document" id="collection">
<h1 class="title">Collection</h1>
<table class="docinfo" frame="void" rules="none">
<col class="docinfo-name" />
</tr>
</tbody>
</table>
-<div class="document" id="collection">
<div class="note">
<p class="first admonition-title">Note</p>
<p class="last">This memo documents a part of TinyOS for the TinyOS Community, and
of this memo is unlimited. This memo is in full compliance with
TEP 1.</p>
</div>
-<div class="section" id="abstract">
-<h1><a name="abstract">Abstract</a></h1>
+<div class="section">
+<h1><a id="abstract" name="abstract">Abstract</a></h1>
<p>The memo documents the interfaces, components, and semantics used by
collection protocol in TinyOS 2.x. Collection provides a best-effort,
-multihop delivery of packets to the root of <em>a</em> tree. There may be
-multiple roots in a network, and in this case the semantics implemented
-are of <em>anycast</em> delivery to at least one of the roots. A node sending
-a packet does not specify which root the packet is destined to.</p>
+multihop delivery of packets to the root of a tree.</p>
</div>
-<div class="section" id="introduction">
-<h1><a name="introduction">1. Introduction</a></h1>
+<div class="section">
+<h1><a id="introduction" name="introduction">1. Introduction</a></h1>
<p>Collecting data at a base station is a common requirement of sensor
network applications. The general approach used is to build one
or more collection <em>trees</em>, each of which is rooted at a base
-station. When a node has data which needs to be collected, it
+station. When a node has data which needs to be collected, it
sends the data up the tree, and it forwards collection data that
other nodes send to it. Sometimes, depending on the form of data
collection, systems need to be able to inspect packets as they go
by, either to gather statistics, compute aggregates, or suppress
redundant transmissions.</p>
<p>When a network has multiple base stations that act as <em>root</em> nodes,
-rather than one tree, it has a <em>forest</em> of trees. By picking a
+rather than one tree, it has a <em>forest</em> of trees. By picking a
parent node, a collection protocol implicitly joins one of these
trees. Collection provides a best-effort,
multihop delivery of packets to one of a network's tree roots:
-it is an <em>anycast</em> protocol. The semantics is that the protocol
-will make a reasonable effort to deliver the message to at least
-one of the roots in the network. There are however no guarantees of
-delivery, and there can be duplicates delivered to one or more
-roots. There is also no ordering guarantees.</p>
+it is an <em>anycast</em> protocol.</p>
<p>Given the limited state that nodes can store and a general need
for distributed tree building algorithms, simple collection protocols
encounter several challenges. These challenges are not unique to
<ul class="simple">
<li>Loop detection, detecting when a node selects one of its
descendants as a new parent.</li>
-<li>Duplicate suppression, detecting and dealing with when lost
-acknowledgments are causing packets to replicate in the
+<li>Duplicate suppression, detecting and dealing with when lost
+acknowledgments are causing packets to replicate in the
network, wasting bandwidth.</li>
<li>Link estimation, evaluating the link quality to single-hop
neighbors.</li>
<p>The rest of this document describes a set of components and interfaces
for a collection service outlined above.</p>
</div>
-<div class="section" id="collection-interfaces">
-<h1><a name="collection-interfaces">2. Collection interfaces</a></h1>
+<div class="section">
+<h1><a id="collection-interfaces" name="collection-interfaces">2. Collection interfaces</a></h1>
<p>A node can perform four different roles in collection: producer,
consumer, snooper, and in-network processor. Depending on their role,
the nodes use different interfaces to interact with the collection
component.</p>
-<p>A consumer is a root of a tree. The set of all roots and the paths that
-lead to them form the collection routing infrastructure in the network.
-For any connected set of nodes implementing the collection protocol
-there is only one collection infrastructure, <em>i.e.</em>, all roots in this
-set active at the same time are part of the same infrastructure.</p>
+<p>The nodes that generate data to be sent to the root are
+<em>producers</em>. The producers use the Send interface [<a class="reference" href="#id1">1</a>] to send
+data to the root of the collection tree. The collection tree
+identifier is be specified as a parameter to Send during
+instantiation.</p>
+<p>Root nodes that receive data from the network are <em>consumers</em>. The
+consumers use the Receive interface [<a class="reference" href="#id1">1</a>] to receive a message
+delivered by collection. The collection tree identifier is be
+specified as a parameter to Receive during instantiation.</p>
+<p>The nodes that overhear messages in transit are <em>snoopers</em>. The snoopers
+use the Receive interface [<a class="reference" href="#id1">1</a>] to receive a snooped message. The
+collection tree identifier is be specified as a parameter to Receive
+during instantiation.</p>
+<p>The nodes can process a packet that are in transit. These in-network
+<em>processors</em> use the Intercept interface [<a class="reference" href="#id1">1</a>] to receive and
+update a packet. The collection tree identifier is be specified as a
+parameter to Intercept during instantiation.</p>
<p>A node is configured to become a root by using the RootControl
interface. RootControl.setRoot() MUST make the current node a root of
-the the collection infrastructure. RootControl.unsetRoot() MUST
-make the current root no longer a root in the collection infrastructure.
-Both calls are idempotent.
-RootControl.setRoot() MAY be called on a node that is already a root, to
-no effect. RootControl.unsetRoot() MAY be called on a node that is
+the tree specified during instantiation. RootControl.unsetRoot() MUST
+make the current root no longer a root in the tree specified during
+instantiation. RootControl.unsetRoot() MAY be called on a node that is
not a root:</p>
<pre class="literal-block">
interface RootControl {
command bool isRoot();
}
</pre>
-<p>The collection infrastructure can be multiplexed among independent
-applications, by means of a <em>collection identifier</em>. It is important
-to note that the <em>data</em> traffic in the protocol is multiplexed,
-while the <em>control</em> traffic is not.</p>
-<p>The nodes that generate data to be sent to the root are <em>producers</em>.
-The producers use the Send interface [<a class="reference" href="#id1">1</a>] to send data to the root
-of the collection tree. The collection identifier is specified as a
-parameter to Send during instantiation.</p>
-<p>Root nodes that receive data from the network are <em>consumers</em>. The
-consumers use the Receive interface [<a class="reference" href="#id1">1</a>] to receive a message
-delivered by collection. The collection identifier is specified
-as a parameter to Receive during instantiation.</p>
-<p>The nodes that overhear messages in transit are <em>snoopers</em>. The
-snoopers use the Receive interface [<a class="reference" href="#id1">1</a>] to receive a snooped
-message. The collection identifier is specified as a parameter
-to Receive during instantiation.</p>
-<p>The nodes can process a packet that are in transit. These in-network
-<em>processors</em> use the Intercept interface [<a class="reference" href="#id1">1</a>] to receive and update
-a packet. The collection identifier is specified as a parameter
-to Intercept during instantiation.</p>
</div>
-<div class="section" id="collection-services">
-<h1><a name="collection-services">3 Collection Services</a></h1>
-<p>A collection service MUST provide one component, CollectionC,
+<div class="section">
+<h1><a id="collection-services" name="collection-services">3 Collection Services</a></h1>
+<p>A collection service MUST provide one component, TreeCollectionC,
which has the following signature:</p>
<pre class="literal-block">
-configuration CollectionC {
+configuration TreeCollectionC {
provides {
interface StdControl;
interface Send[uint8_t client];
interface RootControl;
interface Packet;
interface CollectionPacket;
+ interface TreeRoutingInspect;
}
uses {
interface CollectionId[uint8_t client];
}
}
</pre>
-<p>CollectionC MAY have additional interfaces, but they MUST have
+<p>TreeCollectionC MAY have additional interfaces, but they MUST have
default functions on all outgoing invocations (commands for uses,
events for provides) of those interfaces so that it can operate
properly if they are not wired.</p>
-<p>Components SHOULD NOT wire to CollectionC.Send. The generic
+<p>Components SHOULD NOT wire to TreeCollectionC.Send. The generic
component CollectionSenderC (described in section 3.1) provides
a virtualized sending interface.</p>
<p>Receive, Snoop, and Intercept are all parameterized by
collection_id_t generally have the same payload format, so that
snoopers, intercepters, and receivers can parse it properly.</p>
<p>Receive.receive MUST NOT be signaled on non-root
-nodes. CollectionC MAY signal Receive.receive on a root node when
+nodes. TreeCollectionC MAY signal Receive.receive on a root node when
a data packet successfully arrives at that node. If a root node calls
-Send, CollectionC MUST treat it as it if were a received packet.
+Send, TreeCollectionC MUST treat it as it if were a received packet.
Note that the buffer swapping semantics of Receive.receive, when
-combined with the pass semantics of Send, require that CollectionC
+combined with the pass semantics of Send, require that TreeCollectionC
make a copy of the buffer if it signals Receive.receive.</p>
-<p>If CollectionC receives a data packet to forward and it is not a
+<p>If TreeCollectionC receives a data packet to forward and it is not a
root node, it MAY signal Intercept.forward.</p>
-<p>If CollectionC receives a data packet that a different node
+<p>If TreeCollectionC receives a data packet that a different node
is supposed to forward, it MAY signal Snoop.receive.</p>
<p>RootControl allows a node to be made a collection tree root.
-CollectionC SHOULD NOT configure a node as a root by default.</p>
+TreeCollectionC SHOULD NOT configure a node as a root by default.</p>
<p>Packet and CollectionPacket allow components to access collection
data packet fields [<a class="reference" href="#id1">1</a>].</p>
-<div class="section" id="collectionsenderc">
-<h2><a name="collectionsenderc">3.1 CollectionSenderC</a></h2>
-<p>Collection has a virtualized sending abstraction, the generic
-component CollectionSenderC:</p>
+<p>TreeRoutingInspect provides information on the current position of
+the node in a routing tree:</p>
<pre class="literal-block">
-generic configuration CollectionSenderC(collection_id_t collectid) {
- provides {
- interface Send;
- interface Packet;
- }
+interface TreeRoutingInspect {
+ command error_t getParent(am_addr_t* parent);
+ command error_t getHopcount(uint8_t* hopcount);
+ command error_t getMetric(uint16_t* metric);
}
</pre>
+<p>In each of these commands, if the return value is not SUCCESS, the
+value stored in the pointer argument is undefined. The getMetric
+command provides a measure of the quality of a node's route to the
+base station. This routing metric MUST be monotonically increasing
+across hops. In a collection tree, if node A is the parent of node B,
+then node B's metric value MUST be greater than node A's.</p>
+<div class="section">
+<h2><a id="collectionsenderc" name="collectionsenderc">3.1 CollectionSenderC</a></h2>
+<p>Collection has a virtualized sending abstraction, the generic
+component CollectionSenderC:</p>
+<div class="system-message">
+<p class="system-message-title">System Message: WARNING/2 (<tt class="docutils">txt/tep119.txt</tt>, line 198)</p>
+Literal block expected; none found.</div>
+<dl class="docutils">
+<dt>generic configuration CollectionSenderC(collection_id_t collectid) {</dt>
+<dd><dl class="first docutils">
+<dt>provides {</dt>
+<dd>interface Send;
+interface Packet;</dd>
+</dl>
+<div class="system-message">
+<p class="system-message-title">System Message: WARNING/2 (<tt class="docutils">txt/tep119.txt</tt>, line 202)</p>
+Definition list ends without a blank line; unexpected unindent.</div>
+<p class="last">}</p>
+</dd>
+</dl>
+<div class="system-message">
+<p class="system-message-title">System Message: WARNING/2 (<tt class="docutils">txt/tep119.txt</tt>, line 203)</p>
+Definition list ends without a blank line; unexpected unindent.</div>
+<p>}</p>
<p>This abstraction follows a similar virtualization approach to
AMSenderC [<a class="reference" href="#id1">1</a>], except that it is parameterized by a collection_id_t
rather than an am_id_t. As with am_id_t, every collection_id_t SHOULD
based on its collection ID and contents.</p>
</div>
</div>
-<div class="section" id="implementation">
-<h1><a name="implementation">4 Implementation</a></h1>
+<div class="section">
+<h1><a id="implementation" name="implementation">4 Implementation</a></h1>
<p>An implementation of this TEP can be found in
-<tt class="docutils literal"><span class="pre">tinyos-2.x/tos/lib/net/ctp</span></tt> and <tt class="docutils literal"><span class="pre">tinyos-2.x/tos/lib/net/le</span></tt>, in
-the CTP protocol. It is beyond the scope of this document to fully
-describe CTP, but we outline its main components. CTP will be
-described in an upcoming TEP [<a class="reference" href="#id2">2</a>]. This implementation is a
-reference implementation, and is not the only possibility. It
-consists of three major components, which are wired together to form
-a CollectionC: LinkEstimatorP, CtpTreeRoutingEngineP, and
-CtpForwardingEngineP.</p>
-<p>This decomposition tries to encourage evolution of components and
-ease of use through modularization. Neighbor management and link
-estimation are decoupled from the routing protocol. Furthermore, the
-routing protocol and route selection are decoupled from the
-forwarding policies, such as queueing and timing.</p>
-<div class="section" id="linkestimatorp">
-<h2><a name="linkestimatorp">4.1 LinkEstimatorP</a></h2>
+<tt class="docutils literal"><span class="pre">tinyos-2.x/tos/lib/net/collection</span></tt>. The implementation consists of
+three major components, which are wired together to form a
+CollectionC: LinkEstimatorP, TreeRoutingEngineP, and ForwardingEngineP.</p>
+<p>This decomposition tries to encourage evolution of components and ease
+of use through modularization. Neighbor management and link estimation
+are are decoupled from the routing protocol. Furthermore, the routing
+protocol and route selection are decoupled from the forwarding policies,
+such as queueing and timing.</p>
+<div class="section">
+<h2><a id="linkestimatorp" name="linkestimatorp">4.1 LinkEstimatorP</a></h2>
<p>LinkEstimatorP estimates the quality of link to or from each
-neighbor. Link estimation can be done in a variety of ways, and we
-do not impose one here. It is decoupled from the establishment of
-routes. There is a narrow interface -- LinkEstimator -- between the
-link estimator and the routing engine. The one requirement is that
-the quality returned is standardized. A smaller return value from
+neighbor. Link estimation can be done in a variety of ways, and we do
+not impose one here. It is decoupled from the establishment of
+routes. There is a narrow interface (LinkEstimator) between the link
+estimator and the routing engine. The one requirement is that the
+quality returned is standardized. A larger return value from
LinkEstimator.getQuality(), LinkEstimator.getforwardQuality(),
LinkEstimator.getreserveQuality() MUST imply that the link to the
neighbor is estimated to be of a higher quality than the one that
[0,255] and the variation in link quality in that range SHOULD be
linear. Radio provided values such as LQI or RSI, beacon based link
estimation to compute ETX, or their combination are some possible
-approaches to estimating link qualities.</p>
-<p>LinkEstimatorP MAY have its own control messages to compute
-bi-directional link qualities. LinkEstimatorP provides calls
-(txAck(), txNoAck(), and clearDLQ()) to update the link estimates
-based on successful or unsuccessful data transmission to the
-neighbors.</p>
-<p>The user of LinkEstimatorP can call insertNeighbor() to manually
-insert a node in the neighbor table, pinNeighbor() to prevent a
-neighbor from being evicted, and unpinNeighbor() to restore eviction
-policy:</p>
+approaches to estimating link qualities. LinkEstimatorP MAY have its
+own control messages to compute bi-directional link qualities:</p>
<pre class="literal-block">
-typedef uint16_t neighbor_table_entry_t
+typedef uint16_t neighbor_t
LinkEstimatorP {
provides {
- interface StdControl;
- interface AMSend as Send;
- interface Receive;
interface LinkEstimator;
- interface Init;
- interface Packet;
- interface LinkSrcPacket;
+ interface NeighborTable;
}
}
interface LinkEstimator {
- command uint8_t getLinkQuality(uint16_t neighbor);
- command uint8_t getReverseQuality(uint16_t neighbor);
- command uint8_t getForwardQuality(uint16_t neighbor);
- command error_t insertNeighbor(am_addr_t neighbor);
- command error_t pinNeighbor(am_addr_t neighbor);
- command error_t unpinNeighbor(am_addr_t neighbor);
- command error_t txAck(am_addr_t neighbor);
- command error_t txNoAck(am_addr_t neighbor);
- command error_t clearDLQ(am_addr_t neighbor);
- event void evicted(am_addr_t neighbor);
+ command uint8_t getLinkQuality(neighbot_t neighbor);
+ command uint8_t getReverseQuality(neighbot_t neighbor);
+ command uint8_t getForwardQuality(neighbot_t neighbor);
+}
+
+interface NeighborTable {
+ event void evicted(neighbot_t neighbor)
}
</pre>
</div>
-<div class="section" id="ctproutingenginep">
-<h2><a name="ctproutingenginep">4.2 CtpRoutingEngineP</a></h2>
-<p>CtpRoutingEngineP is responsible for computing routes to the roots of a
-tree. In traditional networking terminology, this is part of the
-control plane of the network, and is does not directly forward any
-data packets, which is the responsibility of CtpForwardingEngine.
-The main interface between the two is UnicastNameFreeRouting.</p>
-<p>CtpRoutingEngineP uses the LinkEstimator interface to learn
+<div class="section">
+<h2><a id="treeroutingenginep" name="treeroutingenginep">4.2 TreeRoutingEngineP</a></h2>
+<p>TreeRoutingEngineP is responsible for computing routes to the roots of a
+tree. It uses NeighborTable and LinkEstimator interfaces to learn
about the nodes in the neighbor table maintained by LinkEstimatorP and
the quality of links to and from the neighbors. The routing protocol
on which collection is implemented MUST be a tree-based routing
-protocol with a single or multiple roots. CtpRoutingEngineP
+protocol with a single or multiple roots. TreeRoutingEngineP
allows a node to be configured as a root or a non-root node
-dynamically. CtpRoutingEngineP maintains multiple candidate next hops:</p>
-<pre class="literal-block">
-generic module CtpRoutingEngineP(uint8_t routingTableSize,
- uint16_t minInterval,
- uint16_t maxInterval) {
- provides {
- interface UnicastNameFreeRouting as Routing;
- interface RootControl;
- interface CtpInfo;
- interface StdControl;
- interface CtpRoutingPacket;
- interface Init;
- }
- uses {
- interface AMSend as BeaconSend;
- interface Receive as BeaconReceive;
- interface LinkEstimator;
- interface AMPacket;
- interface LinkSrcPacket;
- interface SplitControl as RadioControl;
- interface Timer<TMilli> as BeaconTimer;
- interface Timer<TMilli> as RouteTimer;
- interface Random;
- interface CollectionDebug;
- interface CtpCongestion;
- }
-}
-</pre>
+dynamically. TreeRoutingEngineP maintains multiple candidate next hops:</p>
<pre class="literal-block">
-interface UnicastNameFreeRouting {
- command am_addr_t nextHop();
-
- command bool hasRoute();
- event void routeFound();
- event void noRoute();
+generic module TreeRoutingEngineP(uint8_t routingTableSize) {
+ provides {
+ interface UnicastNameFreeRouting as Routing;
+ interface RootControl;
+ interface TreeRoutingInspect;
+ interface StdControl;
+ interface Init;
+ }
+ uses {
+ interface AMSend as BeaconSend;
+ interface Receive as BeaconReceive;
+ interface LinkEstimator;
+ interface AMPacket;
+ interface LinkSrcPacket;
+ interface SplitControl as RadioControl;
+ interface Timer<TMilli> as BeaconTimer;
+ interface Random;
+ interface CollectionDebug;
+ }
}
</pre>
</div>
-<div class="section" id="ctpforwardingenginep">
-<h2><a name="ctpforwardingenginep">4.3 CtpForwardingEngineP</a></h2>
-<p>The CtpForwardingEngineP component provides all the top level interfaces
-(except RootControl) which CollectionC provides and an application
-uses. It deals with retransmissions, duplicate suppression, packet
-timing, loop detection, and also informs the LinkEstimator of the
-outcome of attempted transmissions.:</p>
+<div class="section">
+<h2><a id="forwardingenginep" name="forwardingenginep">4.3 ForwardingEngineP</a></h2>
+<p>The ForwardingEngineP component provides all the top level interfaces
+(except RootControl) which TreeCollectionC provides and an application
+uses:</p>
<pre class="literal-block">
-generic module CtpForwardingEngineP() {
+generic module ForwardingEngineP() {
provides {
interface Init;
interface StdControl;
interface Intercept[collection_id_t id];
interface Packet;
interface CollectionPacket;
- interface CtpPacket;
- interface CtpCongestion;
}
uses {
- interface SplitControl as RadioControl;
interface AMSend as SubSend;
interface Receive as SubReceive;
interface Receive as SubSnoop;
interface Packet as SubPacket;
interface UnicastNameFreeRouting;
+ interface SplitControl as RadioControl;
interface Queue<fe_queue_entry_t*> as SendQueue;
interface Pool<fe_queue_entry_t> as QEntryPool;
interface Pool<message_t> as MessagePool;
interface Timer<TMilli> as RetxmitTimer;
- interface LinkEstimator;
- interface Timer<TMilli> as CongestionTimer;
- interface Cache<message_t*> as SentCache;
- interface CtpInfo;
+ interface Cache<uint32_t> as SentCache;
+ interface TreeRoutingInspect;
interface PacketAcknowledgements;
interface Random;
interface RootControl;
}
}
</pre>
-<p>CtpForwardingEngineP uses a large number of interfaces, which can be
+<p>ForwardingEngineP uses a large number of interfaces, which can be
broken up into a few groups of functionality:</p>
<blockquote>
<ul class="simple">
<li>Single hop communication: SubSend, SubReceive, SubSnoop,
SubPacket, PacketAcknowledgments, AMPacket</li>
-<li>Routing: UnicastNameFreeRouting, RootControl, CtpInfo,
-CollectionId, SentCache</li>
+<li>Routing: UnicastNameFreeRouting, TreeRoutingInspect,
+RootControl, CollectionId, SentCache</li>
<li>Queue and buffer management: SendQueue, MessagePool,
QEntryPool</li>
<li>Packet timing: Random, RetxmitTimer</li>
</blockquote>
</div>
</div>
-<div class="section" id="author-s-address">
-<h1><a name="author-s-address">5. Author's Address</a></h1>
+<div class="section">
+<h1><a id="author-s-address" name="author-s-address">5. Author's Address</a></h1>
<div class="line-block">
-<div class="line">Rodrigo Fonseca </div>
+<div class="line">Rodrigo Fonseca</div>
<div class="line">473 Soda Hall</div>
<div class="line">Berkeley, CA 94720-1776</div>
<div class="line"><br /></div>
<div class="line"><br /></div>
<div class="line"><br /></div>
<div class="line">Omprakash Gnawali</div>
-<div class="line">Ronald Tutor Hall (RTH) 418 </div>
+<div class="line">Ronald Tutor Hall (RTH) 418</div>
<div class="line">3710 S. McClintock Avenue</div>
-<div class="line">Los Angeles, CA 90089 </div>
+<div class="line">Los Angeles, CA 90089</div>
<div class="line"><br /></div>
<div class="line">phone - +1 213 821-5627</div>
<div class="line">email - <a class="reference" href="mailto:gnawali@usc.edu">gnawali@usc.edu</a></div>
<div class="line">Kyle Jamieson</div>
<div class="line">The Stata Center</div>
<div class="line">32 Vassar St.</div>
-<div class="line">Cambridge, MA 02139 </div>
+<div class="line">Cambridge, MA 02139</div>
<div class="line"><br /></div>
<div class="line">email - <a class="reference" href="mailto:jamieson@csail.mit.edu">jamieson@csail.mit.edu</a></div>
<div class="line"><br /></div>
<div class="line">email - <a class="reference" href="mailto:pal@cs.stanford.edu">pal@cs.stanford.edu</a></div>
</div>
</div>
-<div class="section" id="citations">
-<h1><a name="citations">6. Citations</a></h1>
+<div class="section">
+<h1><a id="citations" name="citations">6. Citations</a></h1>
<table class="docutils footnote" frame="void" id="id1" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a name="id1">[1]</a></td><td>TEP 116: Packet Protocols</td></tr>
</tbody>
</table>
-<table class="docutils footnote" frame="void" id="id2" rules="none">
-<colgroup><col class="label" /><col /></colgroup>
-<tbody valign="top">
-<tr><td class="label"><a name="id2">[2]</a></td><td>TEP 124: The Collection Tree Protocol (CTP) - (upcoming)</td></tr>
-</tbody>
-</table>
</div>
</div>
</body>
+++ /dev/null
-<!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <title>Lesson T: Simulation with TOSSIM</title>
- <link href="../../stylesheets/tutorial.css" rel="stylesheet" type="text/css">
-</head>
-<body>
-
-$Id$
-
-<div class="title">Lesson T: Simulation with TOSSIM</div>
-<div class="subtitle">Last Modified: Feb 9, 2006</div>
-
- <p>This lesson introduces the TOSSIM simulator. You will become
- familiar with how to compile TOSSIM and use some of its
- functionality. You will learn how to:</p>
-
- <p>
-
- <ul>
-
- <li>Compile TOSSIM.</li>
-
- <li>Configure a simulation in Python and C++.</li>
-
- <li>Inspect variables.</li>
-
- <li>Inject packets.</li>
- </ul>
- </p>
-
-
-<h1>Introduction</h1>
-
- TOSSIM simulates entire TinyOS applications. It works by
- replacing components with simulation implementations. The
- level at which components are replaced is very flexible: for
- example, there is a simulation implementation of millisecond
- timers that replaces HilTimerMilliC, while there is also an
- implementation for atmega128 platforms that replaces the HPL
- components of the hardware clocks. The former is general and
- can be used for any platform, but lacks the fidelity of
- capturing an actual chips behavior, as the latter
- does. Similarly, TOSSIM can replace a packet-level
- communication component for packet-level simulation, or
- replace a low-level radio chip component for a more precise
- simulation of the code execution.
-
- TOSSIM is a discrete event simulator. When it runs, it pulls
- events of the event queue (sorted by time) and executes them.
- Depending on the level of simulation, simulation events can
- represent hardware interrupts or high-level system events
- (such as packet reception). Additionally, tasks are simulation
- events, so that posting a task causes it to run a short time
- (e.g., a few microseconds) in the future.
-
- TOSSIM is a library: you must write a program that configures
- a simulation and runs it. TOSSIM supports two programming
- interfaces, Python and C++. Python allows you to interact with
- a running simulation dynamically, like a powerful
- debugger. However, as the interpretation can be a performance
- bottleneck when obtaining results, TOSSIM also has a C++
- interface. Usually, transforming code from one to the other is
- very simple.
-
- TOSSIM currently does not support gathering power
- measurements.
-
- <h1>Compiling TOSSIM</h1>
-
- <p>TOSSIM is a TinyOS library. Its core code lives in <tt><a
- href="../../../tos/lib/tossim">tos/lib/tossim</a></tt>. Every TinyOS
- source directory has an optional <tt>sim</tt> subdirectory,
- which contains simulation implementations of that package. For
- example, <tt><a
- href="../../../tos/chips/atm128/timersim">tos/chips/atm128/timer/sim</a></tt>
- contains TOSSIM implementations of some of the Atmega128 timer
- abstractions.</p>
-
- <p>To compile TOSSIM, you pass the <tt>sim</tt> option to make:</p>
-
- <pre>
- $ cd apps/Blink
- $ make micaz sim
- </pre>
-
-
-
- <p>Currently, the only platform TOSSIM supports is the
- micaz. You should see output similar to this:</p>
- <pre>
- mkdir -p build/micaz
- placing object files in build/micaz
- writing XML schema to app.xml
- compiling BlinkAppC to object file sim.o
- ncc -c -fPIC -o build/micaz/sim.o -g -O0 -tossim -fnesc-nido-tosnodes=1000 -fnesc-simulate -fnesc-nido-motenumber=sim_node\(\) -finline-limit=100000 -Wall -Wshadow -DDEF_TOS_AM_GROUP=0x7d -Wnesc-all -target=micaz -fnesc-cfile=build/micaz/app.c -board=micasb -Wno-nesc-data-race BlinkAppC.nc -fnesc-dump=components -fnesc-dump=variables -fnesc-dump=constants -fnesc-dump=typedefs -fnesc-dump=interfacedefs -fnesc-dump=tags -fnesc-dumpfile=app.xml
- compiling Python support into pytossim.o and tossim.o
- g++ -c -shared -fPIC -o build/micaz/pytossim.o -g -O0 /home/pal/src/tinyos-2.x/tos/lib/tossim/tossim_wrap.cxx -I/usr/include/python2.3 -I/home/pal/src/tinyos-2.x/tos/lib/tossim -DHAVE_CONFIG_H
- g++ -c -shared -fPIC -o build/micaz/tossim.o -g -O0 /home/pal/src/tinyos-2.x/tos/lib/tossim/tossim.c -I/usr/include/python2.3 -I/home/pal/src/tinyos-2.x/tos/lib/tossim
- linking into shared object ./_TOSSIMmodule.so
- g++ -shared build/micaz/pytossim.o build/micaz/sim.o build/micaz/tossim.o -lstdc++ -o _TOSSIMmodule.so
- copying Python script interface TOSSIM.py from lib/tossim to local directory
- </pre>
-
- <p>Compiling TOSSIM has five basic steps. Let's go through
- them one by one.</p>
-
- <h2>Writing an XML schema</h2>
-
- <pre>
- writing XML schema to app.xml
- </pre>
-
- <p>The first thing the TOSSIM build process does is use
- nesc-dump to produce an XML document that describes the
- application. Among other things, this document descibes the
- name and type of every variable.</p>
-
- <h2>Compiling the TinyOS Application</h2>
-
- <p>Besides introducing all of these new compilation steps, the
- <tt>sim</tt> option changes the include paths of the
- application. If the application has a series of includes</p>
-
- <pre>
- -Ia -Ib -Ic
- </pre>
-
- <p>Then the sim option transforms the list to</p>
-
- <pre>
- -Ia/sim -Ib/sim -Ic/sim -I%T/lib/tossim -Ia -Ib -Ic
- </pre>
-
- <p>This means that any system-specific simulation
- implementations will be used first, followed by generic TOSSIM
- implementations, followed by standard implementations. The
- <tt>sim</tt> option also passes a bunch of arguments to the
- compiler, so it knows to compile for simulation.</p>
-
- <p>The product of this step is an object file, <tt>sim.o</tt>,
- which lives in the platform's build directory. This object
- file has a set of C functions which configure the simulation
- and control execution.</p>
-
- <h2>Compiling the Programming Interface</h2>
-
- <pre>
- compiling Python support into pytossim.o and tossim.o
- g++ -c -shared -fPIC -o build/micaz/pytossim.o -g -O0 \
- /home/pal/src/tinyos-2.x/tos/lib/tossim/tossim_wrap.cxx \
- -I/usr/include/python2.3 -I/home/pal/src/tinyos-2.x/tos/lib/tossim \
- -DHAVE_CONFIG_H
- g++ -c -shared -fPIC -o build/micaz/tossim.o -g -O0 \
- /home/pal/src/tinyos-2.x/tos/lib/tossim/tossim.c \
- -I/usr/include/python2.3 -I/home/pal/src/tinyos-2.x/tos/lib/tossim
- </pre>
-
- <p>The next step compiles the support for the C++ and Python
- programming interfaces. The Python interface is actually built
- on top of the C++ interface. Calling a Python object calls a
- C++ object, which then calls TOSSIM through the C
- interface. <tt>tossim.o</tt> contains the C++ code, while
- <tt>pytossim.o</tt> contains the Python support. These files
- have to be compiled separately because C++ doesn't understand
- nesC, and nesC doesn't understand C++.</p>
-
- <h2>Building the shared object</h2>
-
- <pre>
- linking into shared object ./_TOSSIMmodule.so
- g++ -shared build/micaz/pytossim.o build/micaz/sim.o build/micaz/tossim.o -lstdc++ -o _TOSSIMmodule.so
- </pre>
-
- <p>The next to last step is to build a shared library that
- contains the TOSSIM code, the C++ support, and the Python
- support.</p>
-
- <h2>Copying Python Support</h2>
-
- <pre>
- copying Python script interface TOSSIM.py from lib/tossim to local directory
- </pre>
-
- <p>Finally, there is the Python code that calls into the
- shared object. This code exists in <tt>lib/tossim</tt>, and
- the make process copies it into the local directory.</p>
-
-
- <h1>Running TOSSIM with Python</h1>
-
- <p>Go into the <tt>RadioCountToLeds</tt> application and build
- TOSSIM:</p>
-
- <pre>
-$ cd tinyos-2.x/apps/RadioCountToLeds
-$ make micaz sim
- </pre>
-
- <p>We'll start with running a simulation in Python. You can either
- write a script and just tell Python to run it, or you can
- use Python interactively. We'll start with the latter. Fire
- up your Python interpreter:</p>
-
- <pre>
-$ python
- </pre>
-
- <p>You should see a prompt like this:</p>
-
- <pre>
-Python 2.3.4 (#1, Nov 4 2004, 14:13:38)
-[GCC 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)] on linux2
-Type "help", "copyright", "credits" or "license" for more information.
->>>
- </pre>
-
- <p>The first thing we need to do is import TOSSIM and create a
- TOSSIM object. Type</p>
-
- <pre>
->>> from TOSSIM import *
->>> t = Tossim([])
- </pre>
-
- <p>The square brackets are an optional argument that lets you
- access variables in the simulation. We'll get to how to use
- that later. In this case, we're telling TOSSIM that there are
- no variables that we want to look at. The way you run a TOSSIM
- simulation is with the <tt>runNextEvent</tt> function. For
- example:</p>
-
- <pre>
->>> t.runNextEvent()
-0
- </pre>
-
- <p>When you tell TOSSIM to run the next event, it returns
- 0. This means that there was no next event to run. The reason
- is simple: we haven't told any nodes to boot. This snippet of
- code will tell mote 32 to boot at time 45654 and run its first
- event (booting):</p>
-
- <pre>
->>> m = t.getNode(32);
->>> m.bootAtTime(45654);
->>> t.runNextEVent()
-1
- </pre>
-
- <p>Instead of using raw simulation ticks, you can also use the
- call <t>ticksPerSecond()</tt>. However, you want to be careful
- to add some random bits into this number: having every node
- perfectly synchronized and only different in phase in terms of
- seconds can lead to strange results.</p>
-
- <pre>
->>> m = t.getNode(32);
->>> m.bootAtTime(4 * t.ticksPerSecond() + 242119);
->>> t.runNextEVent()
-1
- </pre>
-
- <p>Now, <tt>runNextEvent</tt> returns 1, because there was an
- event to run. But we have no way of knowing whether the node
- has booted or not. We can find this out in one of two ways.
- The first is that we can just ask it:</p>
-
- <pre>
->>> m.isOn()
-1
->>> m.turnOff()
->>> m.isOn()
-0
->>> m.bootAtTime(560000)
->>> t.runNextEvent()
-0
->>> t.runNextEvent()
-1
- </pre>
-
- <p>Note that the first <tt>runNextEvent</tt> returned 0. This
- is because when we turned the mote off, there was still an
- event in the queue, for its next timer tick. However, since
- the mote was off when the event was handled in that call,
- <tt>runNextEvent</tt> returned 0. The second call to
- <tt>runNextEvent</tt> returned 1 for the second boot event, at
- time 560000.</p>
-
-
- <p>A Tossim object has several useful functions. In Python,
- you can generally see the signature of an object with the
- <tt>dir</tt> function. E.g.:</p>
-
- <pre>
->>> t = Tossim([])
->>> dir(t)
-['__class__', '__del__', '__delattr__', '__dict__', '__doc__', '__getattr__',
-'__getattribute__', '__hash__', '__init__', '__module__', '__new__',
-'__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__',
-'__swig_getmethods__', '__swig_setmethods__', '__weakref__', 'addChannel',
-'currentNode', 'getNode', 'init', 'mac', 'newPacket', 'radio', 'removeChannel',
-'runNextEvent', 'setCurrentNode', 'setTime', 'this', 'thisown', 'time', 'timeStr']
- </pre>
-
- <p>The most common utility functions are:</p>
-
- <ul>
- <li><b>currentNode()</b>: returns the ID of the current node.</li>
- <li><b>getNode(id)</b>: returns an object representing a specific mote</li>
- <li><b>runNextEvent()</b>: run a simulation event</li>
- <li><b>time()</b>: return the current time in simulation ticks as a large integer </li>
- <li><b>timeStr()</b>: return a string representation of the current time</li>
- <li><b>init()</b>: initialize TOSSIM</li>
- <li><b>mac()</b>: return the object representing the media access layer</li>
- <li><b>radio()</b>: return the object representing the radio model</li>
- <li><b>addChannel(ch, output)</b>: add <i>output</i> as an output to channel <i>ch</i> </li>
- <li><b>removeChannel(ch, output)</b>: remove <i>output</i> as an output to channel <i>ch</i> </li>
- <li><b>ticksPerSecond()</b>: return how many simulation ticks there are in a simulated second </li>
- </ul>
-
- <p>The next section discusses the last two.</p>
-
- <h1>Debugging Statements</h1>
-
- <p>The second approach to know whether a node is on is to tell
- it to print something out when it boots. TOSSIM has a
- debugging output system, called <tt>dbg</tt>. There are four
- <tt>dbg</tt> calls:</p>
-
- <ul>
- <li><tt>dbg</tt>: print a debugging statement preceded by the node ID.</li>
- <li><tt>dbg_clear</tt>: print a debugging statement which is not preceded by the node ID. This allows you to easily print out complex data types, such as packets, without interspersing node IDs through the output.</li>
- <li><tt>dbgerror</tt>: print an error statement preceded by the node ID</li>
- <li><tt>dbgerror_clear</tt>: print an error statement which is not preceded by the node ID</li>
- </ul>
-
-
- <p>Go into <tt>RadioCountToLedsC</tt> and modify the <tt>Boot.booted</tt> event
- to print out a debug message when it boots, such as this:</p>
-
- <pre>
-event void Boot.booted() {
- call Leds.led0On();
- dbg("Boot", "Application booted.\n");
- call AMControl.start();
-}
- </pre>
-
- <p>Calls to the debugging calls take two or more
- parameters. The first parameter ("Boot" in the above example)
- defines the output <i>channel</i>. An output channel is simply
- a string. The second and subsequent parameters are the message
- to output. They are identical to a printf statement. For example
- RadioCountToLedsC has this call:
-
- <pre>
-event message_t* Receive.receive(message_t* bufPtr, void* payload, uint8_t len) {
- dbg("RadioCountToLedsC", "Received packet of length %hhu.\n", len);
- ...
-}
- </pre>
-
- which prints out the length of received packet as an 8-bit unsigned value (%hhu).</p>
-
- <p>Once you have added the debugging statement to the event,
- recompile the application with <tt>make micaz sim</tt> and
- start up your Python interpreter. Load the TOSSIM module and
- schedule a mote to boot as before:</p>
-
- <pre>
->>> from TOSSIM import *
->>> t = Tossim([])
->>> m = t.getNode(32);
->>> m.bootAtTime(45654);
- </pre>
-
- <p>This time, however, we want to see the debugging message
- that the mote has booted. TOSSIM's debugging output can be
- configured on a per-channel basis. So, for example, you can
- tell TOSSIM to send the "Boot" channel to standard output, but
- another channel, say "AM", to a file. Additionally, you can
- configureBy default, a channel has no destination, and so
- messages to it are discarded.</p>
-
- <p>In this case, we want to send the Boot channel to standard
- output. To do this, we need to import the <tt>sys</tt> Python
- package, which lets us refer to standard out. We can then tell
- TOSSIM to send Boot messages to this destination:
-
- <pre>
->>> import sys
->>> t.addChannel("Boot", sys.stdout);
-1
- </pre>
-
- The return value shows that the channel was added successfully. Run the first
- simulation event, and the mote boots:
-
- <pre>
->>> t.runNextEvent()
-DEBUG (32): Application booted.
-1
- </pre> </p>
-
- <p>The only difference between debug and error functions is
- the string output at the beginning of a message. Debug
- statements print <tt>DEBUG (n)</tt>, while error statements
- print <tt>ERROR (n)</tt>.</p>
-
- <p>A debugging statement can have multiple output
- channels. Each channel name is delimited by commas:
-
- <pre>
-event void Boot.booted() {
- call Leds.led0On();
- dbg("Boot,RadioCountToLedsC", "Application booted.\n");
- call AMControl.start();
-}
- </pre>
-
- If a statement has multiple channels and those channels
- share outputs, then TOSSIM only prints the message once. For
- example, if both the Boot channel and RadioCountToLedsC
- channel were connected to standard out, TOSSIM will only
- print one message. For example, this series of debug statements
-
-
- <pre>
-event void Boot.booted() {
- call Leds.led0On();
- dbg("Boot,RadioCountToLedsC", "Application booted.\n");
- dbg("RadioCountToLedsC", "Application booted again.\n");
- dbg("Boot", "Application booted a third time.\n");
- call AMControl.start();
-}
- </pre>
-
- when configured so
-
- <pre>
->>> import sys
->>> t.addChannel("Boot", sys.stdout)
->>> t.addChannel("RadioCountToLedsC", sys.stdout)
- </pre>
-
- will print out this:
-
- <pre>
-DEBUG (32): Application booted.
-DEBUG (32): Application booted again.
-DEBUG (32): Application booted a third time.
- </pre></p>
-
-
- <p>A channel can have multiple outputs. For example, this
- script will tell TOSSIM to write RadioCountToLedsC messages to
- standard output, but to write Boot messages to both standard
- output and a file named <tt>log.txt</tt>:
-
- <pre>
->>> import sys
->>> f = open("log.txt", "w")
->>> t.addChannel("Boot", f)
->>> t.addChannel("Boot", sys.stdout)
->>> t.addChannel("RadioCountToLedsC", sys.stdout)
- </pre>
- </p>
-
- <h1>Configuring a Network</h1>
-
- <p>When you start TOSSIM, no node can communicate with any
- other. In order to be able to simulate network behavior, you
- have to specify a <i>network topology</i>. Internally, TOSSIM
- is structured so that you can easily change the underlying
- radio simulation, but that's beyond the scope of this
- tutorial. The default TOSSIM radio model is signal-strength
- based. You provide a graph to the simulator that describes the
- propagation strengths. You also specify noise floor, and
- receiver sensitivity. There are some very early results that
- describe current sensor platforms (e.g., the mica2) in these
- terms. Because all of this is through a scripting interface,
- rather than provide a specific radio model, TOSSIM tries to
- provide a few low-level primitives that can express a wide
- range of radios and behavior.</p>
-
- <p>You control the radio simulation through a Python Radio
- object:</p>
-
-
- <pre>
->>> from TOSSIM import *
->>> t = Tossim([])
->>> r = t.radio()
->>> dir(r)
-['__class__', '__del__', '__delattr__', '__dict__', '__doc__',
-'__getattr__', '__getattribute__', '__hash__', '__init__',
-'__module__', '__new__', '__reduce__', '__reduce_ex__',
-'__repr__', '__setattr__', '__str__', '__swig_getmethods__',
-'__swig_setmethods__', '__weakref__', 'add', 'connected',
-'gain', 'remove', 'setNoise', 'this', 'thisown',
-<class 'TOSSIM.RadioPtr'>]
- </pre>
-
- <p>The first set of methods (with the double underscores) are
- ones that you usually don't call. The important ones are at
- the end. They are:</p>
-
- <ul>
- <li><b>add(src, dest, gain)</b>: Add a link from <i>src</i>
- to <i>dest</i> with <i>gain</i>. When src transmits, dest
- will receive a packet attenuated by the gain value.</li>
-
- <li><b>connected(src, dest)</b>: Return whether there is a
- link from <i>src</i> to <i>dest</i>.</li>
-
-
- <li><b>gain(src, dest)</b>: Return the gain value of the
- link from <i>src</i> to <i>dest</i>.</li>
-
- <li><b>remove(src, dest)</b>: Remove the link from
- <i>src</i> to <i>dest</i>.</li>
-
-
- <li><b>setNoise(node, mean, variance)</b>: Set the noise
- floor at <i>node</i> to be a gaussian distribution with
- <i>mean</i> and <i>variance</i>.</li>
-
- <li><b>sensitivity()</b>: Return the receive sensitivity of
- the nodes.</li>
-
- <li><b>setSensitivity(val)</b>: Set the receive sensitivity
- of nodes to be <i>val</i>. The sensitivity is how much
- stronger a signal must be for it to be received
- uncorrupted. E.g., a sensitivity of 3.0 (the default value)
- means that a packet must be 3dBm greater than the sum of
- noise and concurrent transmissions for it to be received
- uncorrupted.</li>
-
- <li><b>threshold()</b>: Return the CCA threshold.</li>
-
- <li><b>setThreshold(val)</b>: Set the CCA threshold value in
- dBm.The default is -95.</li>
-
- </ul>
-
- <p>The Radio object only deals with physical layer
- propagation. The MAC object deals with the data link layer,
- packet lengths, and radio bandwidth. The default TOSSIM MAC
- object is for a CSMA protocol. You get a reference to the MAC
- object by calling mac() on a Tossim object:
- <pre>
->>> mac = t.mac()
- </pre>
-
- The default MAC object has a large number of functions, for
- controlling backoff behavior, packet preamble length, radio
- bandwidth, etc. All time values are specified in terms of
- radio symbols, and you can configure the number of symbols
- per second and bits per symbol. By default, the MAC object
- is configured to act like the standard TinyOS 2.0 CC2420
- stack: it has 4 bits per symbol and 64k symbols per second,
- for 256kbps. This is a subset of the MAC functions that
- could be useful for changing backoff behavior. Every
- accessor function has a corresponding set function that
- takes an integer as a parameter. E.g., there's <tt>int
- initHigh()</tt> and <tt>void setInitHigh(int val)</tt>. The
- default value for each parameter is shown italicized in
- parentheses. </p>
-
- <ul>
- <li><b>initHigh</b>: The upper bound of the initial backoff range. <i>(400)</i></li>
- <li><b>initLow</b>: The lower bound of the initial backoff range. <i>(20)</i></li>
- <li><b>high</b>: The upper bound of the backoff range. This is multiplied by the
- exponent base to the nth power, where n is the number of previous backoffs. So if the
- node had its initial backoff, then the upper bound is high * base, while if it
- is after the second backoff then the upper bound is high * base * base. <i>(160)</i></li>
- <li><b>low</b>: The lower bound of the backoff range. This is multiplied by the
- exponent base to the nth power, where n is the number of previous backoffs. So if the
- node had its initial backoff, then the upper bound is low * base, while if it
- is after the second backoff then the upper bound is low * base * base. <i>(20)</i></li>
- <li><b>symbolsPerSec</b>: The number of symbols per second that the radio can
- transmit. <i>(65536)</i></li>
- <li><b>bitsPerSymbol</b>: The number of bits per radio symbol. Multiplying this by
- the symbols per second gives the radio bandwidth. <i>(4)</i></li>
- <li><b>preambleLength</b>: How long a packet preamble is. This is added to the duration
- of transmission for every packet. <i>(12)</i></li>
- <li><b>exponentBase</b>: The base of the exponent used to calculate backoff. Setting it to
- 2 provides binary exponential backoff. <i>(0)</i>.</li>
- <li><b>maxIterations</b>: The maximum number of times the radio will back off before
- signaling failure, zero signifies forever. <i>(0)</i>.</li>
- <li><b>minFreeSamples</b>: The number of times the radio must detect a clear channel
- before it will transmit. This is important for protocols like 802.15.4, whose synchonrous
- acknowledgments requires that this be greater than 1 (you could have sampled in the dead time
- when the radios are changing between RX and TX mode). <i>(2)</i></li>
- <li><b>rxtxDelay</b>: The time it takes to change the radio from RX to TX mode (or vice versa).<i>(32)</i></li>
- <li><b>ackTime</b>: The time it takes to transmit a synchonrous acknowledgment, not including the
- requisite RX/TX transition.<i>(34)</i></li>
- </ul>
-
- <p>Any and all of these configuration constants can be changed
- at compile time with #define directives. Look at
- <tt>tos/lib/tossim/sim_csma.h</tt>.</p>
-
- <p>Because the radio connectivity graph can be scripted, you
- can easily store topologies in files and then load the
- file. Alternatively, you can store a topology as a script.
- For example, this script will load a file which specifies each
- link in the graph as a line with three values, the source, the
- destination, and the gain, e.g.:
-
- <pre>
-1 2 -54.0
- </pre>
-
- means that when 1 transmits 2 hears it at -54 dBm. Create a file <tt>topo.txt</tt>
- that looks like this:</p>
-
- <pre>
-1 2 -54.0
-2 1 -55.0
-1 3 -60.0
-3 1 -60.0
-2 3 -64.0
-3 2 -64.0
- </pre>
-
- <p>This script will read such a file:
-
- <pre>
->>> f = open("topo.txt", "r")
->>> lines = f.readlines()
->>> for line in lines:
-... s = line.split()
-... if (len(s) > 0):
-... print " ", s[0], " ", s[1], " ", s[2];
-... r.add(int(s[0]), int(s[1]), float(s[2]))
- </pre></p>
-
-
- <p>Now, when a node transmits a packet, other nodes will hear it.
- This is a complete script for simulating packet transmission with
- RadioCountToLedsC. Save it as a file <tt>test.py</tt>:</p>
- <pre>
-from TOSSIM import *
-import sys
-
-t = Tossim([])
-r = t.radio()
-f = open("topo.txt", "r")
-
-lines = f.readlines()
-for line in lines:
- s = line.split()
- if (len(s) > 0):
- print " ", s[0], " ", s[1], " ", s[2];
- r.add(int(s[0]), int(s[1]), float(s[2]))
-
-t.addChannel("RadioCountToLedsC", sys.stdout)
-t.addChannel("Boot", sys.stdout)
-
-t.getNode(1).bootAtTime(100001);
-t.getNode(2).bootAtTime(800008);
-t.getNode(3).bootAtTime(1800009);
-
-r.setNoise(1, -100.0, 5.0)
-r.setNoise(2, -100.0, 5.0)
-r.setNoise(3, -100.0, 5.0)
-
-for i in range(0, 100):
- t.runNextEvent()
- </pre>
-
- <p>Run it by typing <tt>python test.py</tt>. You should see
- output that looks like this:</p>
-
- <pre>
-1 2 -54.0
-2 1 -55.0
-1 3 -60.0
-3 1 -60.0
-2 3 -64.0
-3 2 -64.0
-DEBUG (1): Application booted.
-DEBUG (1): Application booted again.
-DEBUG (1): Application booted a third time.
-DEBUG (2): Application booted.
-DEBUG (2): Application booted again.
-DEBUG (2): Application booted a third time.
-DEBUG (3): Application booted.
-DEBUG (3): Application booted again.
-DEBUG (3): Application booted a third time.
-DEBUG (1): RadioCountToLedsC: timer fired, counter is 1.
-DEBUG (1): RadioCountToLedsC: packet sent.
-DEBUG (2): RadioCountToLedsC: timer fired, counter is 1.
-DEBUG (2): RadioCountToLedsC: packet sent.
-DEBUG (3): RadioCountToLedsC: timer fired, counter is 1.
-DEBUG (3): RadioCountToLedsC: packet sent.
-DEBUG (1): Received packet of length 2.
-DEBUG (3): Received packet of length 2.
-DEBUG (2): Received packet of length 2.
-DEBUG (1): RadioCountToLedsC: timer fired, counter is 2.
-DEBUG (1): RadioCountToLedsC: packet sent.
-DEBUG (2): RadioCountToLedsC: timer fired, counter is 2.
-DEBUG (2): RadioCountToLedsC: packet sent.
-DEBUG (3): RadioCountToLedsC: timer fired, counter is 2.
-DEBUG (3): RadioCountToLedsC: packet sent.
-DEBUG (1): Received packet of length 2.
- </pre>
-
- <p>If you set the noise to be 30 plus or minus 5 dBm instead
- of 80 plus or minus 5 dBm, then nodes will never transmit, as
- the default CCA threshold is -95 dBm. You'll see something
- like this:</p>
- <pre>
-1 2 -54.0
-2 1 -55.0
-1 3 -60.0
-3 1 -60.0
-2 3 -64.0
-3 2 -64.0
-DEBUG (1): Application booted.
-DEBUG (1): Application booted again.
-DEBUG (1): Application booted a third time.
-DEBUG (2): Application booted.
-DEBUG (2): Application booted again.
-DEBUG (2): Application booted a third time.
-DEBUG (3): Application booted.
-DEBUG (3): Application booted again.
-DEBUG (3): Application booted a third time.
-DEBUG (1): RadioCountToLedsC: timer fired, counter is 1.
-DEBUG (1): RadioCountToLedsC: packet sent.
-DEBUG (2): RadioCountToLedsC: timer fired, counter is 1.
-DEBUG (2): RadioCountToLedsC: packet sent.
-DEBUG (3): RadioCountToLedsC: timer fired, counter is 1.
-DEBUG (3): RadioCountToLedsC: packet sent.
-DEBUG (1): RadioCountToLedsC: timer fired, counter is 2.
-DEBUG (2): RadioCountToLedsC: timer fired, counter is 2.
-DEBUG (3): RadioCountToLedsC: timer fired, counter is 2.
- </pre>
-
- <p>Because the nodes backoff perpetually, they never transmit
- the packet and so subsequent attempts to send fail. Although
- it only takes a few simulation events to reach the first timer
- firings, it takes many simulation events (approximately 4000)
- to reach the second timer firings. This is because the nodes
- have MAC backoff events. If you want to simulate in terms of
- time, rather than events, you can always do something like
- this, which simulates 5 seconds from the first node boot:</p>
-
- <pre>
-t.runNextEvent();
-time = t.time()
-while (time + 50000000000 > t.time()):
- t.runNextEvent()
-</pre>
-
- <p>TOSSIM allows you to specify a network topology in terms of
- gain. However, this raises the problem of coming up with a
- topology. There are two approaches you can take. The first is
- to take data from a real world network and input this into
- TOSSIM. The second is to generate it from applying a
- theoretical propagation model to a physical layout. TOSSIM has
- an example of the first from the <A
- HREF="https://mirage.berkeley.intel-research.net/">Mirage
- testbed</A> at Intel Research Berkeley. The network topology
- is from data gathered from one hundred micaZ nodes over an
- eight hour period in February 2006. It can be found in <tt><A
- HREF="../../../tos/lib/tossim/topologies/mirage-1.txt">tos/lib/tossim/topologies/mirage-1.txt</A></tt>, and has the following format:
-
- <pre>
-noise n avg std
-gain src dest g
- </pre>
-
- where each statement is on a separate line. The <i>noise</i>
- statement defines the noise observed at node <i>n</i> with
- an average of <i>avg</i> and a standard deviation of
- <i>std</i>. The <i>gain</i> statement defines a propagation
- gain <i>g</i> when <i>src</i> transmits to <i>dest</i>. This
- is a snippet of python code that will parse this file
- format:
-
- <pre>
-f = open("mirage-1.txt", "r")
-
-lines = f.readlines()
-for line in lines:
- s = line.split()
- if (len(s) > 0):
- if (s[0] == "gain"):
- r.add(int(s[1]), int(s[2]), float(s[3]))
- elif (s[0] == "noise"):
- r.setNoise(int(s[1]), float(s[2]), float(s[3]))
- </pre></p>
-
- <p>TOSSIM has a tool for the second option of generating a
- network topology using a theoretical propagation model. The
- tool is written in Java and is
- <tt>net.tinyos.sim.PropagationModel</tt>. The tool takes a
- single command line parameter, the name of a configuration
- file, e.g.:</p>
-
- <pre>
-java net.tinyos.sim.PropagationModel config.txt
- </pre>
-
- <p>The format of a configuration file is beyond the scope of
- this document: the tool has its own <A
- HREF="">documentation</A>. TOSSIM has two sample configuration
- files generated from the tool in
- <tt>tos/lib/tossim/topologies</tt>. The first is <tt><A
- HREF="">grid.txt</A></tt>, which is a 10x10 grid of nodes
- spaced roughly 40 feet apart. Each node is placed randomly
- within a 40'x40' "cell." The cells follow a strict grid. The
- second file is <tt><A HREF="">scatter.txt</A></tt>, which is
- 100 nodes scattered randomly (with a uniform distribution)
- over a 360'x360' area. Note that the tool uses random numbers,
- these configuration files can generate multiple different
- network topologies. Network topology files generated from the
- tool follow the same format as <tt>mirage-1.txt</tt>.</p>
-
- <h1>Variables</h1>
-
- <p>TOSSIM allows you to inspect variables in a running TinyOS
- program. Currently, you can only inspect basic types. For
- example, you can't look at fields of structs, but you can look
- at state variables.</p>
-
- <p>When you compile TOSSIM, the make system generates a large
- XML file that contains a lot of information about the TinyOS
- program, including every component variable and its type. If
- you want to examine the state of your program, then you need
- to give TOSSIM this information so it can parse all of the
- variables properly. You do this by instantiating a Python
- object that parses the XML file to extract all of the relevant
- information. You have to import the Python support package for
- TOSSIM to do this:</p>
-
- <pre>
-from tinyos.tossim.TossimApp import *
-
-n = NescApp()
- </pre>
-
- <p>Instantiating a <tt>NescApp</tt> can take quite a while:
- Python has to parse through megabytes of XML. So be patient
- (you only have to do it once). NescApp has two optional
- arguments. The first is the name of the application being
- loaded. The second is the XML file to load. The default for
- the latter is <tt>app.xml</tt>, which is the name of the file
- that the make system generates. The default for the former is
- "Unknown App." So this code behaves identically to that
- above:</p>
-
- <pre>
-from tinyos.tossim.TossimApp import *
-
-n = NescApp("Unknown App", "app.xml")
- </pre>
-
- <p>You fetch a list of variables from a NescApp object by
- calling the function <tt>variables</tt> on the field
- <tt>variables</tt>:</p>
-
- <pre>
-vars = n.variables.variables()
- </pre>
-
- <p>To enable variable inspection, you pass this list to a
- Tossim object when you instantiate it:</p>
-
- <pre>
-t = Tossim(vars)
- </pre>
-
- <p>The TOSSIM object now knows the names, sizes, and types of
- all of the variables in the TinyOS application. This
- information allows the TOSSIM support code to take C variables
- and properly tranform them into Python variables. This
- currently only works for simple types: if a component declares
- a structure, you can't access its fields. But let's say we
- want to read the counter in RadioCountToLedsC. Since each mote
- in the network has its own instance of the variable, we need
- to fetch it from a specific mote:</p>
-
- <pre>
-m = t.getNode(0)
-v = m.getVariable("RadioCountToLedsC.counter")
- </pre>
-
- <p>The name of a variable is usually <i>C.V</i>, where
- <i>C</i> is the component name and <i>V</i> is the variable.
- In the case of generic components, the name is <i>C.N.V</i>,
- where <i>N</i> is an integer that describes which instance.
- Unfortunately, there is currently no easy way to know what
- <i>N</i> is from nesC source, so you have to root through
- <tt>app.c</tt> in order to know.</p>
-
- <p>Once you have a variable object (<tt>v</tt> in the above
- code), you can fetch its value with the <tt>getData()</tt>
- function:</p>
-
- <pre>
-counter = v.getData()
- </pre>
-
- <p>Because <tt>getData()</tt> transforms the underlying C type
- into a Python type, you can then use its return value in
- Python expressions. For example, this script will start a
- simulation of five nodes and run it until node 0's counter
- reaches 10:</p>
-
- <pre>
-from sys import *
-from random import *
-from TOSSIM import *
-from tinyos.tossim.TossimApp import *
-
-n = NescApp()
-t = Tossim(n.variables.variables())
-r = t.radio()
-
-f = open("topo.txt", "r")
-lines = f.readlines()
-for line in lines:
- s = line.split()
- if (len(s) > 0):
- if (s[0] == "gain"):
- r.add(int(s[1]), int(s[2]), float(s[3]))
- elif (s[0] == "noise"):
- r.setNoise(int(s[1]), float(s[2]), float(s[3]))
-
-for i in range (0, 9):
- m = t.getNode(i)
- m.bootAtTime(randint(1000, 2000) * 1000000)
-
-m = t.getNode(0)
-v = m.getVariable("RadioCountToLedsC.counter")
-
-while (v.getData() < 10):
- t.runNextEvent()
-
- </pre>
-
- <p>The TOSSIM <A
- HREF="../../../tos/lib/tossim/examples">examples</A>
- subdirectory also has an example script, named
- <tt>variables.py</tt>.</p>
-
- <h1>Injecting Packets</h1>
-
- <p>TOSSIM allows you to dynamically inject packets into a
- network. Packets can be scheduled to arrive at any time. If a
- packet is scheduled to arrive in the past, then it arrives
- immediately. Injected packets circumvent the radio stack: it is
- possible for a node to receive an injected packet while it is in
- the midst of receiving a packet from another node over its
- radio.</p>
-
- <p>TinyOS 2.0 has support for building Python packet objects.
- Just like the standard Java toolchain, you can build a packet
- class based on a C structure. The packet class gives you a full
- set of packet field mutators and accessors. If an application
- has a packet format, you can generate a packet class for it,
- instantiate packet objects, set their fields, and have nodes
- receive them.</p>
-
- <p>The <tt>RadioCountToLeds</tt> application Makefile has an
- example of how to do this. First, it adds the Python class as a
- dependency for building the application. Whenever you compile
- the app, if the Python class doesn't exist, make will build it
- for you:</p>
-
- <pre>
-BUILD_EXTRA_DEPS = RadioCountMsg.py RadioCountMsg.class
- </pre>
-
- <p>The Makefile also tells make how to generate RadioCountMsg.py:</p>
-
- <pre>
-RadioCountMsg.py: RadioCountToLeds.h
- mig python -target=$(PLATFORM) $(CFLAGS) -python-classname=RadioCountMsg RadioCountToLeds.h RadioCountMsg -o $@
- </pre>
-
- <p>The rule says to generate RadioCountMsg.py by calling mig
- with the python parameter. The Makefile also has rules on how
- to build Java class, but that's not important for TOSSIM. Since
- we've been using RadioCountToLeds so far, the Python class
- should be there already.</p>
-
- <p>RadioCountMsg.py defines a packet format, but this packet is
- contained in the data payload of another format. If a node is
- sending a RadioCountMsg over AM, then the RadioCountMsg
- structure is put into the AM payload, and might look something
- like this:</p>
-
- <center>
- <table BORDER=1>
- <TR>
- <TD WIDTH=100 BGCOLOR="#ffa0a0">AM Header</TD>
- <TD WIDTH=100 BGCOLOR="white">RadioCountMsg</TD>
- <TD WIDTH=100 BGCOLOR="#ffa0a0">AM Footer</TD>
- </TR>
- </table>
- </center>
-
- <p>If it is sending it over a routing protocol. the packet is
- put in the routing payload, and might look something like this:</p>
-
- <center>
- <table BORDER=1>
- <TR>
- <TD WIDTH=100 BGCOLOR="#ffa0a0">AM Header</TD>
- <TD WIDTH=100 BGCOLOR="#00a0ff">Routing Header</TD>
- <TD WIDTH=100 BGCOLOR="white">RadioCountMsg</TD>
- <TD WIDTH=100 BGCOLOR="#ffa0a0">AM Footer</TD>
- </TR>
- </table>
- </center>
-
- <p>If you want to send a RadioCountMsg to a node, then you need
- to decide how to deliver it. In the simple AM case, you place
- the RadioCountMsg structure in a basic AM packet. In the routing
- case, you put it in a routing packet, which you then put inside
- an AM packet. We'll only deal with the simple AM case here.</p>
-
- <p>To get an AM packet which you can inject into TOSSIM, you
- call the <tt>newPacket</tt> function on a Tossim object. The
- returned object has the standard expected AM fields:
- <i>destination</i>, <i>length</i>, <i>type</i>, and <i>data</i>,
- as well as <i>strength</i>.</p>
-
- <p>To include support for a packet format, you must import
- it. For example, to include RadioCountMsg, you have to import
- it:</p>
-
- <pre>
-from RadioCountMsg import *
- </pre>
-
- <p>This snippet of code, for example, creates a RadioCountMsg,
- sets its counter to 7, creates an AM packet, stores the
- RadioCountMsg in the AM packet, and configures the AM packet so
- it will be received properly (destination and type):</p>
-
- <pre>
-from RadioCountMsg import *
-
-msg = RadioCountMsg()
-msg.set_counter(7);
-pkt = t.newPacket();
-pkt.setData(msg.data)
-pkt.setType(msg.get_amType())
-pkt.setDestination(0)
- </pre>
-
-
- <p>The variable <tt>pkt</tt> is now an Active Message of the AM
- type of RadioCountMsg with a destination of 0 that contains a
- RadioCountMsg with a counter of 7. You can deliver this packet
- to a node with the <tt>deliver</tt> function. The
- <tt>deliver</tt> function takes two parameters, the destination
- node and the time to deliver:</p>
-
- <pre>
-pkt.deliver(0, t.time() + 3)
- </pre>
-
- <p>This call delivers pkt to node 0 at the current simulation
- time plus 3 ticks (e.g., 3ns). There is also a
- <tt>deliverNow</tt>, which has no time parameter. Note that if
- the destination of <tt>pkt</tt> had been set to 1, then the
- TinyOS application would not receive the packet, as it was
- delivered to node 0.</p>
-
- <p>Taken all together, the following script starts a simulation,
- configures the topology based on topo.txt, and delivers a packet
- to node 0. It can also be found as <tt>packets.py</tt> in the TOSSIM <A
- HREF="../../../tos/lib/tossim/examples/">examples</A>
- subdirectory.
-
-
- <pre>
-import sys
-from TOSSIM import *
-from RadioCountMsg import *
-
-t = Tossim([])
-m = t.mac();
-r = t.radio();
-
-t.addChannel("RadioCountToLedsC", sys.stdout);
-t.addChannel("LedsC", sys.stdout);
-
-for i in range(0, 2):
- m = t.getNode(i);
- m.bootAtTime((31 + t.ticksPerSecond() / 10) * i + 1);
-
-f = open("topo.txt", "r")
-lines = f.readlines()
-for line in lines:
- s = line.split()
- if (len(s) > 0):
- if (s[0] == "gain"):
- r.add(int(s[1]), int(s[2]), float(s[3]))
- elif (s[0] == "noise"):
- r.setNoise(int(s[1]), float(s[2]), float(s[3]))
-
-for i in range(0, 60):
- t.runNextEvent();
-
-msg = RadioCountMsg()
-msg.set_counter(7);
-pkt = t.newPacket();
-pkt.setData(msg.data)
-pkt.setType(msg.get_amType())
-pkt.setDestination(0)
-
-print "Delivering " + msg.__str__() + " to 0 at " + str(t.time() + 3);
-pkt.deliver(0, t.time() + 3)
-
-
-for i in range(0, 20):
- t.runNextEvent();
- </pre>
-
-
- <h1>C++</h1>
-
- <p>Python is very useful because it is succinct, easy to write,
- and can be used interactively. Interpretation, however, has a
- significant cost: a Python/C transition on every event is a
- significant cost (around 100%, so it runs at half the
- speed). Additionally, it's often useful to step through code
- with a standard debugger. TOSSIM also has support for C++, so
- that it can be useful in these circumstances. Because many of
- the Python interfaces are merely wrappers around C++ objects,
- much of the scripting stays the same. The two major exceptions
- are inspecting variables and injecting packets.</p>
-
- <p>In a C++ TOSSIM, there is no variable inspection. While it is
- possible to request memory regions and cast them to the expected
- structures, currently there is no good and simple way to do
- so. The Python support goes through several steps in order to
- convert variables into Python types, and this gets in the way of
- C++. However, as the purpose of C++ is usually to run high
- performance simulations (in which inspecting variables is a big
- cost) or debugging (when you have a debugger), this generally
- isn't a big problem.</p>
-
- <p>There is a C++ <tt>Packet</tt> class, which the Python
- version is a simple wrapper around. In order to inject packets
- in C++, however, you must build C support for a packet type and
- manually build the packet. There currently is no support in mig
- with which to generate C/C++ packet structures, and since most
- packets are nx_struct types, they cannot be parsed by
- C/C++. Furthermore, as many of the fields are nx types, they are
- big endian, while x86 processors are little endian. Still, if you
- want to deliver a packet through C++, you can do so.</p>
-
- <p>Usually, the C++ and Python versions of a program look pretty
- similar. For example:</p>
-
- <table WIDTH=800>
-
- <TR><TD WIDTH=400><TD WIDTH=400></TR>
- <TR><TD ALIGN=CENTER><b>Python</b></TD><TD ALIGN=CENTER><b>C++</b></TD></TR>
- <TR>
- <TD VALIGN=TOP>
- <PRE>
-import TOSSIM
-import sys
-
-from RadioCountMsg import *
-
-t = TOSSIM.Tossim([])
-r = t.radio();
-
-for i in range(0, 999):
- m = t.getNode(i);
- m.bootAtTime(5000003 * i + 1);
- r.setNoise(i, -99.0, 3.0);
- for j in range (0, 2):
- if (j != i):
- r.add(i, j, -50.0);
-
-
-
-
-for i in range(0, 1000000):
- t.runNextEvent();
- </PRE>
- </TD>
- <TD VALIGN=TOP>
- <PRE>
-#include <tossim.h>
-
-
-
-int main() {
- Tossim* t = new Tossim(NULL);
- Radio* r = t->radio();
-
- for (int i = 0; i < 999; i++) {
- Mote* m = t->getNode(i);
- m->bootAtTime(5000003 * i + 1);
- r->setNoise(i, -99.0, 3);
- for (int j = 0; j < 2; j++) {
- if (i != j) {
- r->add(i, j, -50.0);
- }
- }
- }
-
- for (int i = 0; i < 1000000; i++) {
- t->runNextEvent();
- }
-}
- </PRE>
- </TD>
- </TR>
- </TABLE>
-
- <p>To compile a C++ TOSSIM, you have to compile the top-level
- driver program (e.g, the one shown above) and link it against
- TOSSIM. Usually the easiest way to do this is to link it against
- the TOSSIM objects rather than the shared library. Often, it's
- useful to have a separate Makefile to do this with. E.g.,
- <tt>Makefile.Driver</tt>:</p>
-
- <pre>
-all:
- make micaz sim
- g++ -g -c -o Driver.o Driver.c -I../../tos/lib/tossim/
- g++ -o Driver Driver.o build/micaz/tossim.o build/micaz/sim.o
- </pre>
-
-
-
-<h1>Conclusions</h1>
-
-This lesson introduced the basics of the TOSSIM simulator. It showed
-you how to configure a network, how to run a simulation, how to
-inspect variables, how to inject packets, and how to compile with C++.
-
-
-<p><b><a href="lesson6.html">Next Lesson ></a></b> | <b><a
- href="index.html">Top</a></b>
-
-</body>
-</html>
</center>
<p>Type:
-<pre>make mica2 reinstall mib510 MIB510=<i>serialport</i></pre>
+<pre>make mica2 reinstall mib510,<i>serialport</i></pre>
where <i>serialport</i> is the serial port device name. Under Windows, if
your serial port is <tt>COM<i>n</i>:</tt>, you must use
<tt>/dev/ttyS<i>n-1</i></tt> as the device name. On Linux, the device name
it at installation. For example, if you type <tt>make telosb install.5</tt>
or <tt>make telosb reinstall.5</tt>, you will install the application
on a node and give it 5 as its identifier.</b></p>
+
+<p>For more information on the build system, please see <a
+href="lesson13.html">Lesson 13</a>.
<h1>Components and Interfaces</h1>
topology. There are two approaches you can take. The first is
to take data from a real world network and input this into
TOSSIM. The second is to generate it from applying a
- theoretical propagation model to a physical layout. TOSSIM has
- an example of the first from the <A
- HREF="https://mirage.berkeley.intel-research.net/">Mirage
- testbed</A> at Intel Research Berkeley. The network topology
- is from data gathered from one hundred micaZ nodes over an
- eight hour period in February 2006. It can be found in <code><A
- HREF="../../../tos/lib/tossim/topologies/mirage-1.txt">tos/lib/tossim/topologies/mirage-1.txt</A></code>, and has the following format:
+ theoretical propagation model to a physical layout. The standard
+ file format is
<pre>
noise n avg std
<p>The format of a configuration file is beyond the scope of
this document: the tool has its own <A
- HREF="">documentation</A>. TOSSIM has two sample configuration
+ HREF="usc-topologies.html">documentation</A>. TOSSIM has two sample configuration
files generated from the tool in
<code>tos/lib/tossim/topologies</code>. The first is <code><A
HREF="">grid.txt</A></code>, which is a 10x10 grid of nodes
inspect variables, how to inject packets, and how to compile with C++.
-<p><b><a href="lesson5.html">< Previous Lesson</a></b> | <b><a
+<p><b><a href="lesson5.html">< Previous Lesson</a></b>
+ |
+<b><a href="lesson13.html">Next Lesson </a> ></b>
+<b><a
href="index.html">Top</a></b>
</body>
passed at the command line, it prints out the packet. You
should see output like this:</p>
-<pre></pre>
+<pre>
+1152232617609: Message <BlinkToRadioMsg>
+ [nodeid=0x2]
+ [counter=0x1049]
+
+1152232617609: Message <BlinkToRadioMsg>
+ [nodeid=0x2]
+ [counter=0x104a]
+
+1152232617609: Message <BlinkToRadioMsg>
+ [nodeid=0x2]
+ [counter=0x104b]
+
+1152232617621: Message <BlinkToRadioMsg>
+ [nodeid=0x2]
+ [counter=0x104c]
+</pre>
<h1>SerialForwarder and other packet sources</h1>
href="index.html">Top</a></b> | <b><a href="lesson5.html">Next Lesson </a> ></b>
</center>
+
+<h1>CLASSPATH and Java classes</h1>
+
+<p>Note that the CLASSPATH variable points to <tt>tinyos.jar</tt>. This
+means that when Java looks for classes to load, it looks in tinyos.jar rather
+than the Java directories in <tt>support/sdk/java</tt>. Therefore,
+if you change and recompile the Java classes, you will not see the changes,
+as Java will only look at the jar file. To regenerate the
+jar from the Java code, go to <tt>support/sdk/java</tt> and type
+<tt>make tinyos.jar</tt>.
</body>
</html>
TinyOS 1.x applications such as <code>Oscilloscope</code> or <code>Sense</code>
used the <code>ADC</code> and <code>ADCControl</code> interfaces to collect
sensor data. When new platforms appeared with sensors that were read out via
-the serial interface, not only additional interfaces like <code>ADCError</code>
-had to be introduced, but it became clear that equating a sensor with an ADC is
-difficult.
+the serial interface, not only did additional interfaces like <code>ADCError</code>
+have to be introduced, but it became clear that equating a sensor with an ADC was
+not always the appropriate thing to do.
<p> Usually sensing involves two tasks: configuring a sensor (and/or the
hardware module it is attached to, for example an ADC or SPI) and reading the
sensor data. The first task is tricky, because a sensing application like, for
example, <code>Sense</code> is meant to run on any TinyOS platform. How can
<code>Sense</code> know the configuration details (e.g. input channel, the
-required reference voltage, etc.) of an attached sensor ? It can't, because the
-configuration details of, for example, the light sensor on the <i>tmote</i>
-platform will be different from the <i>eyes</i> platform. Unless
-<code>Sense</code> knows about all sensors on all platforms it can't perform
-the configuration task, since the interfaces for the configuration of a sensor
+required reference voltage, etc.) of an attached sensor? It can't, because the
+configuration details of sensors will be different from platform to platform,
+i.e. (the light sensor on the <i>tmote</i> and the one on the <i>eyes</i> platform.
+Unless <code>Sense</code> knows about all sensors on all platforms it will be unable to
+perform the configuration task since the interfaces for the configuration of a sensor
will differ from platform to platform (and potentially from sensor to sensor).
However, the second task - reading the sensor data - can be solved so that the
<code>Sense</code> application can collect sensor data even though it is
<p> In TinyOS 2.0 <i>platform independent</i> sensing applications such as
<code>Oscilloscope</code>, <code>Sense</code> or <code>RadioSenseToLeds</code>
-are not using configuration interfaces like <code>ADCControl</code> anymore;
-instead they are only using the standard data acquisition interfaces
+do not use configuration interfaces like <code>ADCControl</code> anymore;
+instead they use the standard data acquisition interfaces
<code>Read</code>, <code>ReadStream</code> or <code>ReadNow</code> for
collecting sensor data. All configuration details are hidden from the
application and this is why you can compile <code>Sense</code> and display
<ul>
<li> Since the <code>Sense</code> application component only uses standard
-data acquisition interfaces who defines what sensor it samples ?
+data acquisition interfaces who is in charge of defining which sensor it samples?
<li> If the <code>Sense</code> application component is not configuring the
-sensor, who is responsible for that ?
+sensor, then who is responsible for that?
-<li> How can an application like <code>Sense</code> display sensor data when it
-does not know the details about sensor configuration ? This includes questions
+<li> How can an applications like <code>Sense</code> display sensor data when they
+do not know the details about sensor configuration? This includes questions
like "what is the value range of the sensor data" or "is a temperature reading
-to be interpreted in degree Celsius or Fahrenheit" ?
+to be interpreted in degrees Celsius or Fahrenheit"?
<li> Let's assume there are several sensors on a platform: what steps have to
-be done to let the <code>Sense</code> or <code>Oscilloscope</code> application
-display data of a different sensor ?
+be taken to let the <code>Sense</code> or <code>Oscilloscope</code> application
+display data from a different sensor?
</ul>
Using the <code>Sense</code> and <code>Oscilloscope</code> application as an
example, the following sections explain how the data acquisition interfaces are
used, how the configuration procedure works and, as an example, how
-<code>Sense</code> can be hooked up to a different than the default sensor on
+<code>Sense</code> can be hooked up to sensors other than the default one on
the <i>telosb</i> platform.
<a name="sense"><h1>The Sense application</h1></a>
What you see above is a <i>generic interface definition</i>, because the
<code>Read</code> interface takes a type parameter. Generic interfaces are
explained in the nesC Language Reference Manual (version 1.2 and above).
-Here it is enough to know that generic interfaces have at least one type
+For now it is enough to know that generic interfaces have at least one type
parameter and two components can be wired together only if they provide/use the
interface with the same types (note that the <code>readDone</code> event passes
a parameter of the <code><val_t></code> parameter, which is a placeholder
nesC compiler.
<p>Recall that the wiring is defined in the <code>SenseAppC.nc</code>
-configuration. Let's again take a look, which component <code>SenseC.nc</code>
-is wired to with the <code>Read<uint16_t></code> interface in the
+configuration. Let's again take a look at which component <code>SenseC.nc</code>
+is wired to using the <code>Read<uint16_t></code> interface in the
<code>SenseAppC</code> configuration. The interesting lines are
<pre>
</pre>
This means that the <i>generic</i> <code>DemoSensorC</code> component provides
-the <code>Read<uint16_t></code> interface to <code>SenseC.nc</code> (a
-<i>generic component</i> is a component that can be instantiated more than once
-and can take constant and type arguments; each instantiation is a
-different component).
+the <code>Read<uint16_t></code> interface to <code>SenseC.nc</code>
<p> It is important to understand that the <code>SenseC.nc</code> module has no
way of telling which sensor it is connected to; in fact it cannot even tell
sensorboard the <code>DemoSensorC</code> component could simply return constant
values. The last sentence hints that the <code>DemoSensorC</code> component is
different for every platform: therefore you will not find
-<code>DemoSensorC.nc</code> in the TinyOS libraries. Instead
-<code>DemoSensorC.nc</code> has to be written for every platform, because, for
-example, on the <i>telosb</i> platform <code>DemoSensorC</code> needs to be
-implemented differently than on the the <i>micaz</i> platform. This is the
+<code>DemoSensorC.nc</code> in the TinyOS libraries. Instead, a different
+<code>DemoSensorC.nc</code> has to be written for every platform, i.e. the
+<code>DemoSensorC.nc</code> implementation for telosb will be different than
+the <code>DemoSensorC.nc</code> implementation for micaz. This is the
answer to the first question asked in the <a
-href="#introduction">introduction</a>: the <i>platform dependent</i>
+href="#introduction">introduction</a> section: the <i>platform dependent</i>
<code>DemoSensorC</code> component defines which sensor the <code>Sense</code>
or <code>Oscilloscope</code> application is sampling and every platform that
wants to run sensing applications such as <code>Oscilloscope</code>,
<code>Sense</code> or <code>RadioSenseToLeds</code> has to provide its own
version of <code>DemoSensorC</code>. Additionally, sensor boards may come
with their own version of <code>DemoSensorC</code> (e.g., the
-<code>basicsb</code> sensorboard for the mica-family of motes is defined to
-be that board's light sensor).
+<code>basicsb</code> sensorboard for the mica-family of motes define
+<code>DemoSensorC.nc</code> to be that board's light sensor).
<a name="demosensorc"><h2>The DemoSensorC component</h2></a>
<code>Oscilloscope</code>. Usually the configuration of a sensor is done in the
component that <code>DemoSensorC</code> instantiates.
-<p> How can <code>Sense</code> be changed to sample another than the platform's
+<p> How can <code>Sense</code> be changed to sample a sensor other than the platform's
default sensor? Usually this requires changing only a single line of code in
<code>DemoSensorC</code>; for example, if you wanted to replace the
<code>VoltageC</code> component on <i>telosb</i> by the constant sensor
-component <code>ConstantSensorC</code> you could change (in
-<code>DemoSensorC</code>)
+component <code>ConstantSensorC</code> you could change the follwoing line in
+<code>DemoSensorC</code> from:
<pre>
components new VoltageC() as DemoSensor;
To compile the <code>Sense</code> application, go to the
<code>apps/Sense</code> directory and depending on which hardware you have,
-type e.g. <code>make telosb install</code>. If you get errors like the
-following
+type something similar to <code>make telosb install</code>. If you get errors such as
+the following,
<pre>
SenseAppC.nc:50: component DemoSensorC not found
SenseAppC.nc:55: no match
</pre>
-your platform has not implemented the <code>DemoSensorC</code> component. For a
+your platform has not yet implemented the <code>DemoSensorC</code> component. For a
quick solution you can copy <code>DemoSensorC.nc</code> from
<code>tinyos-2.x/tos/platforms/micaz</code> to your platform directory; then
you will see constant "sensor" readings (a good starting point on how to create
<p> Once you have installed the application the three most significant bits of
the sensor readings are displayed on the node's LEDs (0 = off, 1 = on). If your
<code>DemoSensorC</code> represents a sensor whose readings are fluctuating
-greatly you may see the LEDs toggle, otherwise <code>Sense</code> is not so
-impressive. Let's have a look at a more interesting application:
+greatly you may see the LEDs toggle, otherwise <code>Sense</code> does not seem to
+be very impressive. Let's take a look at a more interesting application:
<code>Oscilloscope</code>.
<a name="oscilloscope"><h1>The Oscilloscope application</h1></a>
<code>Oscilloscope</code> is a combination of different building blocks
introduced in previous parts of the tutorial. Like <a
-href="#sense"><code>Sense</code></a> <code>Oscilloscope</code> uses
+href="#sense"><code>Sense</code></a>, <code>Oscilloscope</code> uses
<code>DemoSensorC</code> and a timer to periodically sample the default sensor
of a platform. When it has gathered 10 sensor readings
-<code>OscilloscopeC</code> puts them into a message and broadcasts the message
+<code>OscilloscopeC</code> puts them into a message and broadcasts that message
via the <code>AMSend</code> interface. <code>OscilloscopeC</code> uses the
<code>Receive</code> interface for synchronization purposes (see below) and the
<code>RadioControl</code> interface, which is a actually a
To install the <code>Oscilloscope</code> application go to
<code>tinyos-2.x/apps/Oscilloscope</code> and depending on which hardware you
-have, type e.g. <code>make telosb install,1</code>. Note the "<code>,1</code>"
+have, type something similar to <code>make telosb install,1</code>. Note the "<code>,1</code>"
after the <code>install</code> option, which assigns ID 1 to the node.
Assigning IDs to nodes is helpful to differentiate them later on in the GUI, so
make sure you assign different IDs to all nodes on which
<p> The <code>Oscilloscope</code> (or <code>Sense</code>) application displays
the raw data as signalled by the <code>Read.readDone()</code> event. They do
not perform semantic processing and cannot decide questions like "is a reading
-to be interpreted in degree Celsius or Fahrenheit". This decision is forwarded
+to be interpreted in degrees Celsius or Fahrenheit". This decision is forwarded
to the user and therefore the GUI let's you adapt the visible portion of the
y-axis to a plausible range (at the bottom right).
<body>
<div class="title">Lesson 6: TinyOS Boot and System Initialization</div>
-<div class="subtitle">Last updated 18 May 2006</div>
-
-One of the frequently asked questions regarding TinyOS is, "Where is
-<code>main()</code>?". In previous lessons, we deferred detailed discussion of the
-TinyOS boot sequence in favor of grasping the general idea. We will
-now revisit the boot sequence indetail. Understanding how TinyOS
-initializes will help solidify understanding of the execution model
-and answer the question "Where is <code>main()</code>?".
+<div class="subtitle">Last updated 30 October 2006</div>
+
+<h1>Introduction</h1>
+<p>One of the frequently asked questions regarding TinyOS is, "Where is
+ <code>main()</code>?". In previous lessons, we deferred detailed
+ discussion of the TinyOS boot sequence: applications handle the
+ <tt>Boot.booted</tt> event and start from there. This tutorial
+ describes the steps that occur before and after this event,
+ showing how to properly initialize components.</p>
+
+<h1>Boot Sequence</h1>
-The TinyOS boot sequence is comprised of three steps:
-<ul>
-<li> Scheduler initialization
-<li> Component initialization
-<li> Signal that the boot process has completed
-</ul>
+<p>The TinyOS boot sequence has four steps:
+ <ol>
+ <li> Scheduler initialization</li>
+ <li> Component initialization</li>
+ <li> Signal that the boot process has completed</li>
+ <li> Run the scheduler</li>
+ </ol>
+
+ The application-level boot sequence component is <tt>MainC</tt> (in tos/system).
+ MainC provides one interface, <tt>Boot</tt> and uses one interface,
+ <tt>Init as SoftwareInit</tt>. The boot sequence calls SoftwareInit.init() as
+ part of step 2 and signals Boot.booted in step 3.</p>
+
+ <p>The default real boot sequence is in the component <tt>RealMainP</tt>. Note
+ that its name ends in P, denoting that components should not directly wire to
+ it. This is RealMainP's signature:</p>
-<p><b>Scheduler initialization.</b> The scheduler is initialized
-before any components are initialized. If the scheduler were not
+
+ <pre>
+ module RealMainP {
+ provides interface Booted;
+ uses {
+ interface Scheduler;
+ interface Init as PlatformInit;
+ interface Init as SoftwareInit;
+ }
+ }
+ </pre>
+
+ <p>MainC only provides Boot and uses SoftwareInit; RealMainP uses
+ two additional interfaces, PlatformInit and Scheduler. MainC hides
+ these from applications by automatically wiring them to the system's
+ scheduler and platform initialization sequence. The difference between
+ PlatformInit and SoftwareInit is predominantly one of hardware vs. software.
+ PlatformInit is responsible for placing core platform services into
+ meaningful states; for example, the PlatformInit of mica platforms
+ calibrates their clocks.</p>
+
+ <p>This is the code of RealMainP:</p>
+
+ <pre>
+ implementation {
+ int main() __attribute__ ((C, spontaneous)) {
+ atomic {
+ call Scheduler.init();
+ call PlatformInit.init();
+ while (call Scheduler.runNextTask());
+ call SoftwareInit.init();
+ while (call Scheduler.runNextTask());
+ }
+ __nesc_enable_interrupt();
+ signal Boot.booted();
+ call Scheduler.taskLoop();
+ return -1;
+ }
+ default command error_t PlatformInit.init() { return SUCCESS; }
+ default command error_t SoftwareInit.init() { return SUCCESS; }
+ default event void Boot.booted() { }
+ }
+</pre>
+
+ <p>The code shows the four steps described above.</p>
+
+<h2>Scheduler Initialization</h2>
+<p>
+The first boot step is to initialize the scheduler.
+If the scheduler were not
initialized before the components, component initialization
routines would not be able to post tasks. While not all components
-require tasks to be posted, this gives the flexibility required for those compoenents that do.
+require tasks to be posted, this gives the flexibility required for
+ those components that do. The boot sequence runs tasks after each
+ initialization stage in order to allow long-running operations,
+ since they only happen once. <A HREF="../tep106.html">TEP 106</A>
+ describes TinyOS schedulers in greater detail, including information
+ on how to replace the scheduler.</p>
-<p>The <code>Scheduler</code> interface defines a scheduling
-component's signature in
-<code>tos/interfaces/Scheduler.nc</code>. TinyOS developers can
-define their own scheduler to meet their application's needs.</p> An
-implementation of the <code>Scheduler</code> interface is provided in
-<code>tos/system/TinySchedulerC.nc</code>.</p>
-<p><b>Component initialization.</b> After the scheduler is initialized,
-components are initialized. The <code>Init</code> interface implements only
+<h2>Component initialization.</h2>
+
+<p>After RealMainP initializes the scheduler,
+it initializes the platform. The <code>Init</code> interface implements only
the single command <code>init()</code>. </p>
<pre></pre>
}
</pre>
-<p>To provide the initialization flexibility required by sensor
-network components, the TinyOS's boot sequence breaks down the component
-initialization into a <i>platform initialization phase</i> (run first) and a <i>software
-initialization phase</i>. This is accomplished by making the TinyOS component that
-executes the boot sequence use two <code>Init</code> interfaces:
-one called <code>PlatformInit</code> and one called <code>SoftwareInit</code>:
-
-<pre></pre>
-<prehead>tos/system/RealMainP.nc:</prehead>
-<pre>
-module RealMainP {
- provides interface Boot;
- uses interface Scheduler;
- uses interface Init as PlatformInit;
- uses interface Init as SoftwareInit;
-}
-implementation {
- // implementation covered below
-}
-</pre>
-
<p>The platform initialization phase is the responsability of the platform
implementer. Thus, <code>PlatformInit</code> is wired to the
platform-specific initialization component, <code>PlatformC</code>. No
each platform's <code>PlatformC</code> component.
<li> System services (e.g., the timer, the radio) are typically written to
-be independently initialisable. For instance, a radio that uses a timer
+be independently initializable. For instance, a radio that uses a timer
does not setup the timer at radio initialisation time, rather it defers
that action until the radio is started. In other words, initialisation
is used to setup software state, and hardware state wholly owned by
<li> When a service is split into several components, the <code>Init</code>
interface for one of these components may well call <code>Init</code>
-(and other) interfaces of the other components forming the service.
+(and other) interfaces of the other components forming the service,
+ if a specific order is needed.
</ul>
-<p><b>Signal that the boot process has completed.</b> Once all
+<h2>Signal that the boot process has completed.</h2>
+
+<p>Once all
initialization has completed, <code>MainC</code>'s
<code>Boot.booted()</code> event is signaled. Components are now free to
call <code>start()</code> and other commands on any components they are
using. Recall that in the <code>Blink</code> application, the timers were
started from the <code>booted()</code> event. This <code>booted</code>
-event is TinyOS's analogue of <code>main</code> in a Unix application.
+event is TinyOS's analogue of <code>main</code> in a Unix application.</p>
-<p>But if you're curious, <code>main</code> is actually found inside
-<code>RealMainP</code>. It executes the steps outlined above, i.e.,
-initialises the scheduler, calls the initialization interfaces, signals the
-<code>booted</code> event and then starts the main TinyOS scheduling loop:
+<h2>Run the scheduler loop.</h2>
+<p>Once the application has been informed
+ that the system as booted and started needed services, TinyOS
+ enters its core scheduling loop. The scheduler runs as long
+ as there are tasks on the queue. As soon as it detects an empty
+ queue, the scheduler puts the microcontroller into the lowest
+ power state allowed by the active hardware resources. For example,
+ only having timers running usually allows a lower power state than
+ peripheral buses like the UART. <A HREF="../tep112.html">TEP 112</A>
+ describes in detail how this process works.</p>
-<pre></pre>
-<prehead>tos/system/RealMainP.nc:</prehead>
-<pre>
-module RealMainP {
- // signature
-}
-implementation {
- int main() __attribute__ ((C, spontaneous)) {
- atomic
- {
- call Scheduler.init();
-
- call PlatformInit.init();
- while (call Scheduler.runNextTask());
-
- call SoftwareInit.init();
- while (call Scheduler.runNextTask());
- }
+ <p>The processor goes to sleep until it handles an interrupt. When
+ an interrupt arrives, the MCU exits its sleep state and runs the
+ interrupt handler. This causes the scheduler loop to restart. If
+ the interrupt handler posted one or more tasks, the scheduler runs
+ tasks until the task queue and then returns to sleep.</p>
- /* Enable interrupts now that system is ready. */
- __nesc_enable_interrupt();
- signal Boot.booted();
+ <h1>Boot and SoftwareInit</h1>
- /* Spin in the Scheduler */
- call Scheduler.taskLoop();
- }
+ <p>From the perspective of an application or high-level services, the two
+ important interfaces in the boot sequence are those which MainC exports:
+ Boot and SoftwareInit. Boot is typically only handled by the top-level application:
+ it starts services like timers or the radio. SoftwareInit, in contrast,
+ touches many difference parts of the system. If a component needs code
+ that runs once to initialize its state or configuration, then it can wire
+ to SoftwareInit.</p>
+
+ <p>Typically, service components that require intialization wire themselves
+ to SoftwareInit rather than depend on the application writer to do so. When
+ an application developer is writing a large, complex system, keeping track of
+ all of the initialization routines can be difficult, and debugging when one
+ is not being called can be very difficult. To prevent bugs and simplify
+ application development, services typically use <i>auto-wiring</i>.</p>
+
+ <p>The term auto-wiring refers to when a component automatically wires its
+ dependencies rather than export them for the application writer to resolve.
+ In this case, rather than provide the Init interface, a service component
+ wires its Init interface to RealMainC. For example, <tt>PoolC</tt> is a generic
+ memory pool abstraction that allows you to declare a collection of memory
+ objects for dynamic allocation. Underneath, its implementation (<tt>PoolP</tt>)
+ needs to initialize its data structures. Given that this must happen for
+ the component to operate properly, an application writer shouldn't have to
+ worry about it. So the PoolC component instantiates a PoolP and wires it
+ to MainC.SoftwareInit:
+
+ <pre>
+generic configuration PoolC(typedef pool_t, uint8_t POOL_SIZE) {
+ provides interface Pool<pool_t>;
+}
+implementation {
+ components MainC, new PoolP(pool_t, POOL_SIZE);
+
+ MainC.SoftwareInit -> PoolP;
+ Pool = PoolP;
+}
</pre>
+ <p>In practice, this means that when MainP calls SoftwareInit.init,
+ it calls Init.init on a large number of components. In a typical large
+ application, the initialization sequence might involve as many as thirty
+ components. But the application developer doesn't have to worry about this:
+ properly written components take care of it automatically.</p>
+
+
<p>
<a name=#related_docs>
<h1>Related Documentation</h1>
configuration of a software abstraction, auto-wire Init to MainC. This removes the
burden of wiring Init from the programmer, which removes unnecessary work from the
boot sequence and removes the possibility of bugs from forgetting to wire.
-From Phil Levis' <a href="http://csl.stanford.edu/~pal/pubs/tinyos-programming-1-0.pdf">
+From <a href="../../pdf/tinyos-programming.pdf">
<i>TinyOS Programming</i></a>
<!-- Begin footer -->
<tr>
<td>TinyOS</td>
- <td><a href="http://www.tinyos.net/dist-2.0.0/tinyos/windows/tinyos-2.0.0-2.cygwin.noarch.rpm">tinyos-2.0.0-2.cygwin.noarch.rpm</a></td>
- <td><a href="http://www.tinyos.net/dist-2.0.0/tinyos/linux/tinyos-2.0.0-2.noarch.rpm">tinyos-2.0.0-2.noarch.rpm</a></td>
+ <td><a href="http://www.tinyos.net/dist-2.0.0/tinyos/windows/tinyos-2.0.0-1.cygwin.noarch.rpm">tinyos-2.0.0-1.cygwin.noarch.rpm</a></td>
+ <td><a href="http://www.tinyos.net/dist-2.0.0/tinyos/linux/tinyos-2.0.0-1.noarch.rpm">tinyos-2.0.0-1.noarch.rpm</a></td>
<td><tt>rpm -Uvh</tt> (to upgrade)<br>
<tt>rpm -ivh</tt> (to install)<br>
<tt>rpm -ivh --force</tt> (to force install)<br>
different kinds of TEPs and their roles. TEPs 1-100 are
BCP (Best Current Practice) TEPs, while TEPS 101+ are
Informational, Documentary, or Experimental. Currently,
- many TEPs are Drafts: comments and feedback to the
+ all TEPs are still Drafts: comments and feedback to the
authors or the associated working group is welcome.
<BR><BR>
provides interface DisseminationUpdate <t>;
}
-The t argument MUST be able to fit in a single message_t[1_] after
+The t argument MUST be able to fit in a single message_t[tep111_] after
considering the headers that the dissemination protocol introduces.
A dissemination implementation SHOULD have a compile error if a larger
type than this is used.
The memo documents the interfaces, components, and semantics used by
collection protocol in TinyOS 2.x. Collection provides a best-effort,
-multihop delivery of packets to the root of *a* tree. There may be
-multiple roots in a network, and in this case the semantics implemented
-are of *anycast* delivery to at least one of the roots. A node sending
-a packet does not specify which root the packet is destined to.
-
+multihop delivery of packets to the root of a tree.
1. Introduction
====================================================================
parent node, a collection protocol implicitly joins one of these
trees. Collection provides a best-effort,
multihop delivery of packets to one of a network's tree roots:
-it is an *anycast* protocol. The semantics is that the protocol
-will make a reasonable effort to deliver the message to at least
-one of the roots in the network. There are however no guarantees of
-delivery, and there can be duplicates delivered to one or more
-roots. There is also no ordering guarantees.
+it is an *anycast* protocol.
Given the limited state that nodes can store and a general need
for distributed tree building algorithms, simple collection protocols
A node can perform four different roles in collection: producer,
consumer, snooper, and in-network processor. Depending on their role,
the nodes use different interfaces to interact with the collection
-component.
+component.
+
+The nodes that generate data to be sent to the root are
+*producers*. The producers use the Send interface [1_] to send
+data to the root of the collection tree. The collection tree
+identifier is be specified as a parameter to Send during
+instantiation.
+
+Root nodes that receive data from the network are *consumers*. The
+consumers use the Receive interface [1_] to receive a message
+delivered by collection. The collection tree identifier is be
+specified as a parameter to Receive during instantiation.
-A consumer is a root of a tree. The set of all roots and the paths that
-lead to them form the collection routing infrastructure in the network.
-For any connected set of nodes implementing the collection protocol
-there is only one collection infrastructure, *i.e.*, all roots in this
-set active at the same time are part of the same infrastructure.
+The nodes that overhear messages in transit are *snoopers*. The snoopers
+use the Receive interface [1_] to receive a snooped message. The
+collection tree identifier is be specified as a parameter to Receive
+during instantiation.
+
+The nodes can process a packet that are in transit. These in-network
+*processors* use the Intercept interface [1_] to receive and
+update a packet. The collection tree identifier is be specified as a
+parameter to Intercept during instantiation.
A node is configured to become a root by using the RootControl
interface. RootControl.setRoot() MUST make the current node a root of
-the the collection infrastructure. RootControl.unsetRoot() MUST
-make the current root no longer a root in the collection infrastructure.
-Both calls are idempotent.
-RootControl.setRoot() MAY be called on a node that is already a root, to
-no effect. RootControl.unsetRoot() MAY be called on a node that is
+the tree specified during instantiation. RootControl.unsetRoot() MUST
+make the current root no longer a root in the tree specified during
+instantiation. RootControl.unsetRoot() MAY be called on a node that is
not a root::
interface RootControl {
command bool isRoot();
}
-The collection infrastructure can be multiplexed among independent
-applications, by means of a *collection identifier*. It is important
-to note that the *data* traffic in the protocol is multiplexed,
-while the *control* traffic is not.
-
-The nodes that generate data to be sent to the root are *producers*.
-The producers use the Send interface [1_] to send data to the root
-of the collection tree. The collection identifier is specified as a
-parameter to Send during instantiation.
-
-Root nodes that receive data from the network are *consumers*. The
-consumers use the Receive interface [1_] to receive a message
-delivered by collection. The collection identifier is specified
-as a parameter to Receive during instantiation.
-
-The nodes that overhear messages in transit are *snoopers*. The
-snoopers use the Receive interface [1_] to receive a snooped
-message. The collection identifier is specified as a parameter
-to Receive during instantiation.
-
-The nodes can process a packet that are in transit. These in-network
-*processors* use the Intercept interface [1_] to receive and update
-a packet. The collection identifier is specified as a parameter
-to Intercept during instantiation.
3 Collection Services
====================================================================
-A collection service MUST provide one component, CollectionC,
+A collection service MUST provide one component, TreeCollectionC,
which has the following signature::
- configuration CollectionC {
+ configuration TreeCollectionC {
provides {
interface StdControl;
interface Send[uint8_t client];
interface RootControl;
interface Packet;
interface CollectionPacket;
+ interface TreeRoutingInspect;
}
uses {
interface CollectionId[uint8_t client];
}
-CollectionC MAY have additional interfaces, but they MUST have
+TreeCollectionC MAY have additional interfaces, but they MUST have
default functions on all outgoing invocations (commands for uses,
events for provides) of those interfaces so that it can operate
properly if they are not wired.
-Components SHOULD NOT wire to CollectionC.Send. The generic
+Components SHOULD NOT wire to TreeCollectionC.Send. The generic
component CollectionSenderC (described in section 3.1) provides
a virtualized sending interface.
snoopers, intercepters, and receivers can parse it properly.
Receive.receive MUST NOT be signaled on non-root
-nodes. CollectionC MAY signal Receive.receive on a root node when
+nodes. TreeCollectionC MAY signal Receive.receive on a root node when
a data packet successfully arrives at that node. If a root node calls
-Send, CollectionC MUST treat it as it if were a received packet.
+Send, TreeCollectionC MUST treat it as it if were a received packet.
Note that the buffer swapping semantics of Receive.receive, when
-combined with the pass semantics of Send, require that CollectionC
+combined with the pass semantics of Send, require that TreeCollectionC
make a copy of the buffer if it signals Receive.receive.
-If CollectionC receives a data packet to forward and it is not a
+If TreeCollectionC receives a data packet to forward and it is not a
root node, it MAY signal Intercept.forward.
-If CollectionC receives a data packet that a different node
+If TreeCollectionC receives a data packet that a different node
is supposed to forward, it MAY signal Snoop.receive.
RootControl allows a node to be made a collection tree root.
-CollectionC SHOULD NOT configure a node as a root by default.
+TreeCollectionC SHOULD NOT configure a node as a root by default.
Packet and CollectionPacket allow components to access collection
data packet fields [1_].
+TreeRoutingInspect provides information on the current position of
+the node in a routing tree::
+
+ interface TreeRoutingInspect {
+ command error_t getParent(am_addr_t* parent);
+ command error_t getHopcount(uint8_t* hopcount);
+ command error_t getMetric(uint16_t* metric);
+ }
+
+In each of these commands, if the return value is not SUCCESS, the
+value stored in the pointer argument is undefined. The getMetric
+command provides a measure of the quality of a node's route to the
+base station. This routing metric MUST be monotonically increasing
+across hops. In a collection tree, if node A is the parent of node B,
+then node B's metric value MUST be greater than node A's.
+
3.1 CollectionSenderC
--------------------------------------------------------------------
Collection has a virtualized sending abstraction, the generic
component CollectionSenderC::
- generic configuration CollectionSenderC(collection_id_t collectid) {
- provides {
- interface Send;
- interface Packet;
- }
+generic configuration CollectionSenderC(collection_id_t collectid) {
+ provides {
+ interface Send;
+ interface Packet;
}
-
-
+}
This abstraction follows a similar virtualization approach to
AMSenderC [1_], except that it is parameterized by a collection_id_t
====================================================================
An implementation of this TEP can be found in
-``tinyos-2.x/tos/lib/net/ctp`` and ``tinyos-2.x/tos/lib/net/le``, in
-the CTP protocol. It is beyond the scope of this document to fully
-describe CTP, but we outline its main components. CTP will be
-described in an upcoming TEP [2_]. This implementation is a
-reference implementation, and is not the only possibility. It
-consists of three major components, which are wired together to form
-a CollectionC: LinkEstimatorP, CtpTreeRoutingEngineP, and
-CtpForwardingEngineP.
-
-This decomposition tries to encourage evolution of components and
-ease of use through modularization. Neighbor management and link
-estimation are decoupled from the routing protocol. Furthermore, the
-routing protocol and route selection are decoupled from the
-forwarding policies, such as queueing and timing.
+``tinyos-2.x/tos/lib/net/collection``. The implementation consists of
+three major components, which are wired together to form a
+CollectionC: LinkEstimatorP, TreeRoutingEngineP, and ForwardingEngineP.
+
+This decomposition tries to encourage evolution of components and ease
+of use through modularization. Neighbor management and link estimation
+are are decoupled from the routing protocol. Furthermore, the routing
+protocol and route selection are decoupled from the forwarding policies,
+such as queueing and timing.
4.1 LinkEstimatorP
--------------------------------------------------------------------
LinkEstimatorP estimates the quality of link to or from each
-neighbor. Link estimation can be done in a variety of ways, and we
-do not impose one here. It is decoupled from the establishment of
-routes. There is a narrow interface -- LinkEstimator -- between the
-link estimator and the routing engine. The one requirement is that
-the quality returned is standardized. A smaller return value from
-LinkEstimator.getQuality(), LinkEstimator.getforwardQuality(),
-LinkEstimator.getreserveQuality() MUST imply that the link to the
-neighbor is estimated to be of a higher quality than the one that
-results in a smaller return value. The range of value SHOULD be
-[0,255] and the variation in link quality in that range SHOULD be
-linear. Radio provided values such as LQI or RSI, beacon based link
-estimation to compute ETX, or their combination are some possible
-approaches to estimating link qualities.
-
-LinkEstimatorP MAY have its own control messages to compute
-bi-directional link qualities. LinkEstimatorP provides calls
-(txAck(), txNoAck(), and clearDLQ()) to update the link estimates
-based on successful or unsuccessful data transmission to the
-neighbors.
-
-The user of LinkEstimatorP can call insertNeighbor() to manually
-insert a node in the neighbor table, pinNeighbor() to prevent a
-neighbor from being evicted, and unpinNeighbor() to restore eviction
-policy::
+neighbor. Link estimation can be done in a variety of ways, and we do
+not impose one here. It is decoupled from the establishment of
+routes. There is a narrow interface (LinkEstimator and
+NeighborTableEviction) between the link estimator and the routing
+engine. The one requirement is that the quality returned is
+standardized. A smaller return value from LinkEstimator.getQuality(),
+LinkEstimator.getforwardQuality(), LinkEstimator.getreserveQuality()
+MUST imply that the link to the neighbor is estimated to be of a
+higher quality than the one that results in a smaller return
+value. The range of value SHOULD be [0,255] and the variation in link
+quality in that range SHOULD be linear. Radio provided values such as
+LQI or RSI, beacon based link estimation to compute ETX, or their
+combination are some possible approaches to estimating link
+qualities. LinkEstimatorP MAY have its own control messages to compute
+bi-directional link qualities. LinkEstimatorP provides calls (txAck(),
+txNoAck(), and clearDLQ()) to update the link estimates based on
+successful or unsuccessful data transmission to the neighbors. The
+user of LinkEstimatorP can call insertNeighbor() to manually insert a
+node in the neighbor table, pinNeighbor() to prevent a neighbor from
+being evicted, and unpinNeighbor() to restore eviction policy::
typedef uint16_t neighbor_table_entry_t
event void evicted(am_addr_t neighbor);
}
+ interface NeighborTableEviction {
+ event void evicted(uint16_t neighbor)
+ }
-4.2 CtpRoutingEngineP
+4.2 TreeRoutingEngineP
--------------------------------------------------------------------
-CtpRoutingEngineP is responsible for computing routes to the roots of a
-tree. In traditional networking terminology, this is part of the
-control plane of the network, and is does not directly forward any
-data packets, which is the responsibility of CtpForwardingEngine.
-The main interface between the two is UnicastNameFreeRouting.
-
-CtpRoutingEngineP uses the LinkEstimator interface to learn
+TreeRoutingEngineP is responsible for computing routes to the roots of a
+tree. It uses NeighborTable and LinkEstimator interfaces to learn
about the nodes in the neighbor table maintained by LinkEstimatorP and
the quality of links to and from the neighbors. The routing protocol
on which collection is implemented MUST be a tree-based routing
-protocol with a single or multiple roots. CtpRoutingEngineP
+protocol with a single or multiple roots. TreeRoutingEngineP
allows a node to be configured as a root or a non-root node
-dynamically. CtpRoutingEngineP maintains multiple candidate next hops::
-
- generic module CtpRoutingEngineP(uint8_t routingTableSize,
- uint16_t minInterval,
- uint16_t maxInterval) {
- provides {
- interface UnicastNameFreeRouting as Routing;
- interface RootControl;
- interface CtpInfo;
- interface StdControl;
- interface CtpRoutingPacket;
- interface Init;
- }
- uses {
- interface AMSend as BeaconSend;
- interface Receive as BeaconReceive;
- interface LinkEstimator;
- interface AMPacket;
- interface LinkSrcPacket;
- interface SplitControl as RadioControl;
- interface Timer<TMilli> as BeaconTimer;
- interface Timer<TMilli> as RouteTimer;
- interface Random;
- interface CollectionDebug;
- interface CtpCongestion;
- }
- }
-
-
-::
-
- interface UnicastNameFreeRouting {
- command am_addr_t nextHop();
-
- command bool hasRoute();
- event void routeFound();
- event void noRoute();
- }
-
+dynamically. TreeRoutingEngineP maintains multiple candidate next hops::
+ generic module TreeRoutingEngineP(uint8_t routingTableSize) {
+ provides {
+ interface UnicastNameFreeRouting as Routing;
+ interface RootControl;
+ interface TreeRoutingInspect;
+ interface StdControl;
+ interface Init;
+ }
+ uses {
+ interface AMSend as BeaconSend;
+ interface Receive as BeaconReceive;
+ interface LinkEstimator;
+ interface AMPacket;
+ interface LinkSrcPacket;
+ interface SplitControl as RadioControl;
+ interface Timer<TMilli> as BeaconTimer;
+ interface Random;
+ interface CollectionDebug;
+ }
+ }
-4.3 CtpForwardingEngineP
+4.3 ForwardingEngineP
--------------------------------------------------------------------
-The CtpForwardingEngineP component provides all the top level interfaces
-(except RootControl) which CollectionC provides and an application
-uses. It deals with retransmissions, duplicate suppression, packet
-timing, loop detection, and also informs the LinkEstimator of the
-outcome of attempted transmissions.::
+The ForwardingEngineP component provides all the top level interfaces
+(except RootControl) which TreeCollectionC provides and an application
+uses::
- generic module CtpForwardingEngineP() {
+ generic module ForwardingEngineP() {
provides {
interface Init;
interface StdControl;
interface Intercept[collection_id_t id];
interface Packet;
interface CollectionPacket;
- interface CtpPacket;
- interface CtpCongestion;
}
uses {
- interface SplitControl as RadioControl;
interface AMSend as SubSend;
interface Receive as SubReceive;
interface Receive as SubSnoop;
interface Packet as SubPacket;
interface UnicastNameFreeRouting;
+ interface SplitControl as RadioControl;
interface Queue<fe_queue_entry_t*> as SendQueue;
interface Pool<fe_queue_entry_t> as QEntryPool;
interface Pool<message_t> as MessagePool;
interface Timer<TMilli> as RetxmitTimer;
- interface LinkEstimator;
- interface Timer<TMilli> as CongestionTimer;
- interface Cache<message_t*> as SentCache;
- interface CtpInfo;
+ interface Cache<uint32_t> as SentCache;
+ interface TreeRoutingInspect;
interface PacketAcknowledgements;
interface Random;
interface RootControl;
}
}
-
-CtpForwardingEngineP uses a large number of interfaces, which can be
+ForwardingEngineP uses a large number of interfaces, which can be
broken up into a few groups of functionality:
* Single hop communication: SubSend, SubReceive, SubSnoop,
SubPacket, PacketAcknowledgments, AMPacket
- * Routing: UnicastNameFreeRouting, RootControl, CtpInfo,
- CollectionId, SentCache
+ * Routing: UnicastNameFreeRouting, TreeRoutingInspect,
+ RootControl, CollectionId, SentCache
* Queue and buffer management: SendQueue, MessagePool,
QEntryPool
* Packet timing: Random, RetxmitTimer
====================================================================
.. [1] TEP 116: Packet Protocols
-.. [2] TEP 124: The Collection Tree Protocol (CTP) - (upcoming)
INSTALL_SREC = $(MAIN_SREC).out$(if $(NODEID),-$(NODEID),)
VOLUMEFILE = volumes-at45db.xml
-PFLAGS += -Wall -Wshadow -DDEF_TOS_AM_GROUP=$(DEFAULT_LOCAL_GROUP) $(NESC_FLAGS)
+PFLAGS += -Wall -Wshadow $(NESC_FLAGS)
PFLAGS += -target=$(PLATFORM) -fnesc-cfile=$(BUILDDIR)/app.c -board=$(SENSORBOARD)
ifdef MSG_SIZE
PFLAGS += -DTOSH_DATA_LENGTH=$(MSG_SIZE)
mkdir -p $(BUILDDIR)
bytes: FORCE
- @objdump -h $(MAIN_EXE) | perl -ne '$$b{$$1}=hex $$2 if /^\s*\d+\s*\.(text|data|bss)\s+(\S+)/; END { printf("%16d bytes in ROM\n%16d bytes in RAM\n",$$b{text}+$$b{data},$$b{data}+$$b{bss}); }'
+ @$(OBJDUMP) -h $(MAIN_EXE) | perl -ne '$$b{$$1}=hex $$2 if /^\s*\d+\s*\.(text|data|bss)\s+(\S+)/; END { printf("%16d bytes in ROM\n%16d bytes in RAM\n",$$b{text}+$$b{data},$$b{data}+$$b{bss}); }'
DEFAULT_PROGRAM = jtag
endif
+VOLUME_FILE = volumes-stm25p.xml
+VOLUME_ALLOCATOR = tos-storage-stm25p
+
NESC_FLAGS:=-Wnesc-all
$(call TOSMake_include_platform,msp)
MSP_MCU = msp430x1611
+#Flash Config
+VOLUME_FILE = volumes-at45db.xml
+VOLUME_ALLOCATOR = tos-storage-at45db
+
# Disable MSP430 hardware multiply because it makes MSPGCC die
PFLAGS += -mdisable-hwmul
OPTFLAGS += -O
NESC_FLAGS:=-Wnesc-all -mdisable-hwmul
+VOLUME_FILE = volumes-at45db.xml
+VOLUME_ALLOCATOR = tos-storage-at45db
+
$(call TOSMake_include_platform,msp)
eyesIFXv2: $(BUILD_DEPS)
PFLAGS += -DCC2420_DEF_CHANNEL=$(CC2420_CHANNEL)
endif
+VOLUME_FILE = volumes-pxa27xp30.xml
+VOLUME_ALLOCATOR = tos-storage-pxa27xp30
+
#ASSEMBLY_FILES += $(PLATFORM_DIR)/../imote2/flash.s $(PLATFORM_DIR)/../imote2/binarymover.s
ASSEMBLY_FILES += $(TOSDIR)/platforms/intelmote2/toscrt0.s $(TOSDIR)/chips/pxa27x/pxa27x_util.s
CFLAGS += -DPXA27X_13M -T$(TOSDIR)/platforms/intelmote2/tos.x
mkdir -p $(BUILDDIR)
bytes: FORCE
- @objdump -h $(MAIN_EXE) | perl -ne '$$b{$$1}=hex $$2 if /^\s*\d+\s*\.(text|data|bss)\s+(\S+)/; END { printf("%16d bytes in ROM\n%16d bytes in RAM\n",$$b{text}+$$b{data},$$b{data}+$$b{bss}); }'
+ @$(OBJDUMP) -h $(MAIN_EXE) | perl -ne '$$b{$$1}=hex $$2 if /^\s*\d+\s*\.(text|data|bss)\s+(\S+)/; END { printf("%16d bytes in ROM\n%16d bytes in RAM\n",$$b{text}+$$b{data},$$b{data}+$$b{bss}); }'
# out with call in there. I don't know why.
$(if $(PROGRAM),,$(call TOSMake_include,pxa27x/$(DEFAULT_PROGRAM).extra))
+# Build storage file if volumes.xml present
+ifneq ($(wildcard $(VOLUME_FILE)), )
+exe0: $(BUILDDIR)/StorageVolumes.h
+
+$(BUILDDIR)/StorageVolumes.h: $(VOLUME_FILE)
+ $(VOLUME_ALLOCATOR) <$(VOLUME_FILE) >$@
+
+PFLAGS += -I$(BUILDDIR)
+endif
+
ifndef BUILD_DEPS
ifeq ($(filter $(BUILDLESS_DEPS),$(GOALS)),)
BUILD_DEPS = bin bytes $(POST_BUILD_EXTRA_DEPS)
mkdir -p $(BUILDDIR)
bytes: FORCE
- @objdump -h $(MAIN_EXE) | perl -ne '$$b{$$1}=hex $$2 if /^\s*\d+\s*\.(text|data|bss)\s+(\S+)/; END { printf("%16d bytes in ROM\n%16d bytes in RAM\n",$$b{text}+$$b{data},$$b{data}+$$b{bss}); }'
+ @$(OBJDUMP) -h $(MAIN_EXE) | perl -ne '$$b{$$1}=hex $$2 if /^\s*\d+\s*\.(text|data|bss)\s+(\S+)/; END { printf("%16d bytes in ROM\n%16d bytes in RAM\n",$$b{text}+$$b{data},$$b{data}+$$b{bss}); }'
asms:
$(GAS) $(ASSEMBLY_FILES) -o $(BUILDDIR)/asms.o
PROGRAM = xflash
-PROGRAMMER ?= c:/nordheim/xflash/xflash.exe
+PROGRAMMER ?= xflash.exe
PROGRAMMER_FLAGS = -p imote2
PXA27X_JTAG_DEV ?= "JTAG CPU"
OBJFILE = $(BUILDDIR)/sim.o
CXXFILE = $(TOSDIR)/lib/tossim/tossim.c
CXXOBJFILE = $(BUILDDIR)/tossim.o
+HASHFILE = $(TOSDIR)/lib/tossim/hashtable.c
+HASHOBJFILE = $(BUILDDIR)/c-support.o
PYFILE = $(TOSDIR)/lib/tossim/tossim_wrap.cxx
PYOBJFILE = $(BUILDDIR)/pytossim.o
PYDIR =/usr/include/python$(PYTHON_VERSION)
@echo " writing XML schema to $(XML)"
@echo " compiling $(COMPONENT) to object file sim.o"
$(NCC) -c $(PLATFORM_FLAGS) -o $(OBJFILE) $(OPTFLAGS) $(PFLAGS) $(CFLAGS) $(WFLAGS) $(COMPONENT).nc $(LDFLAGS) $(DUMPTYPES) -fnesc-dumpfile=$(XML)
-
- @echo " compiling Python support into pytossim.o and tossim.o"
+ @echo " compiling Python support and C libraries into pytossim.o, tossim.o, and c-support.o"
$(GPP) -c $(PLATFORM_CC_FLAGS) $(PLATFORM_FLAGS) -o $(PYOBJFILE) $(OPTFLAGS) $(CFLAGS) $(PYFILE) -I$(PYDIR) -I$(SIMDIR) -DHAVE_CONFIG_H
$(GPP) -c $(PLATFORM_CC_FLAGS) $(PLATFORM_FLAGS) -o $(CXXOBJFILE) $(OPTFLAGS) $(CFLAGS) $(CXXFILE) -I$(PYDIR) -I$(SIMDIR)
+ $(GPP) -c $(PLATFORM_CC_FLAGS) $(PLATFORM_FLAGS) -o $(HASHOBJFILE) $(OPTFLAGS) $(CFLAGS) $(HASHFILE) -I$(PYDIR) -I$(SIMDIR)
@echo " linking into shared object ./$(SHARED_OBJECT)"
$(GPP) $(PLATFORM_BUILD_FLAGS) $(PLATFORM_CC_FLAGS) $(PYOBJFILE) $(OBJFILE) $(CXXOBJFILE) $(PLATFORM_LIB_FLAGS) -o $(SHARED_OBJECT)
@echo " copying Python script interface TOSSIM.py from lib/tossim to local directory"
LIBS = -lm -lstdc++
PFLAGS += -tossim -fnesc-nido-tosnodes=1000 -fnesc-simulate -fnesc-nido-motenumber=sim_node\(\)
WFLAGS = -Wno-nesc-data-race
-PYTHON_VERSION=2.3
+PYTHON_VERSION=2.4
BUILDDIR = simbuild/$(PLATFORM)
CFILE = $(BUILDDIR)/sim.c
OBJFILE = $(BUILDDIR)/sim.o
CXXFILE = $(TOSDIR)/lib/tossim/tossim.c
CXXOBJFILE = $(BUILDDIR)/tossim.o
+HASHFILE = $(TOSDIR)/lib/tossim/hashtable.c
+HASHOBJFILE = $(BUILDDIR)/c-support.o
PYFILE = $(TOSDIR)/lib/tossim/tossim_wrap.cxx
PYOBJFILE = $(BUILDDIR)/pytossim.o
PYDIR =/usr/include/python$(PYTHON_VERSION)
@echo " compiling $(COMPONENT) to object file sim.o"
$(NCC) -c $(PLATFORM_FLAGS) -o $(OBJFILE) $(OPTFLAGS) $(PFLAGS) $(CFLAGS) $(WFLAGS) $(COMPONENT).nc $(LDFLAGS) $(DUMPTYPES) -fnesc-dumpfile=$(XML)
- @echo " compiling Python support into pytossim.o and tossim.o"
+ @echo " compiling Python support and C libraries into pytossim.o, tossim.o, and c-support.o"
$(GPP) -c $(PLATFORM_CC_FLAGS) $(PLATFORM_FLAGS) -o $(PYOBJFILE) $(OPTFLAGS) $(CFLAGS) $(PYFILE) -I$(PYDIR) -I$(SIMDIR) -DHAVE_CONFIG_H
$(GPP) -c $(PLATFORM_CC_FLAGS) $(PLATFORM_FLAGS) -o $(CXXOBJFILE) $(OPTFLAGS) $(CFLAGS) $(CXXFILE) -I$(PYDIR) -I$(SIMDIR)
+ $(GPP) -c $(PLATFORM_CC_FLAGS) $(PLATFORM_FLAGS) -o $(HASHOBJFILE) $(OPTFLAGS) $(CFLAGS) $(HASHFILE) -I$(PYDIR) -I$(SIMDIR)
@echo " linking into shared object ./$(SHARED_OBJECT)"
- $(GPP) $(PLATFORM_BUILD_FLAGS) $(PLATFORM_CC_FLAGS) $(PYOBJFILE) $(OBJFILE) $(CXXOBJFILE) $(PLATFORM_LIB_FLAGS) -o $(SHARED_OBJECT)
+ $(GPP) $(PLATFORM_BUILD_FLAGS) $(PLATFORM_CC_FLAGS) $(PYOBJFILE) $(OBJFILE) $(CXXOBJFILE) $(HASHOBJFILE) $(PLATFORM_LIB_FLAGS) -o $(SHARED_OBJECT)
@echo " copying Python script interface TOSSIM.py from lib/tossim to local directory"
@cp $(TOSDIR)/lib/tossim/TOSSIM.py .
@echo " "
TOSDIR := $(shell ncc -print-tosdir)
endif
-ifndef TOS_BETADIR
-TOS_BETADIR := $(TOSDIR)/../beta/tos
-endif
-
MSP_BSL ?= tos-bsl
+#Flash Config
+VOLUME_FILE = volumes-at45db.xml
+VOLUME_ALLOCATOR = tos-storage-at45db
+
OPTFLAGS += -Os
#OPTFLAGS =
PFLAGS += -mdisable-hwmul
PFLAGS += -mstrict-align
-PFLAGS += \
--I$(TOS_BETADIR)/platforms/tinynode
-
$(call TOSMake_include_platform,tinynode)
$(call TOSMake_include_platform,msp)
if (!msg)
exit(0);
- printf("addr %u, length %u, group %u, type %u\n ",
- spacket_header_addr_get(msg),
+ printf("dest %u, src %u, length %u, group %u, type %u\n ",
+ spacket_header_dest_get(msg),
+ spacket_header_src_get(msg),
spacket_header_length_get(msg),
spacket_header_group_get(msg),
spacket_header_type_get(msg));
rm -f tinyos.jar
@# create the jar, as update requires it to exist. we use a
@# .class file we assume always exists
- find . -name '*.class' | xargs jar cf tinyos.jar
+ find . | grep -E "class|jpg|gif" | xargs jar cf tinyos.jar
+
javadoc: all
rm -rf $(JAVADOCDIR)
* Construct a new message of the given size.
* @param data_length The size of the message to create.
*/
- protected Message(int data_length) {
+ public Message(int data_length) {
init(data_length);
}
- protected void init(int data_length) {
+ public void init(int data_length) {
init(new byte[data_length]);
}
* @param data_length The size of the message to create.
* @param base_offset The base offset into the newly created message.
*/
- protected Message(int data_length, int base_offset) {
+ public Message(int data_length, int base_offset) {
init(data_length, base_offset);
}
protected void init(int data_length, int base_offset) {
* The length of data determines the length of this message.
* @param data the storage for this message
*/
- protected Message(byte[] data) {
+ public Message(byte[] data) {
init(data);
}
protected void init(byte[] data) {
* @param data the storage for this message
* @param base_offset the base offset into the data array
*/
- protected Message(byte[] data, int base_offset) {
+ public Message(byte[] data, int base_offset) {
init(data, base_offset);
}
protected void init(byte[] data, int base_offset) {
* @param base_offset the base offset into the data array
* @param data_length the length of the message data
*/
- protected Message(byte[] data, int base_offset, int data_length) {
+ public Message(byte[] data, int base_offset, int data_length) {
init(data, base_offset, data_length);
}
protected void init(byte[] data, int base_offset, int data_length) {
* @param base_offset the base offset into the data array
* @param data_length the length of the message data
*/
- protected Message(Message msg, int base_offset, int data_length) {
+ public Message(Message msg, int base_offset, int data_length) {
init(msg, base_offset, data_length);
}
protected void init(Message msg, int base_offset, int data_length) {
* data[0..getData().length - 1] are invalid
*/
public void dataSet(byte[] data) {
- dataSet(data, 0, 0, Math.min(this.data_length, data.length));
+ dataSet(data, 0, this.base_offset, Math.min(this.data_length, data.length));
}
/**
error(temp, "invalid length message received (too short)");
continue;
}
- temp.listener.messageReceived(msg.get_header_addr(), received);
+ temp.listener.messageReceived(msg.get_header_dest(), received);
}
}
}
SerialPacket packet =
new SerialPacket(SerialPacket.offset_data(0) + data.length);
- packet.set_header_addr(moteId);
+ packet.set_header_dest(moteId);
packet.set_header_type((short)amType);
packet.set_header_length((short)data.length);
packet.dataSet(data, 0, packet.offset_data(0), data.length);
Platform.add(Platform.x, "mica2dot", 19200);
Platform.add(Platform.x, "telos", 115200);
Platform.add(Platform.x, "telosb", 115200);
+ Platform.add(Platform.x, "tinynode", 115200);
Platform.add(Platform.x, "tmote", 115200);
Platform.add(Platform.x, "micaz", 57600);
- Platform.add(Platform.x, "eyes", 115200);
+ Platform.add(Platform.x, "eyesIFX", 57600);
Platform.add(Platform.x, "intelmote2", 115200);
}
}
# Makefile for tools/java/net/tinyos/packet
-INITIAL_TARGETS = Serial.class
+INITIAL_TARGETS = Serial.class Serial.java
ROOT = ../../..
include $(ROOT)/Makefile.include
TOS=$(shell ncc -print-tosdir)
SERIAL_H = $(TOS)/lib/serial/Serial.h
-Serial.java: $(SERIAL_H)
+Serial.java: $(SERIAL_H) FORCE
ncg -o $@ -java-classname=net.tinyos.packet.Serial java $(SERIAL_H) Serial.h
writeFramedPacket(P_UNKNOWN, packetType, ackPacket, 0);
}
catch (IOException e) { }
- message(name + ": ignoring unknown packet type " +
+ message(name + ": ignoring unknown packet type 0x" +
Integer.toHexString(packetType));
}
}
+#!/bin/bash
## NOTE: This is for MY rpm setup. Don't expect it to work for you...
# For linux, change to /usr/src/redhat
# For my cygwin: /cygdrive/c/rpmsrc
-RPMS=/cygdrive/c/rpmsrc
-TINYOS_VERSION=2.0.0beta2
-TINYOS_TOOLS_VERSION=1.2.2
-VM_VERSION=1.1.1Mar2004cvs
-TINYDB_VERSION=1.1.3July2004cvs
-CONTRIB_VERSION=1.1.4Apr2005cvs
+RPMS=/usr/src/redhat
+TINYOS_VERSION=2.0.0
+TINYOS_TOOLS_VERSION=1.2.3
echo "*** Building tarballs"
#rm ../../../*.tar.gz
NAME=tinyos-tools
-VERSION=1.2.2
+VERSION=1.2.3
cd ../..
rm -rf $NAME-$VERSION
Summary: TinyOS tools
Name: tinyos-tools
-Version: 1.2.2
+Version: 1.2.3
Release: 1
License: Please see source
Group: Development/System
NAME=tinyos
-VERSION=2.0.0beta2
+VERSION=2.0.0
cd ../..
rm -rf $NAME-$VERSION
tools/release/extractor $NAME-$VERSION <<'EOF' | gzip >../$NAME-$VERSION.tar.gz
-!^./apps/tests/(eyesIFX|mica2|msp430|RadioStress|TestAlarm|TestAMService|TestBroadcast|TestCollection|TestNetwork|TestPowerManager|TestPowerup|TestSerialBandwidth|TestSleep|TestTimerSync|TestTreeRouting|TestTrickleTimer)
+!^./apps/tests/(eyesIFX|mica2|msp430|RadioStress|TestAlarm|TestAMOnOff|TestAMService|TestBroadcast|TestCollection|TestPowerManager|TestPowerup|TestPrintf|TestRadioPM|TestScheduler|TestSerialBandwidth|TestSleep|TestTimerSync|TestTreeRouting|TestTrickleTimer)
+!^/apps/(BlinkAlarm|BlinkMSP430|BlinkTask|BlinkToRadio|Test|TestADC|TestArbiter|TestCC2420|TestRadio|TestSPI|TestScheduler|TestSchedulerTemp|TestSerial)
!^./doc
!^./overall-todo.txt
!^./support/make/Makelocal
!^./support/make/btnode3.target
!^./support/make/telosa.target
!^./tools
-!^./tos/chips/sht11
-!^./tos/sensorboards/mts300
-!^./tos/sensorboards/im2sb
+!^./tos/chips/cc1000_pm
+!^./tos/chips/cc2420_pm
+!^./tos/lib/deluge
+!^./tos/lib/printf
!^./tos/platforms/btnode3
+!^./tos/sensorboards/mts300
!/.cvsignore
!/CVS/
!/CVS$
tos-install-jni.1 \
tos-locate-jre.1 \
tos-mote-key.1 \
+ tos-mviz.1 \
tos-serial-configure.1 \
tos-serial-debug.1 \
tos-set-symbols.1 \
tos-install-jni \
tos-locate-jre \
tos-mote-key \
+ tos-mviz \
tos-serial-configure \
tos-set-symbols \
tos-write-image \
#include <fcntl.h>
#include <termios.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#ifdef __CYGWIN__
async command error_t Pot.set(uint8_t setting) {
call ENPOT.clr();
- call SpiByte.write(setting, 0);
+ call SpiByte.write(setting);
call ENPOT.set();
atomic Pot_value = setting;
return SUCCESS;
ArbiterInfo = Arbiter;
MainC.SoftwareInit -> At45dbP;
- MainC.SoftwareInit -> Arbiter;
At45dbP.HplAt45db -> HplAt45dbC;
At45dbP.BusyWait -> BusyWaitMicroC;
}
erased/programmed many times (there is a 2 page cache, but
random writes are unlikely to hit in it).
- The cache is only flushed on commit.
+ The cache is only flushed on sync.
The first page of a block storage volume stores the maximum address
written in the block and a CRC of the block's contents (up to that
- maximum address). This CRC is written at commit time and verified at
+ maximum address). This CRC is written at sync time and verified at
validate time.
This BlockStorage code is reused in the implementation of
R_IDLE,
R_WRITE,
R_ERASE,
- R_COMMIT,
+ R_SYNC,
R_READ,
- R_VERIFY,
R_CRC,
};
- enum {
- META_IDLE,
- META_COMMIT,
- META_VERIFY
- };
-
enum {
N = uniqueCount(UQ_BLOCK_STORAGE) + uniqueCount(UQ_CONFIG_STORAGE),
NO_CLIENT = 0xff
};
uint8_t client = NO_CLIENT;
- uint8_t metaState;
storage_addr_t bytesRemaining;
- nx_struct {
- nx_uint16_t crc;
- nx_uint32_t maxAddr;
- } sig;
struct {
/* The latest request made for this client, and it's arguments */
uint8_t *buf;
storage_addr_t addr;
storage_len_t len;
-
- /* Maximum address written in this block */
- storage_addr_t maxAddr;
} s[N];
/* ------------------------------------------------------------------ */
void eraseStart();
- void verifyStart();
+ void syncStart();
void multipageStart(storage_len_t len, uint16_t crc);
void startRequest() {
case R_ERASE:
eraseStart();
break;
- case R_VERIFY:
- verifyStart();
+ case R_SYNC:
+ syncStart();
break;
default:
multipageStart(s[client].len, (uint16_t)s[client].buf);
case R_CRC:
signal BlockRead.computeCrcDone[c](addr, actualLength, crc, result);
break;
- case R_COMMIT:
- signal BlockWrite.commitDone[c](result);
- break;
- case R_VERIFY:
- signal BlockRead.verifyDone[c](result);
+ case R_SYNC:
+ signal BlockWrite.syncDone[c](result);
break;
}
}
event void Resource.granted[uint8_t blockId]() {
client = blockId;
- if (s[blockId].request == R_WRITE)
+ if (s[blockId].request == R_WRITE &&
+ call BConfig.writeHook[blockId]())
{
- if (s[blockId].addr + s[blockId].len > s[blockId].maxAddr)
- s[blockId].maxAddr = s[blockId].addr + s[blockId].len;
-
- if (call BConfig.writeHook[blockId]())
- {
- /* Config write intercept. We'll get a writeContinue when it's
- time to resume. */
- client = NO_CLIENT;
- return;
- }
+ /* Config write intercept. We'll get a writeContinue when it's
+ time to resume. */
+ client = NO_CLIENT;
+ return;
}
startRequest();
}
/* Multipage operations */
/* ------------------------------------------------------------------ */
- void commitCrcDone(uint16_t crc);
- void verifyCrcDone(uint16_t crc);
-
- void multipageDone(uint16_t crc) {
- switch (s[client].request)
- {
- default: endRequest(SUCCESS, crc); break;
- case R_COMMIT: commitCrcDone(crc); break;
- case R_VERIFY: verifyCrcDone(crc); break;
- }
- }
-
void calcRequest(storage_addr_t addr, at45page_t *page,
at45pageoffset_t *offset, at45pageoffset_t *count) {
*page = pageRemap(addr >> AT45_PAGE_SIZE_LOG2);
if (bytesRemaining == 0)
{
- multipageDone(crc);
+ endRequest(SUCCESS, crc);
return;
}
case R_READ:
call At45db.read(page, offset, buf, count);
break;
- default:
+ case R_CRC:
call At45db.computeCrc(page, offset, count, crc);
break;
}
}
void multipageStart(storage_len_t len, uint16_t crc) {
- metaState = META_IDLE;
bytesRemaining = len;
multipageContinue(crc);
}
}
/* ------------------------------------------------------------------ */
- /* Commit */
+ /* Sync */
/* ------------------------------------------------------------------ */
- command error_t BlockWrite.commit[uint8_t id]() {
- return newRequest(R_COMMIT, id, 0, NULL, s[id].maxAddr);
+ command error_t BlockWrite.sync[uint8_t id]() {
+ return newRequest(R_SYNC, id, 0, NULL, 0);
}
- /* Called once crc computed. Write crc + signature in block 0. */
- void commitCrcDone(uint16_t crc) {
- sig.crc = crc;
- sig.maxAddr = s[client].maxAddr;
- metaState = META_COMMIT;
- call At45db.write(pageRemap(0), 1 << AT45_PAGE_SIZE_LOG2, &sig, sizeof sig);
- }
-
- void commitWriteDone(error_t error) {
- if (error == SUCCESS)
- call At45db.syncAll();
- else
- endRequest(error, 0);
+ void syncStart() {
+ call At45db.syncAll();
}
- void commitSyncDone(error_t error) {
+ void syncSyncDone(error_t error) {
endRequest(error, 0);
}
- /* ------------------------------------------------------------------ */
- /* Verify */
- /* ------------------------------------------------------------------ */
-
- command error_t BlockRead.verify[uint8_t id]() {
- return newRequest(R_VERIFY, id, 0, NULL, 0);
- }
-
- void verifyStart() {
- metaState = META_VERIFY;
- call At45db.read(pageRemap(0), 1 << AT45_PAGE_SIZE_LOG2, &sig, sizeof sig);
- }
-
- /* See signature written in commit */
- void verifyReadDone(error_t error) {
- if (error == SUCCESS)
- {
- storage_addr_t max = sig.maxAddr;
-
- /* Ignore maxAddress values that are too large */
- if (max <= call BlockRead.getSize[client]())
- {
- s[client].addr = 0;
- s[client].maxAddr = max;
- multipageStart(max, 0);
- return;
- }
- }
- endRequest(FAIL, 0);
- }
-
- void verifyCrcDone(uint16_t crc) {
- if (crc == sig.crc)
- endRequest(SUCCESS, 0);
- else
- {
- s[client].maxAddr = 0;
- endRequest(FAIL, 0);
- }
- }
-
/* ------------------------------------------------------------------ */
/* Read */
/* ------------------------------------------------------------------ */
event void At45db.writeDone(error_t result) {
if (client != NO_CLIENT)
- if (metaState == META_IDLE)
- multipageOpDone(result, 0);
- else
- commitWriteDone(result);
+ multipageOpDone(result, 0);
}
event void At45db.readDone(error_t result) {
if (client != NO_CLIENT)
- if (metaState == META_IDLE)
- multipageOpDone(result, 0);
- else
- verifyReadDone(result);
+ multipageOpDone(result, 0);
}
event void At45db.computeCrcDone(error_t result, uint16_t newCrc) {
event void At45db.syncDone(error_t result) {
if (client != NO_CLIENT)
- commitSyncDone(result);
+ syncSyncDone(result);
}
event void At45db.flushDone(error_t result) { }
event void At45db.copyPageDone(error_t error) { }
default event void BlockWrite.writeDone[uint8_t id](storage_addr_t addr, void* buf, storage_len_t len, error_t result) { }
default event void BlockWrite.eraseDone[uint8_t id](error_t result) { }
- default event void BlockWrite.commitDone[uint8_t id](error_t result) { }
+ default event void BlockWrite.syncDone[uint8_t id](error_t result) { }
default event void BlockRead.readDone[uint8_t id](storage_addr_t addr, void* buf, storage_len_t len, error_t result) { }
- default event void BlockRead.verifyDone[uint8_t id](error_t result) { }
default event void BlockRead.computeCrcDone[uint8_t id](storage_addr_t addr, storage_len_t len, uint16_t x, error_t result) { }
default command at45page_t At45dbVolume.remap[uint8_t id](at45page_t volumePage) { return 0; }
default command at45page_t At45dbVolume.volumeSize[uint8_t id]() { return 0; }
default async command error_t Resource.request[uint8_t id]() { return FAIL; }
- default async command void Resource.release[uint8_t id]() { }
+ default async command error_t Resource.release[uint8_t id]() { return FAIL; }
}
*/
#include "Storage.h"
+#include "crc.h"
module ConfigStorageP {
provides {
enum {
S_STOPPED,
S_MOUNT,
+ S_COMMIT,
S_CLEAN,
S_DIRTY,
S_INVALID
NO_CLIENT = 0xff,
};
- /* Per-client state */
- uint8_t state[N];
+ /* Per-client state. We could keep just the state and current version
+ in an array, but this requires more complex arbitration (don't
+ release block storage during mount or commit). As I don't expect
+ many config volumes, this doesn't seem worth the trouble. */
+ struct {
+ uint8_t state : 3;
+ uint8_t committing : 1;
+ } s[N];
+ nx_struct {
+ nx_uint16_t crc;
+ nx_uint32_t version;
+ } low[N], high[N];
- /* Version numbers for lower and upper half */
- uint32_t lowVersion[N], highVersion[N];
/* Bit n is true if client n is using upper block */
uint8_t flipState[(N + 7) / 8];
setFlip(id, !flipped(id));
}
+ storage_len_t volumeSize(uint8_t id) {
+ return call BlockRead.getSize[id]();
+ }
+
/* ------------------------------------------------------------------ */
/* Mounting */
/* ------------------------------------------------------------------ */
command error_t Mount.mount[uint8_t id]() {
/* Read version on both halves. Validate higher. Validate lower if
higher invalid. Use lower if both invalid. */
- if (state[id] != S_STOPPED)
+ if (s[id].state != S_STOPPED)
return FAIL;
- state[id] = S_MOUNT;
+ s[id].state = S_MOUNT;
setFlip(id, FALSE);
- call BlockRead.read[id](0, &lowVersion[id], sizeof lowVersion[id]);
+ call BlockRead.read[id](0, &low[id], sizeof low[id]);
return SUCCESS;
}
+ void computeCrc(uint8_t id) {
+ call BlockRead.computeCrc[id](sizeof(nx_uint16_t),
+ volumeSize(id) - sizeof(nx_uint16_t),
+ 0);
+ }
+
void mountReadDone(uint8_t id, error_t error) {
if (error != SUCCESS)
{
- state[id] = S_STOPPED;
+ s[id].state = S_STOPPED;
signal Mount.mountDone[id](FAIL);
}
else if (!call BConfig.flipped[id]())
{
/* Just read low-half version. Read high-half version */
setFlip(id, TRUE);
- call BlockRead.read[id](0, &highVersion[id], sizeof highVersion[id]);
+ call BlockRead.read[id](0, &high[id], sizeof high[id]);
}
else
{
/* Verify the half with the largest version */
- setFlip(id, highVersion[id] > lowVersion[id]);
- call BlockRead.verify[id]();
+ setFlip(id, high[id].version > low[id].version);
+ computeCrc(id);
}
}
- void mountVerifyDone(uint8_t id, error_t error) {
- if (error == SUCCESS)
- state[id] = S_CLEAN;
+ void mountCrcDone(uint8_t id, uint16_t crc, error_t error) {
+ bool isflipped = call BConfig.flipped[id]();
+
+ if (error == SUCCESS &&
+ crc == (isflipped ? high[id].crc : low[id].crc))
+ {
+ /* We just use the low data once mounted */
+ if (isflipped)
+ low[id].version = high[id].version;
+ s[id].state = S_CLEAN;
+ }
else
{
// try the other half?
- bool isflipped = call BConfig.flipped[id]();
-
- if ((highVersion[id] > lowVersion[id]) == isflipped)
+ if ((high[id].version > low[id].version) == isflipped)
{
/* Verification of the half with the highest version failed. Try
the other half. */
setFlip(id, !isflipped);
- call BlockRead.verify[id]();
+ computeCrc(id);
return;
}
- /* both halves bad, just declare success and use the current half... */
- state[id] = S_INVALID;
- lowVersion[id] = highVersion[id] = 0;
+ /* Both halves bad, terminate. Reads will fail. */
+ s[id].state = S_INVALID;
+ low[id].version = 0;
}
signal Mount.mountDone[id](SUCCESS);
}
command error_t ConfigStorage.read[uint8_t id](storage_addr_t addr, void* buf, storage_len_t len) {
/* Read from current half using BlockRead */
- if (state[id] < S_CLEAN)
+ if (s[id].state < S_CLEAN)
return EOFF;
- if (state[id] == S_INVALID) // nothing to read
+ if (s[id].state == S_INVALID) // nothing to read
return FAIL;
- return call BlockRead.read[id](addr + sizeof(uint32_t), buf, len);
+ return call BlockRead.read[id](addr + sizeof low[0], buf, len);
}
void readReadDone(uint8_t id, storage_addr_t addr, void* buf, storage_len_t len, error_t error) {
- signal ConfigStorage.readDone[id](addr - sizeof(uint32_t), buf, len, error);
+ signal ConfigStorage.readDone[id](addr - sizeof low[0], buf, len, error);
}
/* ------------------------------------------------------------------ */
copy to other half with incremented version number
2: Write to other half using BlockWrite */
- if (state[id] < S_CLEAN)
+ if (s[id].state < S_CLEAN)
return EOFF;
- return call BlockWrite.write[id](addr + sizeof(uint32_t), buf, len);
+ return call BlockWrite.write[id](addr + sizeof low[0], buf, len);
}
void copyCopyPageDone(error_t error);
void writeContinue(error_t error);
command int BConfig.writeHook[uint8_t id]() {
+ if (s[id].committing)
+ return FALSE;
+
flip(id); /* We write to the non-current half... */
- if (state[id] != S_CLEAN) // no copy if dirty or invalid
+ if (s[id].state != S_CLEAN) // no copy if dirty or invalid
return FALSE;
- /* Time to do the copy, version update dance */
+ /* Time to do the copy dance */
client = id;
nextPage = signal BConfig.npages[id]();
copyCopyPageDone(SUCCESS);
writeContinue(error);
else if (nextPage == 0) // copy done
{
- uint32_t *version;
-
- // Update the version number of the half indicated by flipped()
- if (!flipped(client))
- {
- lowVersion[client] = highVersion[client] + 1;
- version = &lowVersion[client];
- }
- else
- {
- highVersion[client] = lowVersion[client] + 1;
- version = &highVersion[client];
- }
- call At45db.write(signal BConfig.remap[client](0), 0,
- version, sizeof *version);
+ s[client].state = S_DIRTY;
+ writeContinue(SUCCESS);
}
else
{
}
}
- void copyWriteDone(error_t error) {
- if (error == SUCCESS)
- state[client] = S_DIRTY;
- writeContinue(error);
- }
-
void writeContinue(error_t error) {
uint8_t id = client;
void writeWriteDone(uint8_t id, storage_addr_t addr, void* buf, storage_len_t len, error_t error) {
flip(id); // flip back to current half
- signal ConfigStorage.writeDone[id](addr - sizeof(uint32_t), buf, len, error);
+ signal ConfigStorage.writeDone[id](addr - sizeof low[0], buf, len, error);
}
/* ------------------------------------------------------------------ */
/* Commit */
/* ------------------------------------------------------------------ */
+ void commitSyncDone(uint8_t id, error_t error);
+
command error_t ConfigStorage.commit[uint8_t id]() {
- /* Call BlockWrite.commit */
- /* Could special-case attempt to commit clean block */
error_t ok;
+ uint16_t crc;
+ uint8_t i;
- if (state[id] < S_CLEAN)
+ if (s[id].state < S_CLEAN)
return EOFF;
- ok = call BlockWrite.commit[id]();
+
+ if (s[id].state == S_CLEAN)
+ /* A dummy CRC call to avoid signaling a completion event from here */
+ return call BlockRead.computeCrc[id](0, 1, 0);
+
+ /* Compute CRC for new version and current contents */
+ flip(id);
+ low[id].version++;
+ for (crc = 0, i = 0; i < sizeof low[id].version; i++)
+ crc = crcByte(crc, ((uint8_t *)&low[id] + sizeof(nx_uint16_t))[i]);
+ ok = call BlockRead.computeCrc[id](sizeof low[id],
+ volumeSize(id) - sizeof low[id],
+ crc);
if (ok == SUCCESS)
- flip(id); // switch to new block for commit
+ s[id].committing = TRUE;
+
return ok;
}
- void commitDone(uint8_t id, error_t error) {
+ void commitCrcDone(uint8_t id, uint16_t crc, error_t error) {
+ /* Weird commit of clean volume hack: we just complete now, w/o
+ really doing anything. Ideally we should short-circuit out in the
+ commit call, but that would break the "no-signal-from-command"
+ rule. So we just waste the CRC computation effort instead - the
+ assumption is people don't regularly commit clean volumes. */
+ if (s[id].state == S_CLEAN)
+ signal ConfigStorage.commitDone[id](error);
+ else if (error != SUCCESS)
+ commitSyncDone(id, error);
+ else
+ {
+ low[id].crc = crc;
+ call BlockWrite.write[id](0, &low[id], sizeof low[id]);
+ }
+ }
+
+ void commitWriteDone(uint8_t id, error_t error) {
+ if (error != SUCCESS)
+ commitSyncDone(id, error);
+ else
+ call BlockWrite.sync[id]();
+ }
+
+ void commitSyncDone(uint8_t id, error_t error) {
+ s[id].committing = FALSE;
if (error == SUCCESS)
- state[id] = S_CLEAN;
+ s[id].state = S_CLEAN;
else
flip(id); // revert to old block
signal ConfigStorage.commitDone[id](error);
/* ------------------------------------------------------------------ */
command storage_len_t ConfigStorage.getSize[uint8_t id]() {
- return call BlockRead.getSize[id]();
+ return volumeSize(id) - sizeof low[0];
}
/* ------------------------------------------------------------------ */
/* ------------------------------------------------------------------ */
command bool ConfigStorage.valid[uint8_t id]() {
- return state[id] != S_INVALID;
+ return s[id].state != S_INVALID;
}
/* ------------------------------------------------------------------ */
event void BlockRead.readDone[uint8_t id](storage_addr_t addr, void* buf, storage_len_t len, error_t error) {
if (id < N)
- if (state[id] == S_MOUNT)
+ if (s[id].state == S_MOUNT)
mountReadDone(id, error);
else
readReadDone(id, addr, buf, len, error);
}
- event void BlockRead.verifyDone[uint8_t id]( error_t error ) {
- if (id < N)
- mountVerifyDone(id, error);
- }
-
event void BlockWrite.writeDone[uint8_t id]( storage_addr_t addr, void* buf, storage_len_t len, error_t error ) {
if (id < N)
- writeWriteDone(id, addr, buf, len, error);
+ if (s[id].committing)
+ commitWriteDone(id, error);
+ else
+ writeWriteDone(id, addr, buf, len, error);
}
- event void BlockWrite.commitDone[uint8_t id]( error_t error ) {
+ event void BlockWrite.syncDone[uint8_t id]( error_t error ) {
if (id < N)
- commitDone(id, error);
+ commitSyncDone(id, error);
}
- event void At45db.writeDone(error_t error) {
- if (client != NO_CLIENT)
- copyWriteDone(error);
+ event void BlockRead.computeCrcDone[uint8_t id]( storage_addr_t addr, storage_len_t len, uint16_t crc, error_t error ) {
+ if (id < N)
+ if (s[id].state == S_MOUNT)
+ mountCrcDone(id, crc, error);
+ else
+ commitCrcDone(id, crc, error);
}
event void At45db.copyPageDone(error_t error) {
copyCopyPageDone(error);
}
- event void BlockRead.computeCrcDone[uint8_t id]( storage_addr_t addr, storage_len_t len, uint16_t crc, error_t error ) {}
- event void BlockWrite.eraseDone[uint8_t id]( error_t error ) {}
+ event void BlockWrite.eraseDone[uint8_t id](error_t error) {}
event void At45db.eraseDone(error_t error) {}
event void At45db.syncDone(error_t error) {}
event void At45db.flushDone(error_t error) {}
event void At45db.readDone(error_t error) {}
event void At45db.computeCrcDone(error_t error, uint16_t crc) {}
+ event void At45db.writeDone(error_t error) {}
default event void Mount.mountDone[uint8_t id](error_t error) { }
default event void ConfigStorage.readDone[uint8_t id](storage_addr_t addr, void* buf, storage_len_t len, error_t error) {}
}
void requestFlashStatus() {
- uint8_t dummy;
-
call HplAt45dbByte.select();
- call FlashSpi.write(AT45_C_REQ_STATUS, &dummy);
+ call FlashSpi.write(AT45_C_REQ_STATUS);
call HplAt45dbByte.waitIdle();
}
else /* P_COMMAND */
break;
- call FlashSpi.write(out, &in);
+ in = call FlashSpi.write(out);
}
call HplAt45dbByte.deselect();
}
uint8_t client = NO_CLIENT;
uint8_t metaState;
+ bool recordsLost;
at45page_t firstPage, lastPage;
storage_len_t len;
nx_struct pageinfo metadata;
switch (request)
{
case R_ERASE: signal LogWrite.eraseDone[c](ok); break;
- case R_APPEND: signal LogWrite.appendDone[c](ptr, actualLen, ok); break;
+ case R_APPEND: signal LogWrite.appendDone[c](ptr, actualLen, recordsLost, ok); break;
case R_SYNC: signal LogWrite.syncDone[c](ok); break;
case R_READ: signal LogRead.readDone[c](ptr, actualLen, ok); break;
case R_SEEK: signal LogRead.seekDone[c](ok); break;
s[client].woffset += count;
len -= count;
+ /* We normally lose data at the point we make the first write to a
+ page in a log that has circled. */
+ if (offset == 0 && s[client].circled)
+ recordsLost = TRUE;
+
call At45db.write(s[client].wpage, offset, buf, count);
}
void appendStart() {
storage_len_t vlen = (storage_len_t)npages() * PAGE_SIZE;
+ recordsLost = FALSE;
+
/* If request would span the end of the flash, sync, to maintain the
invariant that the last flash page is synced and that either
the first or last pages are valid.
s[client].rpage = s[client].wpage;
else
{
- /* resume writing at the beginning of the first page */
+ /* resume reading at the beginning of the first page */
s[client].rvalid = TRUE;
s[client].rpage = lastVolumePage() - 1;
}
event void At45db.copyPageDone(error_t error) { }
- default event void LogWrite.appendDone[uint8_t logId](void* buf, storage_len_t l, error_t error) { }
+ default event void LogWrite.appendDone[uint8_t logId](void* buf, storage_len_t l, bool rLost, error_t error) { }
default event void LogWrite.eraseDone[uint8_t logId](error_t error) { }
default event void LogWrite.syncDone[uint8_t logId](error_t error) { }
default event void LogRead.readDone[uint8_t logId](void* buf, storage_len_t l, error_t error) { }
default command at45page_t At45dbVolume.remap[uint8_t logId](at45page_t volumePage) {return 0;}
default command at45page_t At45dbVolume.volumeSize[uint8_t logId]() {return 0;}
default async command error_t Resource.request[uint8_t logId]() {return SUCCESS;}
- default async command void Resource.release[uint8_t logId]() { }
+ default async command error_t Resource.release[uint8_t logId]() { return FAIL; }
}
configuration HplAtm128UartC
{
provides {
- interface Init as Uart0Init;
interface StdControl as Uart0TxControl;
interface StdControl as Uart0RxControl;
- interface SerialByteComm as Uart0;
+ interface HplAtm128Uart as HplUart0;
- interface Init as Uart1Init;
interface StdControl as Uart1TxControl;
interface StdControl as Uart1RxControl;
- interface SerialByteComm as Uart1;
+ interface HplAtm128Uart as HplUart1;
}
}
implementation
{
components HplAtm128UartP, PlatformC, McuSleepC;
-
- Uart0Init = HplAtm128UartP.Uart0Init;
+
Uart0TxControl = HplAtm128UartP.Uart0TxControl;
Uart0RxControl = HplAtm128UartP.Uart0RxControl;
- Uart0 = HplAtm128UartP.Uart0;
-
- Uart1Init = HplAtm128UartP.Uart1Init;
+ HplUart0 = HplAtm128UartP.HplUart0;
+
Uart1TxControl = HplAtm128UartP.Uart1TxControl;
Uart1RxControl = HplAtm128UartP.Uart1RxControl;
- Uart1 = HplAtm128UartP.Uart1;
-
+ HplUart1 = HplAtm128UartP.HplUart1;
+
HplAtm128UartP.Atm128Calibrate -> PlatformC;
HplAtm128UartP.McuPowerState -> McuSleepC;
+
+ components MainC;
+ MainC.SoftwareInit -> HplAtm128UartP.Uart0Init;
+ MainC.SoftwareInit -> HplAtm128UartP.Uart1Init;
+
}
-/// $Id$
+/*
+ * Copyright (c) 2006 Arch Rock Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ * - Neither the name of the Arch Rock Corporation nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * ARCH ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE
+ */
+
+/**
+ * @author Alec Woo <awoo@archrock.com>
+ * @author Jonathan Hui <jhui@archrock.com>
+ * @version $Revision$ $Date$
+ */
/*
* Copyright (c) 2004-2005 Crossbow Technology, Inc. All rights reserved.
* MODIFICATIONS.
*/
-#include <Atm128Uart.h>
-
/**
* Private component of the Atmega128 serial port HPL.
*
* @author David Gay
*/
-module HplAtm128UartP
-{
- provides {
- interface Init as Uart0Init;
- interface StdControl as Uart0TxControl;
- interface StdControl as Uart0RxControl;
- interface SerialByteComm as Uart0;
+#include <Atm128Uart.h>
+
+module HplAtm128UartP {
+
+ provides interface Init as Uart0Init;
+ provides interface StdControl as Uart0TxControl;
+ provides interface StdControl as Uart0RxControl;
+ provides interface HplAtm128Uart as HplUart0;
- interface Init as Uart1Init;
- interface StdControl as Uart1TxControl;
- interface StdControl as Uart1RxControl;
- interface SerialByteComm as Uart1;
- }
- uses {
- interface Atm128Calibrate;
- interface McuPowerState;
- }
+ provides interface Init as Uart1Init;
+ provides interface StdControl as Uart1TxControl;
+ provides interface StdControl as Uart1RxControl;
+ provides interface HplAtm128Uart as HplUart1;
+
+ uses interface Atm128Calibrate;
+ uses interface McuPowerState;
}
-implementation
-{
+implementation {
+
//=== Uart Init Commands. ====================================
command error_t Uart0Init.init() {
Atm128UartMode_t mode;
}
command error_t Uart0TxControl.start() {
- Atm128UartControl_t ctrl;
- ctrl.flat = UCSR0B;
- ctrl.bits.txcie = 1;
- ctrl.bits.txen = 1;
- UCSR0B = ctrl.flat;
+ SET_BIT(UCSR0B, TXCIE);
+ SET_BIT(UCSR0B, TXEN);
call McuPowerState.update();
return SUCCESS;
}
command error_t Uart0TxControl.stop() {
- Atm128UartControl_t ctrl;
- ctrl.flat = UCSR0B;
- ctrl.bits.txcie = 0;
- ctrl.bits.txen = 0;
- UCSR0B = ctrl.flat;
+ CLR_BIT(UCSR0B, TXCIE);
+ CLR_BIT(UCSR0B, TXEN);
call McuPowerState.update();
return SUCCESS;
}
command error_t Uart0RxControl.start() {
- Atm128UartControl_t ctrl;
- ctrl.flat = UCSR0B;
- ctrl.bits.rxcie = 1;
- ctrl.bits.rxen = 1;
- UCSR0B = ctrl.flat;
+ SET_BIT(UCSR0B, RXCIE);
+ SET_BIT(UCSR0B, RXEN);
call McuPowerState.update();
return SUCCESS;
}
command error_t Uart0RxControl.stop() {
- Atm128UartControl_t ctrl;
- ctrl.flat = UCSR0B;
- ctrl.bits.rxcie = 0;
- ctrl.bits.rxen = 0;
- UCSR0B = ctrl.flat;
+ CLR_BIT(UCSR0B, RXCIE);
+ CLR_BIT(UCSR0B, RXEN);
call McuPowerState.update();
return SUCCESS;
}
+
+ async command error_t HplUart0.enableTxIntr() {
+ SET_BIT(UCSR0B, TXEN);
+ return SUCCESS;
+ }
+
+ async command error_t HplUart0.disableTxIntr(){
+ CLR_BIT(UCSR0B, TXEN);
+ return SUCCESS;
+ }
+
+ async command error_t HplUart0.enableRxIntr(){
+ SET_BIT(UCSR0B, RXEN);
+ return SUCCESS;
+ }
+ async command error_t HplUart0.disableRxIntr(){
+ CLR_BIT(UCSR0B, RXEN);
+ return SUCCESS;
+ }
+
+ async command bool HplUart0.isTxEmpty(){
+ return READ_BIT(UCSR0A, TXC);
+ }
+
+ async command bool HplUart0.isRxEmpty(){
+ return !READ_BIT(UCSR0A, RXC);
+ }
+
+ async command uint8_t HplUart0.rx(){
+ return UDR0;
+ }
+
+ async command void HplUart0.tx(uint8_t data) {
+ atomic{
+ UDR0 = data;
+ SET_BIT(UCSR0A, TXC);
+ }
+ }
+
+ AVR_ATOMIC_HANDLER(SIG_UART0_RECV) {
+ if (READ_BIT(UCSR0A, RXC)) {
+ signal HplUart0.rxDone(UDR0);
+ }
+ }
+
+ AVR_NONATOMIC_HANDLER(SIG_UART0_TRANS) {
+ signal HplUart0.txDone();
+ }
command error_t Uart1Init.init() {
Atm128UartMode_t mode;
Atm128UartStatus_t stts;
Atm128UartControl_t ctrl;
uint16_t ubrr1;
-
+
ctrl.bits = (struct Atm128_UCSRB_t) {rxcie:0, txcie:0, rxen:0, txen:0};
stts.bits = (struct Atm128_UCSRA_t) {u2x:1};
mode.bits = (struct Atm128_UCSRC_t) {ucsz:ATM128_UART_DATA_SIZE_8_BITS};
}
command error_t Uart1TxControl.start() {
- Atm128UartControl_t ctrl;
- ctrl.flat = UCSR1B;
- ctrl.bits.txcie = 1;
- ctrl.bits.txen = 1;
- UCSR1B = ctrl.flat;
+ SET_BIT(UCSR1B, TXCIE);
+ SET_BIT(UCSR1B, TXEN);
call McuPowerState.update();
return SUCCESS;
}
command error_t Uart1TxControl.stop() {
- Atm128UartControl_t ctrl;
- ctrl.flat = UCSR1B;
- ctrl.bits.txcie = 0;
- ctrl.bits.txen = 0;
- UCSR1B = ctrl.flat;
+ CLR_BIT(UCSR1B, TXCIE);
+ CLR_BIT(UCSR1B, TXEN);
call McuPowerState.update();
return SUCCESS;
}
command error_t Uart1RxControl.start() {
- Atm128UartControl_t ctrl;
- ctrl.flat = UCSR1B;
- ctrl.bits.rxcie = 1;
- ctrl.bits.rxen = 1;
- UCSR1B = ctrl.flat;
+ SET_BIT(UCSR1B, RXCIE);
+ SET_BIT(UCSR1B, RXEN);
call McuPowerState.update();
return SUCCESS;
}
command error_t Uart1RxControl.stop() {
- Atm128UartControl_t ctrl;
- ctrl.flat = UCSR1B;
- ctrl.bits.rxcie = 0;
- ctrl.bits.rxen = 0;
- UCSR1B = ctrl.flat;
+ CLR_BIT(UCSR1B, RXCIE);
+ CLR_BIT(UCSR1B, RXEN);
call McuPowerState.update();
return SUCCESS;
}
+
+ async command error_t HplUart1.enableTxIntr() {
+ SET_BIT(UCSR1B, TXEN);
+ return SUCCESS;
+ }
+
+ async command error_t HplUart1.disableTxIntr(){
+ CLR_BIT(UCSR1B, TXEN);
+ return SUCCESS;
+ }
+
+ async command error_t HplUart1.enableRxIntr(){
+ SET_BIT(UCSR1B, RXEN);
+ return SUCCESS;
+ }
- /* //=== Uart Stop Commands. ==================================== */
- /* async command error_t Uart0.stop() { */
- /* UCSR0A = 0; */
- /* UCSR0B = 0; */
- /* UCSR0C = 0; */
- /* return SUCCESS; */
- /* } */
- /* async command error_t Uart1.stop() { */
- /* UCSR0A = 0; */
- /* UCSR0B = 0; */
- /* UCSR0C = 0; */
- /* return SUCCESS; */
- /* } */
-
- //=== Uart Put Commands. ====================================
- async command error_t Uart0.put(uint8_t data) {
- atomic{
- UDR0 = data;
- SET_BIT(UCSR0A, TXC);
- }
+ async command error_t HplUart1.disableRxIntr(){
+ CLR_BIT(UCSR1B, RXEN);
return SUCCESS;
}
- async command error_t Uart1.put(uint8_t data) {
+
+ async command bool HplUart1.isTxEmpty() {
+ return READ_BIT(UCSR1A, TXC);
+ }
+
+ async command bool HplUart1.isRxEmpty() {
+ return !READ_BIT(UCSR1A, RXC);
+ }
+
+ async command uint8_t HplUart1.rx(){
+ return UDR1;
+ }
+
+ async command void HplUart1.tx(uint8_t data) {
atomic{
UDR1 = data;
SET_BIT(UCSR1A, TXC);
}
- return SUCCESS;
}
- //=== Uart Get Events. ======================================
- default async event void Uart0.get(uint8_t data) { return; }
- AVR_ATOMIC_HANDLER(SIG_UART0_RECV) {
- if (READ_BIT(UCSR0A, RXC))
- signal Uart0.get(UDR0);
- }
- default async event void Uart1.get(uint8_t data) { return; }
AVR_ATOMIC_HANDLER(SIG_UART1_RECV) {
if (READ_BIT(UCSR1A, RXC))
- signal Uart1.get(UDR1);
+ signal HplUart1.rxDone(UDR1);
}
-
- //=== Uart Put Done Events. =================================
- default async event void Uart0.putDone() { return; }
- AVR_NONATOMIC_HANDLER(SIG_UART0_TRANS) {
- signal Uart0.putDone();
- }
- default async event void Uart1.putDone() { return; }
+
AVR_NONATOMIC_HANDLER(SIG_UART1_TRANS) {
- signal Uart1.putDone();
+ signal HplUart1.txDone();
}
-
+
+ default async event void HplUart0.txDone() {}
+ default async event void HplUart0.rxDone(uint8_t data) {}
+ default async event void HplUart1.txDone() {}
+ default async event void HplUart1.rxDone(uint8_t data) {}
+
}
Atm128AdcP.HplAtm128Adc -> HplAtm128AdcC;
Atm128AdcP.Atm128Calibrate -> PlatformC;
- PM.Init <- MainC;
PM.AsyncStdControl -> Atm128AdcP;
- PM.ArbiterInit -> AdcArbiter;
PM.ResourceController -> AdcArbiter;
}
-/// $Id$
+/// $Id$\r
/*
* Copyright (c) 2004-2005 Crossbow Technology, Inc. All rights reserved.
*
signal Resource.granted[id]();
}
- async command void Resource.release[uint8_t id]() {
+ async command error_t Resource.release[uint8_t id]() {
call Atm128I2C.stop(); // Always stop if someone has released.
- call SubResource.release[id]();
+ return call SubResource.release[id]();
}
async command bool Resource.isOwner[uint8_t id]() {
components new Atm128I2CMasterImplP() as I2C;
components new Atm128I2CMasterPacketP() as Master;
components HplAtm128I2CBusC;
- components LedsC, NoLedsC, MainC;
+ components LedsC, NoLedsC;
Resource = I2C;
I2CPacket = I2C;
- MainC.SoftwareInit -> Power;
I2C.SubResource -> Arbiter;
I2C.SubPacket -> Master;
Power.AsyncStdControl -> Master;
Power.ResourceController -> Arbiter;
- Power.ArbiterInit -> Arbiter;
Master.I2C -> HplAtm128I2CBusC;
Master.ReadDebugLeds -> NoLedsC;
async command void IO.toggle() { atomic FLIP_BIT (port, bit); }
inline async command void IO.makeInput() { CLR_BIT (ddr, bit); }
+ inline async command bool IO.isInput() { return !READ_BIT(ddr, bit); }
inline async command void IO.makeOutput() { SET_BIT (ddr, bit); }
+ inline async command bool IO.isOutput() { return READ_BIT(ddr, bit); }
}
inline async command void IO.toggle() { atomic FLIP_BIT (port, bit); }
inline async command void IO.makeInput() { atomic CLR_BIT (ddr, bit); }
+ inline async command bool IO.isInput() { return !READ_BIT(ddr, bit); }
inline async command void IO.makeOutput() { atomic SET_BIT (ddr, bit); }
+ inline async command bool IO.isOutput() { return READ_BIT(ddr, bit); }
}
inline async command void IO.makeInput() { CLR_BIT (ddr, bit); }
inline async command void IO.makeOutput() { SET_BIT (ddr, bit); }
+ inline async command bool IO.isInput() { return !READ_BIT (ddr, bit); }
+ inline async command bool IO.isOutput() { return READ_BIT (ddr, bit); }
}
implementation {
components Atm128SpiP as SpiMaster, HplAtm128SpiC as HplSpi;
components HplAtm128GeneralIOC as IO;
- components new FcfsArbiterC("Atm128SpiC.Resource") as Arbiter;
+ components new SimpleFcfsArbiterC("Atm128SpiC.Resource") as Arbiter;
components McuSleepC;
Init = SpiMaster;
- Init = Arbiter;
SpiByte = SpiMaster;
SpiPacket = SpiMaster;
call McuPowerState.update();
}
- async command void SpiByte.write( uint8_t tx, uint8_t* rx ) {
+ async command uint8_t SpiByte.write( uint8_t tx ) {
call Spi.write( tx );
while ( !( SPSR & 0x80 ) );
- *rx = call Spi.read();
+ return call Spi.read();
}
for (;tmpPos < (end - 1) ; tmpPos++) {
uint8_t val;
if (tx != NULL)
- call SpiByte.write( tx[tmpPos], &val );
+ val = call SpiByte.write( tx[tmpPos] );
else
- call SpiByte.write( 0, &val );
+ val = call SpiByte.write( 0 );
if (rx != NULL) {
rx[tmpPos] = val;
return call ResourceArbiter.request[ id ]();
}
- async command void Resource.release[ uint8_t id ]() {
- call ResourceArbiter.release[ id ]();
+ async command error_t Resource.release[ uint8_t id ]() {
+ error_t error = call ResourceArbiter.release[ id ]();
atomic {
if (!call ArbiterInfo.inUse()) {
stopSpi();
}
}
+ return error;
}
async command uint8_t Resource.isOwner[uint8_t id]() {
}
implementation {
components SimAtm128SpiDeviceC as Device;
- components new FcfsArbiterC("Atm128SpiC.Resource") as Arbiter;
+ components new SimpleFcfsArbiterC("Atm128SpiC.Resource") as Arbiter;
components McuSleepC;
Init = Device;
- Init = Arbiter;
SPIByte = Device;
SPIPacket = Device;
* @author Matt Miller, Crossbow <mmiller@xbow.com>
* @author Martin Turon, Crossbow <mturon@xbow.com>
*/
-generic module Atm128CaptureP ()
+generic module Atm128CaptureC ()
{
provides {
interface Capture as CapturePin;
{
/**
* SendReceive wants to send a packet.
+ * @param msg Message to be sent.
*/
- event void rts();
+ event void rts(message_t *msg);
/**
* Access to the media granted. Start sending. SendReceive must signal
* Implementation component for CC1000ActiveMessageC.
*
* @author Philip Levis
- * @date June 19 2005
+ * @date June 19 2006
*/
module CC1000ActiveMessageP {
uint8_t len) {
cc1000_header_t* header = getHeader(amsg);
header->type = id;
- header->addr = addr;
+ header->dest = addr;
+ header->source = call AMPacket.address();
header->group = TOS_AM_GROUP;
return call SubSend.send(amsg, len);
}
command am_addr_t AMPacket.destination(message_t* amsg) {
cc1000_header_t* header = getHeader(amsg);
- return header->addr;
+ return header->dest;
+ }
+
+ command am_addr_t AMPacket.source(message_t* amsg) {
+ cc1000_header_t* header = getHeader(amsg);
+ return header->source;
}
command void AMPacket.setDestination(message_t* amsg, am_addr_t addr) {
cc1000_header_t* header = getHeader(amsg);
- header->addr = addr;
+ header->dest = addr;
+ }
+
+ command void AMPacket.setSource(message_t* amsg, am_addr_t addr) {
+ cc1000_header_t* header = getHeader(amsg);
+ header->source = addr;
}
command bool AMPacket.isForMe(message_t* amsg) {
CC1K_LPL_STATES = 9,
- CC1K_LPL_PACKET_TIME = 16
+ CC1K_LPL_PACKET_TIME = 16,
+
+ CC1K_LPL_CHECK_TIME = 16, /* In tenth's of milliseconds, this should
+ be an approximation of the on-time for
+ a LPL check rather than the total check
+ time. */
+ CC1K_LPL_MIN_INTERVAL = 5, /* In milliseconds, the minimum interval
+ between low-power-listening checks */
+ CC1K_LPL_MAX_INTERVAL = 10000 /* In milliseconds, the maximum interval
+ between low-power-listening checks.
+ Arbitrary value, but must be at
+ most 32767 because of the way
+ sleep interval is stored in outgoing
+ messages */
};
#ifdef CC1K_DEFAULT_FREQ
#define CC1K_DEF_PRESET (CC1K_434_845_MHZ)
#endif
-
-static const_uint8_t CC1K_LPL_PreambleLength[CC1K_LPL_STATES*2] = {
- 0, 6, // Always on, 6 byte preamble
- 0x0, 48, // 10ms check interval
- 0x0, 60, // 25ms
- 0x0, 144, // 50ms
- 0x1, 0x0f, // 100ms
- 0x1, 0xf8, // 200ms
- 0x3, 0xd9, // 400ms
- 0x7, 0x9b, // 800ms
- 0xf, 0x06, // 1600ms
-};
-
-static const_uint8_t CC1K_LPL_SleepTime[CC1K_LPL_STATES*2] = {
- 0, 0, //0
- 0x0, 10, // 10ms
- 0x0, 25, // 25ms
- 0x0, 50, // 50ms
- 0x0, 100, // 100ms
- 0x0, 200, // 200ms
- 0x1, 0x90, // 400ms
- 0x3, 0x20, // 800ms
- 0x6, 0x40, // 1600ms
-};
-
-static const_uint8_t CC1K_LPL_SleepPreamble[CC1K_LPL_STATES] = {
- 0,
- 8,
- 8,
- 8,
- 8,
- 8,
- 8,
- 8
-};
-
static const_uint8_t CC1K_Params[6][20] = {
// (0) 433.002 MHz channel, 19.2 Kbps data, Manchester Encoding, High Side LO
{ // MAIN 0x00
int16_t macDelay;
- uint8_t lplTxPower, lplRxPower;
uint16_t sleepTime;
uint16_t rssiForSquelch;
task void setWakeupTask();
+ cc1000_metadata_t *getMetadata(message_t *amsg) {
+ return (cc1000_metadata_t *)((uint8_t *)amsg->footer + sizeof(cc1000_footer_t));
+ }
+
void enterIdleState() {
call cancelRssi();
radioState = IDLE_STATE;
call ByteRadio.off();
}
- /* LPL preamble length and sleep time computation */
-
- void setPreambleLength() {
- uint16_t len =
- (uint16_t)read_uint8_t(&CC1K_LPL_PreambleLength[lplTxPower * 2]) << 8
- | read_uint8_t(&CC1K_LPL_PreambleLength[lplTxPower * 2 + 1]);
- call ByteRadio.setPreambleLength(len);
- }
-
- void setSleepTime() {
- sleepTime =
- (uint16_t)read_uint8_t(&CC1K_LPL_SleepTime[lplRxPower *2 ]) << 8 |
- read_uint8_t(&CC1K_LPL_SleepTime[lplRxPower * 2 + 1]);
- }
+ void setPreambleLength(message_t *msg);
/* Initialisation, startup and stopping */
/*--------------------------------------*/
call ByteRadioControl.start();
enterIdleStateSetWakeup();
f.txPending = FALSE;
- setPreambleLength();
- setSleepTime();
}
else
return SUCCESS;
if (!call WakeupTimer.isRunning())
if (call CC1000Squelch.settled())
{
- if (lplRxPower == 0)
+ if (sleepTime == 0)
call WakeupTimer.startOneShot(CC1K_SquelchIntervalSlow);
else
// timeout for receiving a message after an lpl check
bool turnOn = FALSE;
atomic
- if (f.txPending)
+ if (f.txPending || !sleepTime)
{
if (radioState == PULSECHECK_STATE || radioState == POWERDOWN_STATE)
{
turnOn = TRUE;
}
}
- else if (lplRxPower > 0 && call CC1000Squelch.settled() &&
- !call ByteRadio.syncing())
+ else if (call CC1000Squelch.settled() && !call ByteRadio.syncing())
{
radioOff();
enterPowerDownState();
/* CSMA */
/*------*/
- event void ByteRadio.rts() {
+ event void ByteRadio.rts(message_t *msg) {
atomic
{
f.txPending = TRUE;
macDelay = signal CsmaBackoff.initial(call ByteRadio.getTxMessage());
else
macDelay = 1;
+
+ setPreambleLength(msg);
}
}
return SUCCESS;
}
- async command error_t LowPowerListening.setListeningMode(uint8_t power) {
- if (power >= CC1K_LPL_STATES)
- return FAIL;
+ /* Default MAC backoff parameters */
+ /*--------------------------------*/
- atomic
- {
- if (radioState != DISABLED_STATE)
- return FAIL;
- lplTxPower = power;
- lplRxPower = power;
- }
- return SUCCESS;
+ default async event uint16_t CsmaBackoff.initial(message_t *m) {
+ // initially back off [1,32] bytes (approx 2/3 packet)
+ return (call Random.rand16() & 0x1F) + 1;
}
- async command uint8_t LowPowerListening.getListeningMode() {
- atomic return lplRxPower;
+ default async event uint16_t CsmaBackoff.congestion(message_t *m) {
+ return (call Random.rand16() & 0xF) + 1;
}
- async command error_t LowPowerListening.setTransmitMode(uint8_t power) {
- if (power >= CC1K_LPL_STATES)
- return FAIL;
+ /* LowPowerListening setup */
+ /* ----------------------- */
- atomic
- {
- lplTxPower = power;
- setPreambleLength();
- }
- return SUCCESS;
+ uint16_t validateSleepInterval(uint16_t sleepIntervalMs) {
+ if (sleepIntervalMs < CC1K_LPL_MIN_INTERVAL)
+ return 0;
+ else if (sleepIntervalMs > CC1K_LPL_MAX_INTERVAL)
+ return CC1K_LPL_MAX_INTERVAL;
+ else
+ return sleepIntervalMs;
}
- async command uint8_t LowPowerListening.getTransmitMode() {
- atomic return lplTxPower;
+ uint16_t dutyToSleep(uint16_t dutyCycle) {
+ /* Scaling factors on CC1K_LPL_CHECK_TIME and dutyCycle are identical */
+ uint16_t interval = (1000 * CC1K_LPL_CHECK_TIME) / dutyCycle;
+
+ return interval < CC1K_LPL_MIN_INTERVAL ? 0 : interval;
}
- async command error_t LowPowerListening.setPreambleLength(uint16_t bytes) {
- call ByteRadio.setPreambleLength(bytes);
- return SUCCESS;
+ uint16_t sleepToDuty(uint16_t sleepInterval) {
+ if (sleepInterval < CC1K_LPL_MIN_INTERVAL)
+ return 10000;
+
+ /* Scaling factors on CC1K_LPL_CHECK_TIME and dutyCycle are identical */
+ return (1000 * CC1K_LPL_CHECK_TIME) / sleepInterval;
}
- async command uint16_t LowPowerListening.getPreambleLength() {
- return call ByteRadio.getPreambleLength();
+ command void LowPowerListening.setLocalSleepInterval(uint16_t s) {
+ sleepTime = validateSleepInterval(s);
}
- async command error_t LowPowerListening.setCheckInterval(uint16_t ms) {
- atomic
- {
- if (lplRxPower == 0)
- return FAIL;
+ command uint16_t LowPowerListening.getLocalSleepInterval() {
+ return sleepTime;
+ }
- sleepTime = ms;
- }
- return SUCCESS;
+ command void LowPowerListening.setLocalDutyCycle(uint16_t d) {
+ return call LowPowerListening.setLocalSleepInterval(dutyToSleep(d));
}
- async command uint16_t LowPowerListening.getCheckInterval() {
- atomic return sleepTime;
+ command uint16_t LowPowerListening.getLocalDutyCycle() {
+ return sleepToDuty(call LowPowerListening.getLocalSleepInterval());
}
- /* Default MAC backoff parameters */
- /*--------------------------------*/
+ command void LowPowerListening.setRxSleepInterval(message_t *msg, uint16_t sleepIntervalMs) {
+ cc1000_metadata_t *meta = getMetadata(msg);
- default async event uint16_t CsmaBackoff.initial(message_t *m) {
- // initially back off [1,32] bytes (approx 2/3 packet)
- return (call Random.rand16() & 0x1F) + 1;
+ meta->strength_or_preamble = -(int16_t)validateSleepInterval(sleepIntervalMs) - 1;
}
- default async event uint16_t CsmaBackoff.congestion(message_t *m) {
- return (call Random.rand16() & 0xF) + 1;
+ command uint16_t LowPowerListening.getRxSleepInterval(message_t *msg) {
+ cc1000_metadata_t *meta = getMetadata(msg);
+
+ if (meta->strength_or_preamble >= 0)
+ return sleepTime;
+ else
+ return -(meta->strength_or_preamble + 1);
+ }
+
+ command void LowPowerListening.setRxDutyCycle(message_t *msg, uint16_t d) {
+ return call LowPowerListening.setRxSleepInterval(msg, dutyToSleep(d));
+ }
+
+ command uint16_t LowPowerListening.getRxDutyCycle(message_t *msg) {
+ return sleepToDuty(call LowPowerListening.getRxSleepInterval(msg));
+ }
+
+ command uint16_t LowPowerListening.dutyCycleToSleepInterval(uint16_t d) {
+ return dutyToSleep(d);
+ }
+
+ command uint16_t LowPowerListening.sleepIntervalToDutyCycle(uint16_t s) {
+ return sleepToDuty(s);
+ }
+
+ void setPreambleLength(message_t *msg) {
+ cc1000_metadata_t *meta = getMetadata(msg);
+ uint16_t s;
+ uint32_t plen;
+
+ if (meta->strength_or_preamble >= 0)
+ s = sleepTime;
+ else
+ s = -(meta->strength_or_preamble + 1);
+ meta->strength_or_preamble = 0; /* Destroy setting */
+
+ if (s == 0)
+ plen = 6;
+ else
+ plen = ((s * 614UL) >> 8) + 22; /* ~ s * 2.4 + 22 */
+ call ByteRadio.setPreambleLength(plen);
}
}
#include "AM.h"
typedef nx_struct CC1KHeader {
- nx_am_addr_t addr;
+ nx_am_addr_t dest;
+ nx_am_addr_t source;
nx_uint8_t length;
nx_am_group_t group;
nx_am_id_t type;
} cc1000_footer_t;
typedef nx_struct CC1KMetadata {
- nx_uint16_t strength;
+ nx_int16_t strength_or_preamble; /* negative when used for preamble length */
nx_uint8_t ack;
nx_uint16_t time;
nx_uint8_t sendSecurityMode;
txBufPtr = msg;
}
}
- signal ByteRadio.rts();
+ signal ByteRadio.rts(msg);
return SUCCESS;
}
cc1000_metadata_t *rxMetadata = getMetadata(rxBufPtr);
if (result != SUCCESS)
- rxMetadata->strength = 0;
+ rxMetadata->strength_or_preamble = 0;
else
- rxMetadata->strength = data;
+ rxMetadata->strength_or_preamble = data;
}
void rxData(uint8_t in) {
if (f.ack &&
rxFooter->crc &&
- rxHeader->addr == call amAddress())
+ rxHeader->dest == call amAddress())
{
enterAckState();
call CC1000Control.txMode();
-/* tab:4
- *
- *
- * "Copyright (c) 2000-2002 The Regents of the University of California.
+/*
+ * Copyright (c) 2005-2006 Rincon Research Corporation
* All rights reserved.
*
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose, without fee, and without written agreement is
- * hereby granted, provided that the above copyright notice, the following
- * two paragraphs and the author appear in all copies of this software.
- *
- * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
- * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
- * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ * - Neither the name of the Arch Rock Corporation nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE
*/
+
/**
- * Low Power Listening control interface
+ * Low Power Listening interface
*
- * @author Joe Polastre
+ * @author David Moss
+ * @author Jonathan Hui
*/
-interface LowPowerListening
-{
+
+interface LowPowerListening {
+
/**
- * Set the current Low Power Listening mode.
- * Setting the LPL mode sets both the check interval and preamble length.
- * The listening mode can only be set while the radio is stopped.
+ * Set this this node's radio sleep interval, in milliseconds.
+ * Once every interval, the node will sleep and perform an Rx check
+ * on the radio. Setting the sleep interval to 0 will keep the radio
+ * always on.
*
- * Modes include:
- * 0 = Radio fully on
- * 1 = 10ms check interval
- * 2 = 25ms check interval
- * 3 = 50ms check interval
- * 4 = 100ms check interval (recommended)
- * 5 = 200ms check interval
- * 6 = 400ms check interval
- * 7 = 800ms check interval
- * 8 = 1600ms check interval
+ * This is the equivalent of setting the local duty cycle rate.
*
- * @param mode the mode number
- * @return SUCCESS if the mode was successfully changed, FAIL otherwise
+ * @param sleepIntervalMs the length of this node's Rx check interval, in [ms]
*/
- async command error_t setListeningMode(uint8_t mode);
-
+ command void setLocalSleepInterval(uint16_t sleepIntervalMs);
+
/**
- * Get the current Low Power Listening mode
- * @return mode number (see SetListeningMode)
+ * @return the local node's sleep interval, in [ms]
*/
- async command uint8_t getListeningMode();
-
+ command uint16_t getLocalSleepInterval();
+
/**
- * Set the transmit mode. This allows for hybrid schemes where
- * the transmit mode is different than the receive mode.
- * Use SetListeningMode first, then change the mode with SetTransmitMode.
+ * Set this node's radio duty cycle rate, in units of [percentage*100].
+ * For example, to get a 0.05% duty cycle,
+ * <code>
+ * call LowPowerListening.setDutyCycle(5); // or equivalently...
+ * call LowPowerListening.setDutyCycle(00005); // for better readability?
+ * </code>
*
- * @param mode mode number (see SetListeningMode)
- * @return SUCCESS if the mode was successfully changed, FAIL otherwise
+ * For a 100% duty cycle (always on),
+ * <code>
+ * call LowPowerListening.setDutyCycle(10000);
+ * </code>
+ *
+ * This is the equivalent of setting the local sleep interval explicitly.
+ *
+ * @param dutyCycle The duty cycle percentage, in units of [percentage*100]
*/
- async command error_t setTransmitMode(uint8_t mode);
-
+ command void setLocalDutyCycle(uint16_t dutyCycle);
+
/**
- * Get the current Low Power Listening transmit mode
- * @return mode number (see SetListeningMode)
+ * @return this node's radio duty cycle rate, in units of [percentage*100]
*/
- async command uint8_t getTransmitMode();
-
+ command uint16_t getLocalDutyCycle();
+
+
/**
- * Set the preamble length of outgoing packets. Note that this overrides
- * the value set by setListeningMode or setTransmitMode.
- *
- * @param bytes length of the preamble in bytes
- * @return SUCCESS if the preamble length was successfully changed, FAIL
- * otherwise
+ * Configure this outgoing message so it can be transmitted to a neighbor mote
+ * with the specified Rx sleep interval.
+ * @param msg Pointer to the message that will be sent
+ * @param sleepInterval The receiving node's sleep interval, in [ms]
*/
- async command error_t setPreambleLength(uint16_t bytes);
-
+ command void setRxSleepInterval(message_t *msg, uint16_t sleepIntervalMs);
+
/**
- * Get the preamble length of outgoing packets
- *
- * @return length of the preamble in bytes
+ * @return the destination node's sleep interval configured in this message
*/
- async command uint16_t getPreambleLength();
-
+ command uint16_t getRxSleepInterval(message_t *msg);
+
/**
- * Set the check interval (time between waking up and sampling
- * the radio for activity in low power listening). The sleep time
- * can only be changed if low-power-listening is enabled
- * (setListeningMode called with a non-zero value).
- *
- * @param ms check interval in milliseconds
- * @return SUCCESS if the check interval was successfully changed,
- * FAIL otherwise.
+ * Configure this outgoing message so it can be transmitted to a neighbor mote
+ * with the specified Rx duty cycle rate.
+ * Duty cycle is in units of [percentage*100], i.e. 0.25% duty cycle = 25.
+ *
+ * @param msg Pointer to the message that will be sent
+ * @param dutyCycle The duty cycle of the receiving mote, in units of
+ * [percentage*100]
*/
- async command error_t setCheckInterval(uint16_t ms);
-
+ command void setRxDutyCycle(message_t *msg, uint16_t dutyCycle);
+
/**
- * Get the check interval currently used by low power listening
- *
- * @return length of the check interval in milliseconds
+ * @return the destination node's duty cycle configured in this message
+ * in units of [percentage*100]
+ */
+ command uint16_t getRxDutyCycle(message_t *msg);
+
+ /**
+ * Convert a duty cycle, in units of [percentage*100], to
+ * the sleep interval of the mote in milliseconds
+ * @param dutyCycle The duty cycle in units of [percentage*100]
+ * @return The equivalent sleep interval, in units of [ms]
+ */
+ command uint16_t dutyCycleToSleepInterval(uint16_t dutyCycle);
+
+ /**
+ * Convert a sleep interval, in units of [ms], to a duty cycle
+ * in units of [percentage*100]
+ * @param sleepInterval The sleep interval in units of [ms]
+ * @return The duty cycle in units of [percentage*100]
*/
- async command uint16_t getCheckInterval();
+ command uint16_t sleepIntervalToDutyCycle(uint16_t sleepInterval);
+
}
cc2420_header_t* header = getHeader(amsg);
return header->dest;
}
+
+ command am_addr_t AMPacket.source(message_t* amsg) {
+ cc2420_header_t* header = getHeader(amsg);
+ return header->src;
+ }
command void AMPacket.setDestination(message_t* amsg, am_addr_t addr) {
cc2420_header_t* header = getHeader(amsg);
header->dest = addr;
}
- //command void AMPacket.setDestination(am_addr_t dest, message_t* amsg){
- // cc2420_header_t* header = getHeader(amsg);
- // header->dest = dest;
- //}
+ command void AMPacket.setSource(message_t* amsg, am_addr_t addr) {
+ cc2420_header_t* header = getHeader(amsg);
+ header->src = addr;
+ }
command bool AMPacket.isForMe(message_t* amsg) {
return (call AMPacket.destination(amsg) == call AMPacket.address() ||
return call SpiResource.isOwner();
}
- async command void Resource.release() {
+ async command error_t Resource.release() {
atomic {
call CSN.set();
- call SpiResource.release();
+ return call SpiResource.release();
}
}
( ( (channel - 11)*5+357 ) << CC2420_FSCTRL_FREQ ) );
call PANID.write( 0, (uint8_t*)id, sizeof( id ) );
call CSN.set();
+ call SyncResource.release();
post syncDone_task();
}
header->length = len;
- header->fcf = ( ( IEEE154_TYPE_DATA << IEEE154_FCF_FRAME_TYPE ) |
- ( 1 << IEEE154_FCF_INTRAPAN ) |
- ( IEEE154_ADDR_SHORT << IEEE154_FCF_DEST_ADDR_MODE ) |
- ( IEEE154_ADDR_SHORT << IEEE154_FCF_SRC_ADDR_MODE ) );
- if ( header->dest != AM_BROADCAST_ADDR )
- header->fcf |= 1 << IEEE154_FCF_ACK_REQ;
+ header->fcf &= 1 << IEEE154_FCF_ACK_REQ;
+ header->fcf |= ( ( IEEE154_TYPE_DATA << IEEE154_FCF_FRAME_TYPE ) |
+ ( 1 << IEEE154_FCF_INTRAPAN ) |
+ ( IEEE154_ADDR_SHORT << IEEE154_FCF_DEST_ADDR_MODE ) |
+ ( IEEE154_ADDR_SHORT << IEEE154_FCF_SRC_ADDR_MODE ) );
header->src = call AMPacket.address();
metadata->ack = FALSE;
metadata->rssi = 0;
return error;
}
- async command void Resource.release[ uint8_t id ]() {
+ async command error_t Resource.release[ uint8_t id ]() {
uint8_t i;
atomic {
if ( m_holder != id )
- return;
+ return FAIL;
m_holder = NO_HOLDER;
call SpiResource.release();
if ( !m_requests ) {
m_holder = i;
m_requests &= ~( 1 << i );
call SpiResource.request();
- return;
+ return SUCCESS;
}
}
}
+ return SUCCESS;
}
}
m_addr = addr | 0x40;
- call SpiByte.write( m_addr, &status );
+ status = call SpiByte.write( m_addr );
call Fifo.continueRead[ addr ]( data, len );
return status;
m_addr = addr;
- call SpiByte.write( m_addr, &status );
+ status = call SpiByte.write( m_addr );
call SpiPacket.send( data, NULL, len );
return status;
addr += offset;
- call SpiByte.write( addr | 0x80, &status );
- call SpiByte.write( ( ( addr >> 1 ) & 0xc0 ) | 0x20, &status );
+ call SpiByte.write( addr | 0x80 );
+ status = call SpiByte.write( ( ( addr >> 1 ) & 0xc0 ) | 0x20 );
for ( ; len; len-- )
- call SpiByte.write( 0, data++ );
+ *data++ = call SpiByte.write( 0 );
return status;
uint8_t* data,
uint8_t len ) {
- cc2420_status_t status;
+ cc2420_status_t status = 0;
addr += offset;
- call SpiByte.write( addr | 0x80, &status );
- call SpiByte.write( ( addr >> 1 ) & 0xc0, &status );
+ call SpiByte.write( addr | 0x80 );
+ call SpiByte.write( ( addr >> 1 ) & 0xc0 );
for ( ; len; len-- )
- call SpiByte.write( *data++, &status );
+ status = call SpiByte.write( *data++ );
return status;
async command cc2420_status_t Reg.read[ uint8_t addr ]( uint16_t* data ) {
cc2420_status_t status;
- uint8_t tmp;
-
- call SpiByte.write( addr | 0x40, &status );
- call SpiByte.write( 0, &tmp );
- *data = (uint16_t)tmp << 8;
- call SpiByte.write( 0, &tmp );
- *data |= tmp;
-
+
+ status = call SpiByte.write( addr | 0x40 );
+ *data = (uint16_t)call SpiByte.write( 0 ) << 8;
+ *data |= call SpiByte.write( 0 );
+
return status;
}
async command cc2420_status_t Reg.write[ uint8_t addr ]( uint16_t data ) {
- cc2420_status_t status;
-
- call SpiByte.write( addr, &status );
- call SpiByte.write( data >> 8, &status );
- call SpiByte.write( data & 0xff, &status );
-
- return status;
+ call SpiByte.write( addr );
+ call SpiByte.write( data >> 8 );
+ return call SpiByte.write( data & 0xff );
}
async command cc2420_status_t Strobe.strobe[ uint8_t addr ]() {
-
- cc2420_status_t status;
-
- call SpiByte.write( addr, &status );
-
- return status;
-
+ return call SpiByte.write( addr );
}
default async event void Fifo.readDone[ uint8_t addr ]( uint8_t* rx_buf, uint8_t rx_len, error_t error ) {}
return error;
}
- void releaseSpiResource() {
- call SpiResource.release();
+ error_t releaseSpiResource() {
+ return call SpiResource.release();
}
void signalDone( error_t err ) {
/**
* This module is the driver components for the ST LIS3L02DQ 3-axis
* accelerometer in the 4 wire SPI mode. It requires the SPI packet
- * interface and provides the HplLIS3L02DQ HPL interface.
+ * interface and assumes the ability to manually toggle the chip select
+ * via a GPIO. It provides the HplLIS3L02DQ HPL interface.
*
* @author Phil Buonadonna <pbuonadonna@archrock.com>
+ * @author Kaisen Lin <klin@archrock.com>
* @version $Revision$ $Date$
*/
uses interface SpiPacket;
uses interface GpioInterrupt as InterruptAlert;
-
- uses interface HplPXA27xGPIOPin as SPIRxD;
- uses interface HplPXA27xGPIOPin as SPITxD;
- uses interface HplPXA27xGPIOPin as SPICLK;
- uses interface HplPXA27xGPIOPin as SPIFRM;
+ uses interface GeneralIO as SPIFRM;
}
implementation {
}
task void StopDone() {
- atomic mState = STATE_STOPPED;
signal SplitControl.stopDone(mSSError);
return;
}
misInited = TRUE;
mState = STATE_STOPPED;
}
- call SPICLK.setGAFRpin(SSP1_SCLK_ALTFN);
- call SPICLK.setGPDRbit(TRUE);
-
// Control CS pin manually
- call SPIFRM.setGPSRbit(); // CS HIGH
- call SPIFRM.setGPDRbit(TRUE);
- //call SPIFRM.setGAFRpin(SSP1_SFRM_ALTFN);
-
- call SPIRxD.setGAFRpin(SSP1_RXD_ALTFN);
- call SPIRxD.setGPDRbit(FALSE);
- call SPITxD.setGAFRpin(SSP1_TXD_ALTFN);
- call SPITxD.setGPDRbit(TRUE);
+ call SPIFRM.makeOutput();
+ call SPIFRM.set();
}
+ return SUCCESS;
}
command error_t SplitControl.start() {
mSPITxBuf[0] = LIS3L02DQ_CTRL_REG1;
mSPITxBuf[1] = 0;
- mSPITxBuf[1] = (LIS3L01DQ_CTRL_REG1_PD(1) | /*LIS3L01DQ_CTRL_REG1_ST |*/ LIS3L01DQ_CTRL_REG1_XEN | LIS3L01DQ_CTRL_REG1_YEN | LIS3L01DQ_CTRL_REG1_ZEN);
- call SPIFRM.setGPCRbit(); // CS LOW
+ mSPITxBuf[1] = (LIS3L01DQ_CTRL_REG1_PD(1) | LIS3L01DQ_CTRL_REG1_XEN | LIS3L01DQ_CTRL_REG1_YEN | LIS3L01DQ_CTRL_REG1_ZEN);
+ call SPIFRM.clr(); // CS LOW
error = call SpiPacket.send(mSPITxBuf,mSPIRxBuf,2);
return error;
}
if (error)
return error;
- return post StopDone();
+ mSPITxBuf[0] = LIS3L02DQ_CTRL_REG1;
+ mSPITxBuf[1] = 0;
+ mSPITxBuf[1] = (LIS3L01DQ_CTRL_REG1_PD(0));
+ call SPIFRM.clr(); // CS LOW
+ error = call SpiPacket.send(mSPITxBuf,mSPIRxBuf,2);
+ return error;
}
command error_t HplLIS3L02DQ.getReg(uint8_t regAddr) {
mSPITxBuf[0] = regAddr | (1 << 7); // Set the READ bit
mSPIRxBuf[1] = 0;
mState = STATE_GETREG;
- call SPIFRM.setGPCRbit(); // CS LOW
+ call SPIFRM.clr(); // CS LOW
error = call SpiPacket.send(mSPITxBuf,mSPIRxBuf,2);
return error;
switch (mState) {
case STATE_GETREG:
mState = STATE_IDLE;
- call SPIFRM.setGPSRbit(); // CS HIGH
+ call SPIFRM.set(); // CS HIGH
signal HplLIS3L02DQ.getRegDone(error, (txBuf[0] & 0x7F) , rxBuf[1]);
break;
case STATE_SETREG:
break;
case STATE_STARTING:
mState = STATE_IDLE;
- call SPIFRM.setGPSRbit();
+ call SPIFRM.set();
post StartDone();
break;
+ case STATE_STOPPING:
+ mState = STATE_STOPPED;
+ post StopDone();
default:
mState = STATE_IDLE;
break;
return;
}
- async event void SPITxD.interruptGPIOPin() {}
- async event void SPIRxD.interruptGPIOPin() {}
- async event void SPICLK.interruptGPIOPin() {}
- async event void SPIFRM.interruptGPIOPin() {}
-
default event void SplitControl.startDone( error_t error ) { return; }
default event void SplitControl.stopDone( error_t error ) { return; }
#define LIS3L01DQ_CTRL_REG1_ST (1 << 3)
#define LIS3L01DQ_CTRL_REG1_ZEN (1 << 2)
#define LIS3L01DQ_CTRL_REG1_YEN (1 << 1)
-#define LIS3L01DQ_CTRL_REG1_XEN (1 << 1)
+#define LIS3L01DQ_CTRL_REG1_XEN (1 << 0)
#define LIS3L01DQ_CTRL_REG2_RES (1 << 7)
#define LIS3L01DQ_CTRL_REG2_BDU (1 << 6)
S_SETCONVMODE,
S_SETCLK,
S_SETREF,
+ S_ENALERT,
+ S_GETSTATUS,
};
uint8_t state = S_IDLE;
error_t clientResult;
+ task void alert_Task() {
+ signal HalMAX136xAdvanced.alertThreshold();
+ }
+
task void signalDone_Task() {
switch(state) {
case S_SETSCANMODE:
call Resource.release();
signal HalMAX136xAdvanced.setRefDone(clientResult);
break;
+ case S_ENALERT:
+ state = S_IDLE;
+ call Resource.release();
+ signal HalMAX136xAdvanced.enableAlertDone(clientResult);
+ break;
+ case S_GETSTATUS:
+ state = S_IDLE;
+ call Resource.release();
+ signal HalMAX136xAdvanced.getStatusDone(clientResult, mI2CBuffer[0], 0);
+ break;
default:
break;
}
setupByteShadow &= ~MAX136X_SETUP_REFAIN3SEL(3);
setupByteShadow |= MAX136X_SETUP_REFAIN3SEL(sel);
+
+ mI2CBuffer[0] = setupByteShadow;
+ call HplMAX136x.setConfig(mI2CBuffer, 1);
+ return SUCCESS;
}
command error_t HalMAX136xAdvanced.getStatus() {
- // STUB
+ error_t status;
+ if(state != S_IDLE)
+ return FAIL;
+ status = call Resource.immediateRequest();
+ if(status != SUCCESS)
+ return status;
+ state = S_GETSTATUS;
+
+ return call HplMAX136x.readStatus(mI2CBuffer, 2);
}
command error_t HalMAX136xAdvanced.enableAlert(bool bEnable) {
- // STUB
+ uint8_t i;
+ error_t status;
+ if(state != S_IDLE)
+ return FAIL;
+ status = call Resource.immediateRequest();
+ if(status != SUCCESS)
+ return status;
+ state = S_ENALERT;
+
+ if(bEnable)
+ monitorByteShadow |= MAX136X_MONITOR_INTEN;
+ else
+ monitorByteShadow &= ~MAX136X_MONITOR_INTEN;
+
+ mI2CBuffer[1] = setupByteShadow;
+ mI2CBuffer[2] = monitorByteShadow;
+
+ call HplMAX136x.setConfig(mI2CBuffer, 2);
+ return SUCCESS;
}
event void Resource.granted() {
// intentionally left blank
}
+ async event void HplMAX136x.readStatusDone(error_t error, uint8_t* buf) {
+ clientResult = error;
+ post signalDone_Task();
+ }
+
async event void HplMAX136x.measureChannelsDone( error_t error, uint8_t *buf, uint8_t len ) { /* intentionally left blank */ }
async event void HplMAX136x.setConfigDone( error_t error , uint8_t *cfgbuf, uint8_t len) {
clientResult = error;
post signalDone_Task();
}
- async event void HplMAX136x.alertThreshold() {}
+ async event void HplMAX136x.alertThreshold() {
+ post alert_Task();
+ }
}
}
async event void HplMAX136x.alertThreshold() {}
-
+ async event void HplMAX136x.readStatusDone(error_t error, uint8_t* buf) { }
}
command error_t setConfig( uint8_t *cfgbuf, uint8_t len);
async event void setConfigDone( error_t error , uint8_t *cfgbuf, uint8_t len);
+ command error_t readStatus(uint8_t *buf, uint8_t len);
+ async event void readStatusDone(error_t error, uint8_t *buf);
async event void alertThreshold();
STATE_STOPPED,
STATE_READCH,
STATE_SETCONFIG,
- STATE_ERROR
+ STATE_READSTATUS,
+ STATE_ERROR,
};
uint8_t mState;
return post StopDone();
}
+ command error_t HplMAX136x.readStatus(uint8_t *buf, uint8_t len) {
+ return doRead(STATE_READSTATUS,buf,len);
+ }
command error_t HplMAX136x.measureChannels(uint8_t *buf, uint8_t len) {
return doRead(STATE_READCH,buf,len);
mState = STATE_IDLE;
signal HplMAX136x.measureChannelsDone(error, buf, len);
break;
+ case STATE_READSTATUS:
+ mState = STATE_IDLE;
+ signal HplMAX136x.readStatusDone(error, buf);
+ break;
default:
mState = STATE_IDLE;
break;
#define MAX136X_SETUP_MONSETUP (1 << 0)
#define MAX136X_MONITOR_DELAY(_x) (((_x) & 0x7) << 1)
+#define MAX136X_MONITOR_INTEN (1 << 0)
typedef uint16_t max136x_data_t;
implementation {
components MM74HC595ImplP, HplMM74HC595PinsC;
- MM74HC595ImplP.Ser -> HplMM74HC595C.Ser;
- MM74HC595ImplP.Sck -> HplMM74HC595C.Sck;
- MM74HC595ImplP.Rck -> HplMM74HC595C.Rck;
+ MM74HC595ImplP.Ser -> HplMM74HC595PinsC.Ser;
+ MM74HC595ImplP.Sck -> HplMM74HC595PinsC.Sck;
+ MM74HC595ImplP.Rck -> HplMM74HC595PinsC.Rck;
components MainC;
MainC.SoftwareInit -> MM74HC595ImplP.Init;
}
async command void GeneralIO.makeOutput() {
}
+
+ async command bool GeneralIO.isInput() {
+ }
+ async command bool GeneralIO.isOutput() {
+ }
+
}
*/
/**
- * This component allows a client to access the MSP430 ADC12
- * (12-bit analog-to-digital converter) via the <code>Read</code> interface. A
- * client must wire the <code>Msp430Adc12Config</code> interface to a component
- * that returns its ADC12 configuration data. Depending on the
- * REF_VOLT_AUTO_CONFIGURE switch (defined in Msp430Adc12.h) the internal
- * reference voltage generator is automatically enabled if and only if the
- * configuration data includes VREF as reference voltage.
+ * This component virtualizes the HIL of ADC12 on MSP430. A client must wire
+ * <code>AdcConfigure</code> to a component that returns the client's adc
+ * configuration data.
*
- * @author Jan Hauer
- * @see Please refer to TEP 101 for more information about this component and its
- * intended use.
+ * @author Jan Hauer
+ * @see Please refer to the README.txt and TEP 101 for more information about
+ * this component and its intended use.
*/
#include <Msp430Adc12.h>
generic configuration AdcReadClientC() {
provides interface Read<uint16_t>;
- uses interface Msp430Adc12Config;
+ uses interface AdcConfigure<const msp430adc12_channel_config_t*>;
} implementation {
- components AdcC,
+ components AdcP,
#ifdef REF_VOLT_AUTO_CONFIGURE
- new Msp430Adc12RefVoltAutoClientC() as Msp430AdcClient;
+ // if the client configuration requires a stable
+ // reference voltage, the reference voltage generator
+ // is automatically enabled
+ new Msp430Adc12ClientAutoRVGC() as Msp430AdcClient;
#else
new Msp430Adc12ClientC() as Msp430AdcClient;
#endif
CLIENT = unique(ADCC_SERVICE),
};
- Read = AdcC.Read[CLIENT];
- Msp430Adc12Config = AdcC.Config[CLIENT];
- AdcC.SingleChannel[CLIENT] -> Msp430AdcClient.Msp430Adc12SingleChannel;
- AdcC.Resource[CLIENT] -> Msp430AdcClient.Resource;
+ Read = AdcP.Read[CLIENT];
+ AdcConfigure = AdcP.Config[CLIENT];
+ AdcP.SingleChannel[CLIENT] -> Msp430AdcClient.Msp430Adc12SingleChannel;
+ AdcP.ResourceRead[CLIENT] -> Msp430AdcClient.Resource;
#ifdef REF_VOLT_AUTO_CONFIGURE
- Msp430Adc12Config = Msp430AdcClient.Msp430Adc12Config;
+ AdcConfigure = Msp430AdcClient.AdcConfigure;
#endif
}
*/
/**
- * This component allows a client to access the MSP430 ADC12
- * (12-bit analog-to-digital converter) via the <code>ReadNow</code> and
- * <code>Resource</code> interface. According to TEP 108 a client must reserve
- * the ADC before using it via the <code>Resource</code> interface (otherwise
- * the request will fail). A client must wire the
- * <code>Msp430Adc12Config</code> interface to a component that returns its
- * ADC12 configuration data. Depending on the REF_VOLT_AUTO_CONFIGURE switch
- * (defined in Msp430Adc12.h) the internal reference voltage generator is
- * automatically enabled if and only if the configuration data includes VREF as
- * reference voltage. Then the <code>Resource.granted()</code> event implies
- * that the reference voltage is stable.
+ * This component virtualizes the HIL of ADC12 on MSP430. A client must wire
+ * <code>AdcConfigure</code> to a component that returns the client's adc
+ * configuration data.
*
- * @author Jan Hauer
- * @see Please refer to TEP 101 for more information about this component and its
- * intended use.
+ * @author Jan Hauer
+ * @see Please refer to the README.txt and TEP 101 for more information about
+ * this component and its intended use.
*/
#include <Msp430Adc12.h>
interface Resource;
interface ReadNow<uint16_t>;
}
- uses interface Msp430Adc12Config;
+ uses interface AdcConfigure<const msp430adc12_channel_config_t*>;
} implementation {
- components AdcC,
+ components AdcP,
#ifdef REF_VOLT_AUTO_CONFIGURE
- new Msp430Adc12RefVoltAutoClientC() as Msp430AdcClient;
+ // if the client configuration requires a stable
+ // reference voltage, the reference voltage generator
+ // is automatically enabled
+ new Msp430Adc12ClientAutoRVGC() as Msp430AdcClient;
#else
new Msp430Adc12ClientC() as Msp430AdcClient;
#endif
CLIENT = unique(ADCC_SERVICE),
};
- ReadNow = AdcC.ReadNow[CLIENT];
- Msp430Adc12Config = AdcC.Config[CLIENT];
- AdcC.SingleChannel[CLIENT] -> Msp430AdcClient.Msp430Adc12SingleChannel;
- Resource = Msp430AdcClient.Resource;
+ ReadNow = AdcP.ReadNow[CLIENT];
+ AdcConfigure = AdcP.Config[CLIENT];
+ AdcP.SingleChannel[CLIENT] -> Msp430AdcClient.Msp430Adc12SingleChannel;
+ Resource = AdcP.ResourceReadNow[CLIENT];
+
+ AdcP.SubResourceReadNow[CLIENT] -> Msp430AdcClient.Resource;
#ifdef REF_VOLT_AUTO_CONFIGURE
- Msp430Adc12Config = Msp430AdcClient.Msp430Adc12Config;
+ AdcConfigure = Msp430AdcClient.AdcConfigure;
#endif
}
*/
/**
- * This component allows a client to access the MSP430 ADC12
- * (12-bit analog-to-digital converter) via the <code>ReadStream</code>
- * interface. A client must wire the <code>Msp430Adc12Config</code> interface
- * to a component that returns its ADC12 configuration data. Depending on the
- * REF_VOLT_AUTO_CONFIGURE switch (defined in Msp430Adc12.h) the internal
- * reference voltage generator is automatically enabled if and only if the
- * configuration data includes VREF as reference voltage.
+ * This component virtualizes the HIL of ADC12 on MSP430. A client must wire
+ * <code>AdcConfigure</code> to a component that returns the client's adc
+ * configuration data.
*
- * @author Jan Hauer
- * @see Please refer to TEP 101 for more information about this component and its
- * intended use.
+ * @author Jan Hauer
+ * @see Please refer to the README.txt and TEP 101 for more information about
+ * this component and its intended use.
*/
#include <Msp430Adc12.h>
generic configuration AdcReadStreamClientC() {
provides interface ReadStream<uint16_t>;
- uses interface Msp430Adc12Config;
+ uses interface AdcConfigure<const msp430adc12_channel_config_t*>;
} implementation {
- components AdcC,
+ components AdcP,
#ifdef REF_VOLT_AUTO_CONFIGURE
- new Msp430Adc12RefVoltAutoClientC() as Msp430AdcClient;
+ // if the client configuration requires a stable
+ // reference voltage, the reference voltage generator
+ // is automatically enabled
+ new Msp430Adc12ClientAutoRVGC() as Msp430AdcPlient;
#else
- new Msp430Adc12ClientC() as Msp430AdcClient;
+ new Msp430Adc12ClientC() as Msp430AdcPlient;
#endif
enum {
RSCLIENT = unique(ADCC_READ_STREAM_SERVICE),
};
- ReadStream = AdcC.ReadStream[RSCLIENT];
- Msp430Adc12Config = AdcC.ConfigReadStream[RSCLIENT];
- AdcC.SingleChannelReadStream[RSCLIENT] -> Msp430AdcClient.Msp430Adc12SingleChannel;
- AdcC.ResourceReadStream[RSCLIENT] -> Msp430AdcClient.Resource;
+ ReadStream = AdcP.ReadStream[RSCLIENT];
+ AdcConfigure = AdcP.ConfigReadStream[RSCLIENT];
+ AdcP.SingleChannelReadStream[RSCLIENT] -> Msp430AdcPlient.Msp430Adc12SingleChannel;
+ AdcP.ResourceReadStream[RSCLIENT] -> Msp430AdcPlient.Resource;
#ifdef REF_VOLT_AUTO_CONFIGURE
- Msp430Adc12Config = Msp430AdcClient.Msp430Adc12Config;
+ AdcConfigure = Msp430AdcPlient.AdcConfigure;
#endif
}
*/
async command void resetIFGs();
- /**
- * Returns the ADC12 interrupt flag register, ADC12IFG.
- * @return ADC12IFG
- */
- async command uint16_t getIFGs();
-
/**
* Signals an ADC12MEMx overflow.
*/
*/
async command bool isBusy();
- /**
- * Sets the Sample-and-hold time flags, SHT0x and SHT1x.
- * Requires ENC-flag to be reset (disableConversion) !
- * @param sht Sample-and-hold, top 4 bits = SHT1x, lower 4 bits = SHT0x
- */
- async command void setSHT(uint8_t sht);
-
- /**
- * Sets the multiple sample and conversion flag, MSC in ADC12CTL0.
- * Requires ENC-flag to be reset (disableConversion) !
- */
- async command void setMSC();
-
- /**
- * Resets the multiple sample and conversion flag, MSC in ADC12CTL0.
- * Requires ENC-flag to be reset (disableConversion) !
- */
- async command void resetMSC();
-
- /**
- * Sets the REFON in ADC12CTL0.
- * Requires ENC-flag to be reset (disableConversion) !
- */
- async command void setRefOn();
-
- /**
- * Resets the REFON in ADC12CTL0.
- * Requires ENC-flag to be reset (disableConversion) !
- */
- async command void resetRefOn();
-
- /**
- * Returns the REFON flag in ADC12CTL0.
- * @return REFON
- */
- async command uint8_t getRefon();
-
- /**
- * Sets the reference generator voltage to 1.5V.
- * Requires ENC-flag to be reset (disableConversion) !
- */
- async command void setRef1_5V();
-
- /**
- * Sets the reference generator voltage to 2.5V.
- * Requires ENC-flag to be reset (disableConversion) !
- */
- async command void setRef2_5V();
-
- /**
- * Returns reference voltage level (REF2_5V flag).
- * @return 0 if reference generator voltage is 1.5V,
- * 1 if reference generator voltage is 2.5V
- */
- async command uint8_t isRef2_5V();
-
/**
- * Enables a conversion (sets the ENC flag).
- */
- async command void enableConversion();
-
- /**
- * Disables a conversion (resets the ENC flag).
+ * Stops a conversion.
*/
- async command void disableConversion();
+ async command void stopConversion();
/**
* Starts a conversion.
*/
async command void startConversion();
- /**
- * Stops a conversion.
- */
- async command void stopConversion();
-
- /**
- * Switches the ADC12 off (ADC12ON flag).
- */
- async command void adcOff();
-
- /**
- * Switches the ADC12 off (ADC12ON flag).
- */
- async command void adcOn();
}
}
}
- async command uint16_t HplAdc12.getIFGs(){ return (uint16_t) ADC12IFG; }
-
- async command bool HplAdc12.isBusy(){ return ADC12CTL1 & ADC12BUSY; }
-
- async command void HplAdc12.enableConversion(){ ADC12CTL0 |= ENC;}
- async command void HplAdc12.disableConversion(){ ADC12CTL0 &= ~ENC; }
- async command void HplAdc12.startConversion(){ ADC12CTL0 |= ADC12SC + ENC; }
- async command void HplAdc12.stopConversion(){
- ADC12CTL1 &= ~(CONSEQ_1 | CONSEQ_3);
- ADC12CTL0 &= ~ENC;
+ async command void HplAdc12.startConversion(){
+ ADC12CTL0 |= ADC12ON;
+ ADC12CTL0 |= (ADC12SC + ENC);
}
- async command void HplAdc12.setMSC(){ ADC12CTL0 |= MSC; }
- async command void HplAdc12.resetMSC(){ ADC12CTL0 &= ~MSC; }
-
- async command void HplAdc12.setRefOn(){ ADC12CTL0 |= REFON;}
- async command void HplAdc12.resetRefOn(){ ADC12CTL0 &= ~REFON;}
- async command uint8_t HplAdc12.getRefon(){ return (ADC12CTL0 & REFON) >> 5;}
- async command void HplAdc12.setRef1_5V(){ ADC12CTL0 &= ~REF2_5V;}
- async command void HplAdc12.setRef2_5V(){ ADC12CTL0 |= REF2_5V;}
- async command uint8_t HplAdc12.isRef2_5V(){ return (ADC12CTL0 & REF2_5V) >> 6;}
-
- async command void HplAdc12.setSHT(uint8_t sht){
- uint16_t ctl0 = ADC12CTL0;
- uint16_t shttemp = sht & 0x0F;
- ctl0 &= 0x00FF;
- ctl0 |= (shttemp << 8);
- ctl0 |= (shttemp << 12);
- ADC12CTL0 = ctl0;
+ async command void HplAdc12.stopConversion(){
+ ADC12CTL0 &= ~(ADC12SC + ENC);
+ ADC12CTL0 &= ~(ADC12ON);
}
- async command void HplAdc12.adcOff(){ ADC12CTL0 &= ~ADC12ON; }
- async command void HplAdc12.adcOn(){ ADC12CTL0 |= ADC12ON; }
+ async command bool HplAdc12.isBusy(){ return ADC12CTL1 & ADC12BUSY; }
TOSH_SIGNAL(ADC_VECTOR) {
uint16_t iv = ADC12IV;
/*
- * Copyright (c) 2004, Technische Universitaet Berlin
+ * Copyright (c) 2006, Technische Universitaet Berlin
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
#define CHECK_ARGS
/*
- * The msp430adc12_channel_config_t encapsulates all relevant flags for
- * sampling a single ADC12 channel on a per-client basis. They are taken from
- * the following MSP430 registers: ADC12CTL0, ADC12CTL1, ADC12MCTLx and TACTL
- * of TimerA (if applicable) and named according to section "17.3 ADC12
- * Registers" of the "MSP430x1xx Family User's Guide",
- * http://focus.ti.com/lit/ug/slau049e/slau049e.pdf).
- *
- * .inch: ADC12 input channel (ADC12MCTLx register). An (external) input channel
- * maps to one of msp430's A0-A7 pins (see device specific data sheet).
+ * The msp430adc12_channel_config_t includes all relevant flags to configure
+ * the ADC12 for single channel conversions. They are contained in the following
+ * MSP430 registers: ADC12CTL0, ADC12CTL1, ADC12MCTLx and TACTL of TimerA (if
+ * applicable) and named according to section "17.3 ADC12 Registers" of the
+ * "MSP430x1xx Family User's Guide".
+ *
+ * **********************************
+ *
+ * .inch: ADC12 input channel (ADC12MCTLx register). An (external) input
+ * channel maps to one of msp430's A0-A7 pins (see device specific data sheet).
*
- * .sref: reference voltage (ADC12MCTLx register). If
- * REFERENCE_VREFplus_AVss or REFERENCE_VREFplus_VREFnegterm is chosen
- * AND the client wires to Msp430Adc12RefVoltAutoClientC (or
- * REF_VOLT_AUTO_CONFIGURE is defined and the client wires to
- * AdcReadClientC, AdcReadNowClientC or AdcReadStreamClientC) then the
- * reference voltage generator is automatically switched on to the
- * voltage level defined by the "ref2_5v" flag (see below) whenever the
- * client accesses the ADC12. Otherwise both flags are ignored.
+ * .sref: reference voltage (ADC12MCTLx register). If REFERENCE_VREFplus_AVss
+ * or REFERENCE_VREFplus_VREFnegterm is chosen AND the client wires to the
+ * Msp430Adc12ClientAutoRVGC or Msp430Adc12ClientAutoDMA_RVGC component then
+ * the reference voltage generator has automatically been enabled to the
+ * voltage level defined by the "ref2_5v" flag (see below) when the
+ * Resource.granted() event is signalled to the client. Otherwise this flag is
+ * ignored.
*
- * .ref2_5v: Reference generator voltage level (ADC12CTL0 register). See
- * explanation to "sref" flag.
+ * .ref2_5v: Reference generator voltage level (ADC12CTL0 register). See "sref"
+ * flag.
*
- * .adc12ssel: ADC12 clock source select for the sample-hold-time
- * (ADC12CTL1 register). In combination the "adc12ssel", "adc12div" and
- * "sht" define the sample-hold-time: "adc12ssel" defines the clock
- * source, "adc12div" defines the ADC12 clock divider and "sht" define
- * the time expressed in jiffies.
+ * .adc12ssel: ADC12 clock source select for the sample-hold-time (ADC12CTL1
+ * register). In combination the "adc12ssel", "adc12div" and "sht" define the
+ * sample-hold-time: "adc12ssel" defines the clock source, "adc12div" defines
+ * the ADC12 clock divider and "sht" define the time expressed in jiffies.
+ * (the sample-hold-time depends on the resistence of the attached sensor, and
+ * is calculated using to the formula in section 17.2.4 of the user guide)
*
* .adc12div: ADC12 clock divider (ADC12CTL1 register). See "adc12ssel".
*
* .sht: Sample-and-hold time (ADC12CTL1 register). See "adc12ssel".
*
- * .sampcon_ssel: In combination with "sampcon_id" and the "jiffies"
- * parameter in the Msp430Adc12SingleChannel interface commands the
- * "sampcon_ssel" defines the sampling rate (TASSEL in TACTL register,
- * TimerA). It is the clock source for the SAMPCON signal, which
- * triggers the actual sampling. It is ignored when
- * Msp430Adc12SingleChannel.getSingleData() is used or the "jiffies"
- * parameter is zero; otherwise the SAMPCON signal is sourced from
- * TimerA, so that the multiple conversion mode can be made with the
- * user defined sampling rate.
+ * .sampcon_ssel: Clock source for the sampling period (TASSEL for TimerA).
+ * When an ADC client specifies a non-zero "jiffies" parameter (passed in the
+ * relevant Msp430Adc12SingleChannel interface commands), the ADC
+ * implementation will automatically configure TimerA to be sourced from
+ * "sampcon_ssel" with an input divider of "sampcon_id". During the sampling
+ * process TimerA will then be used to trigger a conversion every "jiffies"
+ * clock ticks.
*
- * .sampcon_id: Input divider for "sampcon_ssel" (IDx in TACTL
- * register, TimerA). See "sampcon_ssel".
+ * .sampcon_id: Input divider for "sampcon_ssel" (IDx in TACTL register,
+ * TimerA). See "sampcon_ssel".
*
*
* **********************************
*
- * EXAMPLE: Assuming that SMCLK runs at 1 MHz the following command fills the
- * user buffer with 2000 conversion results sampled on channel A2 with a
- * sampling rate of 4000 Hz, i.e. the multipleDataReady() event is signalled
- * after 500 ms. Note that the sampling rate is defined by the combination of
- * SAMPCON_SOURCE_SMCLK, SAMPCON_CLOCK_DIV_1 and the "jiffies" parameter of
- * 250.
- *
- *
- * uint16_t buffer[2000];
- * msp430adc12_channel_config_t config = {
- * INPUT_CHANNEL_A2, REFERENCE_VREFplus_AVss, REFVOLT_LEVEL_1_5,
- * SHT_SOURCE_SMCLK, SHT_CLOCK_DIV_1, SAMPLE_HOLD_64_CYCLES,
- * SAMPCON_SOURCE_SMCLK, SAMPCON_CLOCK_DIV_1
- * };
- *
- * event void Resource.granted()
- * {
- * if (call SingleChannel.getMultipleData(&config, buffer, 2000, 250)
- * == SUCCESS)
- * {
- * // .. multipleDataReady() event will be signalled in 500ms
- * } else {
- * // check error
- * }
- * }
+ * EXAMPLE: Assuming that SMCLK runs at 1 MHz the following code snippet
+ * performs 2000 ADC conversions on channel A2 with a sampling period of 4000 Hz.
+ * The sampling period is defined by the combination of SAMPCON_SOURCE_SMCLK,
+ * SAMPCON_CLOCK_DIV_1 and a "jiffies" parameter of (1000000 / 4000) = 250.
+
+ #define NUM_SAMPLES 2000
+ uint16_t buffer[NUM_SAMPLES];
+
+ msp430adc12_channel_config_t config = {
+ INPUT_CHANNEL_A2, REFERENCE_VREFplus_AVss, REFVOLT_LEVEL_NONE,
+ SHT_SOURCE_SMCLK, SHT_CLOCK_DIV_1, SAMPLE_HOLD_64_CYCLES,
+ SAMPCON_SOURCE_SMCLK, SAMPCON_CLOCK_DIV_1
+ };
+
+ event void Boot.booted()
+ {
+ call Resource.request();
+ }
+
+ event void Resource.granted()
+ {
+ error_t result;
+ result = call SingleChannel.configureMultiple(&config, buffer, BUFFER_SIZE, 250);
+ if (result == SUCCESS)
+ call SingleChannel.getData();
+ }
+
+ async event uint16_t* SingleChannel.multipleDataReady(uint16_t *buf, uint16_t length)
+ {
+ // buffer contains conversion results
+ }
*/
// The unique string for accessing HAL2 via ReadStream
#define ADCC_READ_STREAM_SERVICE "AdcC.ReadStream.Client"
-
typedef struct
{
volatile unsigned
/* \r
- * Copyright (c) 2004, Technische Universitaet Berlin\r
+ * Copyright (c) 2006, Technische Universitaet Berlin\r
* All rights reserved.\r
*\r
* Redistribution and use in source and binary forms, with or without\r
*/\r
\r
/** \r
- * This component realizes the HAL1 representation and allows an\r
- * MSP430-specific client to access the MSP430 ADC12 (12-bit analog-to-digital\r
- * converter) via the <code>Msp430Adc12SingleChannel</code> and\r
- * <code>Resource</code> interface. According to TEP 108 a client must reserve\r
- * the ADC before using it via the <code>Resource</code> interface (otherwise\r
- * the request will fail). In contrast to the\r
- * <code>Msp430Adc12RefVoltAutoClientC</code> the\r
- * <code>Msp430Adc12ClientC</code> does not enable internal reference voltage\r
- * generator. \r
+ * This component virtualizes access to the HAL of the MSP430 ADC12. \r
* \r
- * @author Jan Hauer\r
- * @see Please refer to TEP 101 for more information about this component and its\r
- * intended use.\r
+ * @author Jan Hauer \r
+ *\r
+ * @see Please refer to the README.txt and TEP 101 for more information about\r
+ * this component and its intended use.\r
*/\r
\r
generic configuration Msp430Adc12ClientC()\r
{\r
- provides interface Resource;\r
- provides interface Msp430Adc12SingleChannel;\r
+ provides {\r
+ interface Resource;\r
+ interface Msp430Adc12SingleChannel;\r
+ }\r
} implementation {\r
- components Msp430Adc12C;\r
+ components Msp430Adc12P;\r
\r
enum {\r
ID = unique(MSP430ADC12_RESOURCE),\r
};\r
- Resource = Msp430Adc12C.Resource[ID];\r
- Msp430Adc12SingleChannel = Msp430Adc12C.SingleChannel[ID];\r
+ Resource = Msp430Adc12P.Resource[ID];\r
+ Msp430Adc12SingleChannel = Msp430Adc12P.SingleChannel[ID];\r
}\r
/*
- * Copyright (c) 2004, Technische Universitaet Berlin
+ * Copyright (c) 2006, Technische Universitaet Berlin
* All rights reserved.
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * - Neither the name of the Technische Universitaet Berlin nor the names
+ * - Neither the name of the Technische Universitaet Berlin nor the names
* of its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
- * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* - Revision -------------------------------------------------------------
* ========================================================================
*/
-#include <Msp430Adc12.h>
-module Msp430Adc12P
-{
- provides {
- interface Init;
- interface Msp430Adc12SingleChannel as SingleChannel[uint8_t id];
- interface Msp430Adc12FastSingleChannel as FastSingleChannel[uint8_t id];
- }
- uses {
- interface ArbiterInfo as ADCArbiterInfo;
- interface HplAdc12;
- interface Msp430Timer as TimerA;
- interface Msp430TimerControl as ControlA0;
- interface Msp430TimerControl as ControlA1;
- interface Msp430Compare as CompareA0;
- interface Msp430Compare as CompareA1;
- interface HplMsp430GeneralIO as Port60;
- interface HplMsp430GeneralIO as Port61;
- interface HplMsp430GeneralIO as Port62;
- interface HplMsp430GeneralIO as Port63;
- interface HplMsp430GeneralIO as Port64;
- interface HplMsp430GeneralIO as Port65;
- interface HplMsp430GeneralIO as Port66;
- interface HplMsp430GeneralIO as Port67;
-
- }
-}
-implementation
+#include <Msp430Adc12.h>
+configuration Msp430Adc12P
{
- enum { // conversionMode
- SINGLE_DATA,
- SINGLE_DATA_REPEAT,
- MULTIPLE_DATA,
- MULTIPLE_DATA_REPEAT,
- };
- enum { // flags
- ADC_BUSY = 1, /* request pending */
- TIMERA_USED = 2, /* TimerA used for SAMPCON signal */
- FAST_MODE = 4,
- };
-
- uint16_t *resultBuffer; /* result buffer */
- uint16_t resultBufferLength; /* length of buffer */
- uint16_t resultBufferIndex; /* offset into buffer */
- norace uint8_t clientID; /* ID of interface that issued current request */
- norace uint8_t flags; /* current state, see above */
-
- // norace is safe, because Resource interface resolves conflicts
- norace uint8_t conversionMode; /* current conversion conversionMode, see above */
-
- command error_t Init.init()
- {
- call HplAdc12.disableConversion();
- call HplAdc12.adcOff();
- return SUCCESS;
- }
-
- error_t clientAccessRequest(uint8_t id)
- {
- atomic {
- if (call ADCArbiterInfo.userId() == id){
- if (flags & ADC_BUSY)
- return EBUSY;
- flags = ADC_BUSY;
- clientID = id;
- return SUCCESS;
- }
- }
- return ERESERVE;
- }
-
- inline void clientAccessFinished()
- {
- atomic flags = 0;
- }
-
- void prepareTimerA(uint16_t interval, uint16_t csSAMPCON, uint16_t cdSAMPCON)
- {
- msp430_compare_control_t ccResetSHI = {
- ccifg : 0, cov : 0, out : 0, cci : 0, ccie : 0,
- outmod : 0, cap : 0, clld : 0, scs : 0, ccis : 0, cm : 0 };
-
- call TimerA.setMode(MSP430TIMER_STOP_MODE);
- call TimerA.clear();
- call TimerA.disableEvents();
- call TimerA.setClockSource(csSAMPCON);
- call TimerA.setInputDivider(cdSAMPCON);
- call ControlA0.setControl(ccResetSHI);
- call CompareA0.setEvent(interval-1);
- call CompareA1.setEvent((interval-1)/2);
- }
-
- void startTimerA()
- {
- msp430_compare_control_t ccSetSHI = {
- ccifg : 0, cov : 0, out : 1, cci : 0, ccie : 0,
- outmod : 0, cap : 0, clld : 0, scs : 0, ccis : 0, cm : 0 };
- msp430_compare_control_t ccResetSHI = {
- ccifg : 0, cov : 0, out : 0, cci : 0, ccie : 0,
- outmod : 0, cap : 0, clld : 0, scs : 0, ccis : 0, cm : 0 };
- msp430_compare_control_t ccRSOutmod = {
- ccifg : 0, cov : 0, out : 0, cci : 0, ccie : 0,
- outmod : 7, cap : 0, clld : 0, scs : 0, ccis : 0, cm : 0 };
- // manually trigger first conversion, then switch to Reset/set conversionMode
- call ControlA1.setControl(ccResetSHI);
- call ControlA1.setControl(ccSetSHI);
- //call ControlA1.setControl(ccResetSHI);
- call ControlA1.setControl(ccRSOutmod);
- call TimerA.setMode(MSP430TIMER_UP_MODE); // go!
- }
-
- void configureAdcPin( uint8_t inch )
- {
-#ifdef P6PIN_AUTO_CONFIGURE
- switch (inch)
- {
- case 0: call Port60.selectModuleFunc(); call Port60.makeInput(); break;
- case 1: call Port61.selectModuleFunc(); call Port61.makeInput(); break;
- case 2: call Port62.selectModuleFunc(); call Port62.makeInput(); break;
- case 3: call Port63.selectModuleFunc(); call Port63.makeInput(); break;
- case 4: call Port64.selectModuleFunc(); call Port64.makeInput(); break;
- case 5: call Port65.selectModuleFunc(); call Port65.makeInput(); break;
- case 6: call Port66.selectModuleFunc(); call Port66.makeInput(); break;
- case 7: call Port67.selectModuleFunc(); call Port67.makeInput(); break;
- }
-#endif
- }
-
- void resetAdcPin( uint8_t inch )
- {
-#ifdef P6PIN_AUTO_CONFIGURE
- switch (inch)
- {
- case 0: call Port60.selectIOFunc(); break;
- case 1: call Port61.selectIOFunc(); break;
- case 2: call Port62.selectIOFunc(); break;
- case 3: call Port63.selectIOFunc(); break;
- case 4: call Port64.selectIOFunc(); break;
- case 5: call Port65.selectIOFunc(); break;
- case 6: call Port66.selectIOFunc(); break;
- case 7: call Port67.selectIOFunc(); break;
- }
-#endif
- }
-
- void stopConversionSingleChannel()
- {
- adc12memctl_t memctl = call HplAdc12.getMCtl(0);
- if (flags & TIMERA_USED){
- call TimerA.setMode(MSP430TIMER_STOP_MODE);
- }
- resetAdcPin( memctl.inch );
- call HplAdc12.stopConversion();
- call HplAdc12.adcOff();
- call HplAdc12.setIEFlags(0);
- call HplAdc12.resetIFGs();
- clientAccessFinished();
- }
-
- error_t configureSingleData(uint8_t id, const msp430adc12_channel_config_t *config)
- {
- error_t result;
-#ifdef CHECK_ARGS
- if (!config)
- return EINVAL;
-#endif
- if ((result = clientAccessRequest(id)) == SUCCESS)
- {
- adc12ctl0_t ctl0 = {
- adc12sc: 0,
- enc: 0,
- adc12tovie: 0,
- adc12ovie: 0,
- adc12on: 1,
- refon: call HplAdc12.getRefon(),
- r2_5v: call HplAdc12.isRef2_5V(),
- msc: 1,
- sht0: config->sht,
- sht1: config->sht
- };
- adc12ctl1_t ctl1 = {
- adc12busy: 0,
- conseq: 0,
- adc12ssel: config->adc12ssel,
- adc12div: config->adc12div,
- issh: 0,
- shp: 1,
- shs: 0,
- cstartadd: 0
- };
- adc12memctl_t memctl = {
- inch: config->inch,
- sref: config->sref,
- eos: 1
- };
- conversionMode = SINGLE_DATA;
- configureAdcPin( config->inch );
- call HplAdc12.setCtl0(ctl0);
- call HplAdc12.setCtl1(ctl1);
- call HplAdc12.setMCtl(0, memctl);
- call HplAdc12.setIEFlags(0x01);
- //call HplAdc12.startConversion();
- }
- return result;
- }
-
- async command error_t SingleChannel.getSingleData[uint8_t id](
- const msp430adc12_channel_config_t *config)
- {
- error_t result = configureSingleData(id, config);
- if (result == SUCCESS)
- call HplAdc12.startConversion();
- return result;
- }
-
- async command error_t FastSingleChannel.configure[uint8_t id](const msp430adc12_channel_config_t *config)
- {
- return configureSingleData(id, config);
- }
-
- async command error_t FastSingleChannel.getSingleData[uint8_t id]()
- {
- if (clientID == id){
- flags |= FAST_MODE;
- call HplAdc12.startConversion();
- return SUCCESS;
- }
- return FAIL;
- }
-
- async command error_t SingleChannel.getSingleDataRepeat[uint8_t id](
- const msp430adc12_channel_config_t *config,
- uint16_t jiffies)
- {
- error_t result;
-#ifdef CHECK_ARGS
- if (!config || jiffies == 1 || jiffies == 2)
- return EINVAL;
-#endif
- if ((result = clientAccessRequest(id)) == SUCCESS)
- {
- adc12ctl0_t ctl0 = {
- adc12sc: 0,
- enc: 0,
- adc12tovie: 0,
- adc12ovie: 0,
- adc12on: 1,
- refon: call HplAdc12.getRefon(),
- r2_5v: call HplAdc12.isRef2_5V(),
- msc: (jiffies == 0) ? 1 : 0,
- sht0: config->sht,
- sht1: config->sht
- };
- adc12ctl1_t ctl1 = {
- adc12busy: 0,
- conseq: 2,
- adc12ssel: config->adc12ssel,
- adc12div: config->adc12div,
- issh: 0,
- shp: 1,
- shs: (jiffies == 0) ? 0 : 1,
- cstartadd: 0
- };
- adc12memctl_t memctl = {
- inch: config->inch,
- sref: config->sref,
- eos: 1
- };
- conversionMode = SINGLE_DATA_REPEAT;
- configureAdcPin( config->inch );
- call HplAdc12.setCtl0(ctl0);
- call HplAdc12.setCtl1(ctl1);
- call HplAdc12.setMCtl(0, memctl);
- call HplAdc12.setIEFlags(0x01);
- if (jiffies){
- atomic flags |= TIMERA_USED;
- prepareTimerA(jiffies, config->sampcon_ssel, config->sampcon_id);
- }
- call HplAdc12.startConversion();
- if (jiffies)
- startTimerA(); // go!
- }
- return result;
- }
-
- async command error_t SingleChannel.getMultipleData[uint8_t id](
- const msp430adc12_channel_config_t *config,
- uint16_t *buf, uint16_t length, uint16_t jiffies)
- {
- error_t result;
-#ifdef CHECK_ARGS
- if (!config || !buf || !length || jiffies == 1 || jiffies == 2)
- return EINVAL;
-#endif
- if ((result = clientAccessRequest(id)) == SUCCESS)
- {
- adc12ctl0_t ctl0 = {
- adc12sc: 0,
- enc: 0,
- adc12tovie: 0,
- adc12ovie: 0,
- adc12on: 1,
- refon: call HplAdc12.getRefon(),
- r2_5v: call HplAdc12.isRef2_5V(),
- msc: (jiffies == 0) ? 1 : 0,
- sht0: config->sht,
- sht1: config->sht
- };
- adc12ctl1_t ctl1 = {
- adc12busy: 0,
- conseq: (length > 16) ? 3 : 1,
- adc12ssel: config->adc12ssel,
- adc12div: config->adc12div,
- issh: 0,
- shp: 1,
- shs: (jiffies == 0) ? 0 : 1,
- cstartadd: 0
- };
- adc12memctl_t memctl = {
- inch: config->inch,
- sref: config->sref,
- eos: 0
- };
- uint16_t i, mask = 1;
- conversionMode = MULTIPLE_DATA;
- atomic {
- resultBuffer = buf;
- resultBufferLength = length;
- resultBufferIndex = 0;
- }
- configureAdcPin( config->inch );
- call HplAdc12.setCtl0(ctl0);
- call HplAdc12.setCtl1(ctl1);
- for (i=0; i<(length-1) && i < 15; i++)
- call HplAdc12.setMCtl(i, memctl);
- memctl.eos = 1;
- call HplAdc12.setMCtl(i, memctl);
- call HplAdc12.setIEFlags(mask << i);
-
- if (jiffies){
- atomic flags |= TIMERA_USED;
- prepareTimerA(jiffies, config->sampcon_ssel, config->sampcon_id);
- }
- call HplAdc12.startConversion();
- if (jiffies)
- startTimerA(); // go!
- }
- return result;
- }
-
- async command error_t SingleChannel.getMultipleDataRepeat[uint8_t id](
- const msp430adc12_channel_config_t *config,
- uint16_t *buf, uint8_t length, uint16_t jiffies)
- {
- error_t result;
-#ifdef CHECK_ARGS
- if (!config || !buf || !length || length > 16 || jiffies == 1 || jiffies == 2)
- return EINVAL;
-#endif
- if ((result = clientAccessRequest(id)) == SUCCESS)
- {
- adc12ctl0_t ctl0 = {
- adc12sc: 0,
- enc: 0,
- adc12tovie: 0,
- adc12ovie: 0,
- adc12on: 1,
- refon: call HplAdc12.getRefon(),
- r2_5v: call HplAdc12.isRef2_5V(),
- msc: (jiffies == 0) ? 1 : 0,
- sht0: config->sht,
- sht1: config->sht
- };
- adc12ctl1_t ctl1 = {
- adc12busy: 0,
- ctl1.conseq = 3,
- adc12ssel: config->adc12ssel,
- adc12div: config->adc12div,
- issh: 0,
- shp: 1,
- shs: (jiffies == 0) ? 0 : 1,
- cstartadd: 0
- };
- adc12memctl_t memctl = {
- inch: config->inch,
- sref: config->sref,
- eos: 0
- };
- uint16_t i, mask = 1;
- conversionMode = MULTIPLE_DATA_REPEAT;
- atomic {
- resultBuffer = buf;
- resultBufferLength = length;
- resultBufferIndex = 0;
- }
- configureAdcPin( config->inch );
- call HplAdc12.setCtl0(ctl0);
- call HplAdc12.setCtl1(ctl1);
- for (i=0; i<(length-1) && i < 15; i++)
- call HplAdc12.setMCtl(i, memctl);
- memctl.eos = 1;
- call HplAdc12.setMCtl(i, memctl);
- call HplAdc12.setIEFlags(mask << i);
-
- if (jiffies){
- atomic flags |= TIMERA_USED;
- prepareTimerA(jiffies, config->sampcon_ssel, config->sampcon_id);
- }
- call HplAdc12.startConversion();
- if (jiffies)
- startTimerA(); // go!
- }
- return result;
- }
-
- async event void TimerA.overflow(){}
- async event void CompareA0.fired(){}
- async event void CompareA1.fired(){}
-
-
- async event void HplAdc12.conversionDone(uint16_t iv)
- {
- switch (conversionMode)
- {
- case SINGLE_DATA:
- if (flags & FAST_MODE){
-#ifdef P6PIN_AUTO_CONFIGURE
- adc12memctl_t memctl = call HplAdc12.getMCtl(0);
- resetAdcPin( memctl.inch );
-#endif
- clientAccessFinished();
- // stopConversionSingleChannel()
- signal FastSingleChannel.singleDataReady[clientID](call HplAdc12.getMem(0));
- } else {
- stopConversionSingleChannel();
- signal SingleChannel.singleDataReady[clientID](call HplAdc12.getMem(0));
- }
- break;
- case SINGLE_DATA_REPEAT:
- {
- error_t repeatContinue;
- repeatContinue = signal SingleChannel.singleDataReady[clientID](
- call HplAdc12.getMem(0));
- if (repeatContinue == FAIL)
- stopConversionSingleChannel();
- break;
- }
- case MULTIPLE_DATA:
- {
- uint16_t i = 0, length;
- if (resultBufferLength - resultBufferIndex > 16)
- length = 16;
- else
- length = resultBufferLength - resultBufferIndex;
- do {
- *resultBuffer++ = call HplAdc12.getMem(i);
- } while (++i < length);
- resultBufferIndex += length;
-
- if (resultBufferLength - resultBufferIndex > 15)
- return;
- else if (resultBufferLength - resultBufferIndex > 0){
- adc12memctl_t memctl = call HplAdc12.getMCtl(0);
- memctl.eos = 1;
- call HplAdc12.setMCtl(resultBufferLength - resultBufferIndex, memctl);
- } else {
- stopConversionSingleChannel();
- signal SingleChannel.multipleDataReady[clientID](
- resultBuffer - resultBufferLength, resultBufferLength);
- }
- }
- break;
- case MULTIPLE_DATA_REPEAT:
- {
- uint8_t i = 0;
- do {
- *resultBuffer++ = call HplAdc12.getMem(i);
- } while (++i < resultBufferLength);
-
- resultBuffer = signal SingleChannel.multipleDataReady[clientID](
- resultBuffer-resultBufferLength,
- resultBufferLength);
- if (!resultBuffer)
- stopConversionSingleChannel();
- break;
- }
- } // switch
+ provides {
+ interface Resource[uint8_t id];
+ interface Msp430Adc12SingleChannel as SingleChannel[uint8_t id];
+ interface AsyncStdControl as DMAExtension[uint8_t id];
}
+} implementation {
+ components Msp430Adc12ImplP, HplAdc12P, Msp430TimerC, MainC, HplMsp430GeneralIOC,
+ new SimpleRoundRobinArbiterC(MSP430ADC12_RESOURCE) as Arbiter;
- default async event error_t SingleChannel.singleDataReady[uint8_t id](uint16_t data)
- {
- return FAIL;
- }
+ Resource = Arbiter;
+ SingleChannel = Msp430Adc12ImplP.SingleChannel;
+ DMAExtension = Msp430Adc12ImplP.DMAExtension;
- default async event void FastSingleChannel.singleDataReady[uint8_t id](uint16_t data)
- {
- return;
- }
-
- default async event uint16_t* SingleChannel.multipleDataReady[uint8_t id](
- uint16_t *buf, uint16_t length)
- {
- return 0;
- }
-
- async event void HplAdc12.memOverflow(){}
- async event void HplAdc12.conversionTimeOverflow(){}
-
+ Msp430Adc12ImplP.Init <- MainC;
+ Msp430Adc12ImplP.ADCArbiterInfo -> Arbiter;
+ Msp430Adc12ImplP.HplAdc12 -> HplAdc12P;
+ Msp430Adc12ImplP.Port60 -> HplMsp430GeneralIOC.Port60;
+ Msp430Adc12ImplP.Port61 -> HplMsp430GeneralIOC.Port61;
+ Msp430Adc12ImplP.Port62 -> HplMsp430GeneralIOC.Port62;
+ Msp430Adc12ImplP.Port63 -> HplMsp430GeneralIOC.Port63;
+ Msp430Adc12ImplP.Port64 -> HplMsp430GeneralIOC.Port64;
+ Msp430Adc12ImplP.Port65 -> HplMsp430GeneralIOC.Port65;
+ Msp430Adc12ImplP.Port66 -> HplMsp430GeneralIOC.Port66;
+ Msp430Adc12ImplP.Port67 -> HplMsp430GeneralIOC.Port67;
+
+ Msp430Adc12ImplP.TimerA -> Msp430TimerC.TimerA;
+ Msp430Adc12ImplP.ControlA0 -> Msp430TimerC.ControlA0;
+ Msp430Adc12ImplP.ControlA1 -> Msp430TimerC.ControlA1;
+ Msp430Adc12ImplP.CompareA0 -> Msp430TimerC.CompareA0;
+ Msp430Adc12ImplP.CompareA1 -> Msp430TimerC.CompareA1;
}
/*
- * Copyright (c) 2004, Technische Universitaet Berlin
+ * Copyright (c) 2006, Technische Universitaet Berlin
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
*/
/**
- * This interface exports access to the ADC12 on the level of
- * HAL1 on a per-channel basis. It allows to sample a channel once or
- * repeatedly (and signal an event per conversion result) or perform multiple
- * conversions for the same channel once or repeatedly (and signal an event per
- * multiple conversion results). It does not allow to sample different channels
- * with the same command.
+ *
+ * This interface provides access to the ADC12 on the level of HAL. It can be
+ * used to sample an adc channel once or repeatedly (one event is signalled per
+ * conversion result) or perform multiple conversions for a channel once or
+ * repeatedly (one event is signalled per multiple conversion results). It
+ * cannot be used to sample different adc channels with a single command.
+ * Sampling a channel requires calling a sequence of two commands, configureX()
+ * and getData(), where X is either 'Single', 'SingleRepeat', 'Multiple' or
+ * 'MultipleRepeat'. Conversion results will be signalled by the
+ * dataReadySingle() or dataReadyMultiple() event, depending on the previous
+ * configuration, i.e. there are four possible sequences:
+ *
+ * configureSingle() -> [ getData() -> singleDataReady() ]*
+ * or configureSingleRepeat() -> [ getData() -> singleDataReady() ]*
+ * or configureMultiple() -> [ getData() -> multipleDataReady() ]*
+ * or configureMultipleRepeat() -> getData() -> multipleDataReady()
*
- * @author Jan Hauer
- * @see Please refer to TEP 101 for more information about this component and its
- * intended use.
+ * where configureX() and getData() are commands called by the client and
+ * singleDataReady() and multipleDataReady() are events signalled back to the
+ * client by the adc subsystem. Note that a configuration is valid until
+ * the client reconfigures or releases the ADC (using the Resource
+ * interface), except for configureMultipleRepeat(), which is only valid
+ * for a single call to getData(). This means that after a successful
+ * configuration with, for example, configureSingle() the client may call
+ * getData() more than once without reconfiguring the ADC in between
+ * (if the client has not released the ADC via the Resource interface).
+ *
+ * @author Jan Hauer
*/
-#include <Msp430Adc12.h>
+#include "Msp430Adc12.h"
interface Msp430Adc12SingleChannel
{
+
/**
- * Samples an ADC channel once. If SUCCESS is returned, an event
- * <code>singleDataReady()</code> will be signalled with the conversion
- * result. Otherwise <code>singleDataReady()</code> will not be signalled.
+ * Configures the ADC to perform a single conversion. Any previous
+ * configuration will be overwritten. If SUCCESS is returned calling
+ * <code>getData()</code> will start the conversion immediately and a
+ * <code>singleDataReady()</code> event will be signalled with the conversion
+ * result when the conversion has finished.
*
* @param config ADC12 configuration data.
- * @return SUCCESS means conversion data will be signalled in
- * <code>singleDataReady()</code>.
+ *
+ * @return SUCCESS means that the ADC was configured successfully and
+ * <code>getData()</code> can be called to start the conversion.
*/
- async command error_t getSingleData(const msp430adc12_channel_config_t *config);
+ async command error_t configureSingle(const msp430adc12_channel_config_t *config);
- /** Samples an ADC channel repeatedly and signals an event
- * <code>singleDataReady()</code> after every single conversion. Conversion
- * result are signalled, until the client returns <code>FAIL</code> in the
- * <code>singleDataReady()</code> event handler. If this command does not
- * return SUCCESS then <code>singleDataReady()</code> will not be
- * signalled.<br><br> Successive conversions are performed as quickly as
- * possible if <code>jiffies</code> equals zero. Otherwise
- * <code>jiffies</code> define the time between successive conversions in
- * terms of clock ticks of "sampcon_ssel" and input divider "sampcon_id" as
- * specified in the <code>config</code> parameter.
+ /**
+ * Configures the ADC for repeated single channel conversion mode. Any
+ * previous configuration will be overwritten. If SUCCESS is returned calling
+ * <code>getData()</code> will start sampling the adc channel periodically
+ * (the first conversion is started immediately). The sampling period is
+ * specified by the <code>jiffies</code> parameter, which defines the time
+ * between successive conversions in terms of clock ticks of clock source
+ * "sampcon_ssel" and clock input divider "sampcon_id" as specified in the
+ * <code>config</code> parameter. If jiffies is zero successive conversions
+ * are performed as quickly as possible. Conversion result are signalled
+ * until the client returns <code>FAIL</code> in the
+ * <code>singleDataReady()</code> event handler.
*
* @param config ADC12 configuration data.
- * @param jiffies Sampling rate in terms of clock ticks of
- * "sampcon_ssel" and input divider "sampcon_id".
- * @return SUCCESS means conversion data will be signalled in
- * <code>singleDataReady()</code> until the client returns <code>FAIL</code>.
+ * @param jiffies Sampling period in terms of clock ticks of "sampcon_ssel" and
+ * input divider "sampcon_id".
+ *
+ * @return SUCCESS means that the ADC was configured successfully and
+ * <code>getData()</code> can be called to start with the first conversion.
*/
- async command error_t getSingleDataRepeat(const msp430adc12_channel_config_t *config,
- uint16_t jiffies);
+ async command error_t configureSingleRepeat(const msp430adc12_channel_config_t *config, uint16_t jiffies);
- /**
- *
- * Samples an ADC channel multiple times and signals one event
- * <code>multipleDataReady()</code> with all conversion results. If SUCCESS
- * is returned, the event <code>multipleDataReady</code> is signalled after
- * the buffer is filled with conversion results, otherwise
- * <code>multipleDataReady()</code> will not be signalled. <br><br>
- * Successive conversions are performed as quickly as possible if
- * <code>jiffies</code> equals zero. Otherwise <code>jiffies</code> define the
- * time between successive conversions in terms of clock ticks of
- * "sampcon_ssel" and input divider "sampcon_id" as specified in the
- * <code>config</code> parameter.
- *
- * @param config ADC12 configuration data.
- * @param jiffies Sampling rate in terms of clock ticks of
- * "sampcon_ssel" and input divider "sampcon_id".
- * @param buffer The buffer to store the conversion results. It must have a
- * minimum size of <code>numSamples * 2</code> byte !
- * @param numSamples Number of samples to take, buffer size must be greater or
- * equal than <code>numSamples * 2</code> byte !
- * @return SUCCESS means conversion data will be signalled in
- * <code>singleDataReady()</code>.
- */
- async command error_t getMultipleData( const msp430adc12_channel_config_t *config,
- uint16_t *buffer, uint16_t numSamples, uint16_t jiffies);
+
+ /**
+ * Configures the ADC for sampling a channel <code>numSamples</code> times
+ * with a given sampling period. Any previous configuration will be
+ * overwritten. In contrast to the <code>configureSingleRepeat()</code>
+ * command, this configuration means that only one event will be signalled
+ * after all samples have been taken (which is useful for high-frequency
+ * sampling). If SUCCESS is returned calling <code>getData()</code> will
+ * start sampling the adc channel <code>numSamples</code> times and the first
+ * conversion is started immediately. Conversion results are stored in a
+ * buffer allocated by the client (the <code>buffer</code>
+ * parameter). The sampling period is specified by the <code>jiffies</code>
+ * parameter, which defines the time between successive conversions in terms
+ * of clock ticks of clock source "sampcon_ssel" and clock input divider
+ * "sampcon_id" as specified in the <code>config</code> parameter. If jiffies
+ * is zero successive conversions are performed as quickly as possible. After
+ * <code>numSamples</code> conversions an event
+ * <code>multipleDataReady()</code> is signalled with the conversion results.
+ *
+ * @param config ADC12 configuration data.
+ * @param jiffies Sampling period in terms of clock ticks of "sampcon_ssel"
+ * and input divider "sampcon_id".
+ * @param buffer The user-allocated buffer in which the conversion results
+ * will be stored. It must have at least <code>numSamples</code> entries,
+ * i.e. it must have a size of at least <code>numSamples</code> * 2 byte.
+ * @param numSamples Number of adc samples
+ *
+ * @return SUCCESS means that the ADC was configured successfully and
+ * <code>getData()</code> can be called to start with the first conversion.
+ */
+ async command error_t configureMultiple( const msp430adc12_channel_config_t *config, uint16_t buffer[], uint16_t numSamples, uint16_t jiffies);
+
+ /**
+ *
+ * Configures the ADC for sampling a channel multiple times repeatedly. Any
+ * previous configuration will be overwritten. In contrast to the
+ * <code>configureSingleRepeat()</code> command this configuration means that
+ * an event with <code>numSamples</code> conversion results will be
+ * signalled, where 0 < <code>numSamples</code> <= 16. In contrast to the
+ * <code>configureMultiple()</code> command, this configuration means that
+ * <code>numSamples</code> conversion results will be signalled repeatedly
+ * until the client returns <code>FAIL</code> in the
+ * <code>multipleDataReady()</code> event handler.
+ *
+ * If <code>configureMultipleRepeat()</code> returns SUCCESS calling
+ * <code>getData()</code> will start the the first conversion immediately.
+ * The sampling period is specified by the <code>jiffies</code> parameter,
+ * which defines the time between successive conversions in terms of clock
+ * ticks of clock source "sampcon_ssel" and clock input divider "sampcon_id"
+ * as specified in the <code>config</code> parameter. If jiffies is zero
+ * successive conversions are performed as quickly as possible. After
+ * <code>numSamples</code> conversions an event
+ * <code>multipleDataReady()</code> is signalled with <code>numSamples</code>
+ * conversion results. If the client returns <code>SUCCESS</code> in the
+ * <code>multipleDataReady()</code> event handler, <code>numSamples</code>
+ * new conversions will be performed, otherwise not.
+ *
+ * @param config ADC12 configuration data.
+ * @param jiffies Sampling period in terms of clock ticks of "sampcon_ssel"
+ * and input divider "sampcon_id".
+ * @param buffer The user-allocated buffer in which the conversion results
+ * will be stored. It must have at least <code>numSamples</code> entries,
+ * i.e. it must have a size of at least <code>numSamples</code> * 2 byte.
+ * @param numSamples Number of adc samples to take, 0 <
+ * <code>numSamples</code> <= 16
+ *
+ * @return SUCCESS means that the ADC was configured successfully and
+ * <code>getData()</code> can be called to start with the first conversion.
+ */
+ async command error_t configureMultipleRepeat(const msp430adc12_channel_config_t *config, uint16_t buffer[], uint8_t numSamples, uint16_t jiffies);
- /**
- *
- * Samples an ADC channel up to 16 times and signals an event
- * <code>multipleDataReady()</code> with all conversion results repeatedly.
- * If SUCCESS is returned, the event <code>multipleDataReady</code> is
- * signalled after the buffer is filled with the first (up to 16) conversion
- * results, otherwise <code>multipleDataReady()</code> will not be signalled.
- * The conversion result are signalled repeatedly, until the client returns
- * <code>FAIL</code> in the <code>multipleDataReady()</code> event handler.
- * <br><br> Successive conversions are performed as quickly as possible if
- * <code>jiffies</code> equals zero. Otherwise <code>jiffies</code> define the
- * time between successive conversions in terms of clock ticks of
- * "sampcon_ssel" and input divider "sampcon_id" as specified in the
- * <code>config</code> parameter.
- *
- * @param config ADC12 configuration data. @param jiffies Jiffies in terms of
- * clock ticks of "sampcon_ssel" and input divider "sampcon_id". @param
- * buffer The buffer to store the conversion results. It must have a minimum
- * size of <code>numSamples * 2</code> byte !
- * @param jiffies Sampling rate in terms of clock ticks of
- * "sampcon_ssel" and input divider "sampcon_id".
- * @param numSamples Number of samples to take, 1 <= numSamples <= 16, buffer
- * size must be greater or equal than <code>numSamples * 2</code> byte !
- * @return SUCCESS means conversion data will be signalled in
- * <code>singleDataReady()</code> until the client returns <code>FAIL</code>.
- */
- async command error_t getMultipleDataRepeat(const msp430adc12_channel_config_t *config,
- uint16_t *buffer, uint8_t numSamples, uint16_t jiffies);
/**
- * Data from a call to <code>getSingleData()</code> or
- * <code>getSingleDataRepeat()</code> is ready. In the first case the return
- * value is ignored, in the second it defines whether another conversion
- * takes place (<code>SUCCESS()</code>) or not (<code>FAIL</code>).
+ * Starts sampling an adc channel using the configuration as specified by
+ * the last call to any of the four available configuration commands.
+ *
+ * @return SUCCESS means that the conversion was started successfully and an
+ * event singleDataReady() or multipleDataReady() will be signalled
+ * (depending on the previous configuration). Otherwise no such event will be
+ * signalled.
+ */
+ async command error_t getData();
+
+ /**
+ * A single ADC conversion result is ready. If the ADC was configured with
+ * the <code>configureSingle()</code> command, then the return value is
+ * ignored. If the ADC was configured with the
+ * <code>configureSingleRepeat()</code> command then the return value tells
+ * whether another conversion should be performed (<code>SUCCESS()</code>) or
+ * not (<code>FAIL</code>). If <code>SUCCESS()</code> is returned then the
+ * sampling period will be as specified in the
+ * <code>configureSingleRepeat()</code> command.
*
* @param data Conversion result (lower 12 bit).
+ *
* @return If this event is signalled as response to a call to
- * <code>getSingleDataRepeat()</code> then <code>SUCCESS</code> results in
+ * <code>configureSingleRepeat()</code> then <code>SUCCESS</code> results in
* another sampling and <code>FAIL</code> stops the repeated sampling.
* Otherwise the return value is ignored.
*/
async event error_t singleDataReady(uint16_t data);
/**
- * Data from a call to <code>getMultipleData()</code> or
- * <code>getMultipleDataRepeat()</code> is ready. In the first case the
- * return value is ignored, in the second a non-zero pointer defines where to
- * store the next <code>numSamples</code> conversion results and a null
- * pointer stops the repeated conversion mode.
+ * Multiple ADC conversion results are ready. If the ADC was configured
+ * with the <code>configureMultiple()</code> command, then the return value
+ * is ignored. If the ADC was configured with the
+ * <code>configureMultipleRepeat()</code> command then the returned pointer
+ * defines where to store the next <code>numSamples</code>
+ * conversion results (the client must make sure that the buffer is big
+ * enough!). Returning a null pointer means that the repeated conversion
+ * mode will be stopped.
*
- * @param buffer Conversion results (lower 12 bit are valid).
+ * @param buffer Conversion results (lower 12 bit are valid, respectively).
* @param numSamples Number of samples stored in <code>buffer</code>
- * @return A null pointer stops a repeated conversion mode. Any non-zero
- * value is interpreted as the next buffer, which must have size
- * <code>numSamples 2</code> byte!). Ignored if this event is a response to
- * <code>getMultipleData()</code>.
+ *
+ * @return
+ * A null pointer stops a repeated conversion mode. Any non-zero value is
+ * interpreted as the next buffer, which must have at least
+ * <code>numSamples</code> entries. The return value us ignored if the ADC
+ * was configured with <code>configureMultiple()</code>.
*/
- async event uint16_t* multipleDataReady(uint16_t *buffer, uint16_t
- numSamples);
+ async event uint16_t* multipleDataReady(uint16_t buffer[], uint16_t numSamples);
+
}
/*
- * Copyright (c) 2004, Technische Universität Berlin
+ * Copyright (c) 2006, Technische Universität Berlin
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* ========================================================================
*/
-module Msp430RefVoltArbiterP
+/**
+ * This component is meant to intercept requests to the <code>Resource</code>
+ * interface on their way to the adc arbiter. It checks whether the client's
+ * adc configuration requires the internal reference voltage generator of the
+ * MSP430 to be enabled during the conversion by inspecting the client's
+ * configuration data (using the <code>AdcConfigure</code> interface). If so it
+ * makes sure that Resource.granted() is held back until the reference voltage
+ * is stable. Clients SHOULD NOT wire to <code>Msp430RefVoltArbiterP</code> but
+ * to the Resource interface provided by
+ * <code>Msp430Adc12ClientAutoRVGC</code>.
+ *
+ * @author Jan Hauer
+ */
+
+configuration Msp430RefVoltArbiterP
{
provides interface Resource as ClientResource[uint8_t client];
uses {
interface Resource as AdcResource[uint8_t client];
- interface SplitControl as RefVolt_1_5V;
- interface SplitControl as RefVolt_2_5V;
- interface Msp430Adc12Config as Config[uint8_t client];
+ interface AdcConfigure<const msp430adc12_channel_config_t*> as Config[uint8_t client];
}
} implementation {
- enum {
- NO_OWNER = 0xFF,
- };
- norace uint8_t owner = NO_OWNER;
+ components Msp430RefVoltGeneratorP, Msp430RefVoltArbiterImplP,
+ new TimerMilliC() as SwitchOnDelayTimer,
+ new TimerMilliC() as SwitchOffDelayTimer,
+ HplAdc12P;
- task void switchOff();
-
- async command error_t ClientResource.request[uint8_t client]()
- {
- return call AdcResource.request[client]();
- }
-
- async command error_t ClientResource.immediateRequest[uint8_t client]()
- {
- msp430adc12_channel_config_t settings = call Config.getChannelSettings[client]();
- if (settings.sref == REFERENCE_VREFplus_AVss ||
- settings.sref == REFERENCE_VREFplus_VREFnegterm)
- // always fails, because of the possible start-up delay (and async-sync transition)
- return FAIL;
- else {
- error_t request = call AdcResource.immediateRequest[client]();
- if (request == SUCCESS)
- owner = client;
- return request;
- }
- }
+ ClientResource = Msp430RefVoltArbiterImplP.ClientResource;
+ AdcResource = Msp430RefVoltArbiterImplP.AdcResource;
+ Config = Msp430RefVoltArbiterImplP;
- event void AdcResource.granted[uint8_t client]()
- {
- msp430adc12_channel_config_t settings = call Config.getChannelSettings[client]();
- owner = client;
- if (settings.sref == REFERENCE_VREFplus_AVss ||
- settings.sref == REFERENCE_VREFplus_VREFnegterm){
- error_t started;
- if (settings.ref2_5v == REFVOLT_LEVEL_1_5)
- started = call RefVolt_1_5V.start();
- else
- started = call RefVolt_2_5V.start();
- if (started != SUCCESS){
- owner = NO_OWNER;
- call AdcResource.release[client]();
- call AdcResource.request[client]();
- }
- } else
- signal ClientResource.granted[client]();
- }
-
- event void RefVolt_1_5V.startDone(error_t error)
- {
- if (owner != NO_OWNER){
- // Note that it can still not be guaranteed that ClientResource.granted()
- // is not signalled after ClientResource.release() has been called.
- signal ClientResource.granted[owner]();
- }
- }
-
- event void RefVolt_2_5V.startDone(error_t error)
- {
- if (owner != NO_OWNER){
- // Note that it can still not be guaranteed that ClientResource.granted()
- // is not signalled after ClientResource.release() has been called.
- signal ClientResource.granted[owner]();
- }
- }
-
- async command void ClientResource.release[uint8_t client]()
- {
- atomic {
- if (owner == client){
- owner = NO_OWNER;
- post switchOff();
- }
- }
- call AdcResource.release[client]();
- }
-
- task void switchOff()
- {
- if (owner == NO_OWNER)
- if (call RefVolt_1_5V.stop() != SUCCESS)
- post switchOff();
- }
-
- event void RefVolt_1_5V.stopDone(error_t error)
- {
- }
-
- event void RefVolt_2_5V.stopDone(error_t error)
- {
- }
-
- async command uint8_t ClientResource.isOwner[uint8_t client]()
- {
- return call AdcResource.isOwner[client]();
- }
-
- default event void ClientResource.granted[uint8_t client](){}
- default async command error_t AdcResource.request[uint8_t client]()
- {
- return FAIL;
- }
- default async command error_t AdcResource.immediateRequest[uint8_t client]()
- {
- return FAIL;
- }
-
- default async command void AdcResource.release[uint8_t client](){}
- default async command msp430adc12_channel_config_t
- Config.getChannelSettings[uint8_t client]()
- {
- msp430adc12_channel_config_t defaultConfig = {INPUT_CHANNEL_NONE,0,0,0,0,0,0,0};
- return defaultConfig;
- }
+ Msp430RefVoltArbiterImplP.RefVolt_1_5V -> Msp430RefVoltGeneratorP.RefVolt_1_5V;
+ Msp430RefVoltArbiterImplP.RefVolt_2_5V -> Msp430RefVoltGeneratorP.RefVolt_2_5V;
+ Msp430RefVoltGeneratorP.SwitchOnTimer -> SwitchOnDelayTimer;
+ Msp430RefVoltGeneratorP.SwitchOffTimer -> SwitchOffDelayTimer;
+ Msp430RefVoltGeneratorP.HplAdc12 -> HplAdc12P;
}
if (call HplAdc12.isBusy())
return FAIL;
else {
- call HplAdc12.disableConversion();
- call HplAdc12.setRefOn();
+ adc12ctl0_t ctl0 = call HplAdc12.getCtl0();
+ ctl0.enc = 0;
+ call HplAdc12.setCtl0(ctl0);
+ ctl0.refon = 1;
if (level == REFERENCE_1_5V_PENDING)
- call HplAdc12.setRef1_5V();
+ ctl0.r2_5v = 0;
else
- call HplAdc12.setRef2_5V();
+ ctl0.r2_5v = 1;
+ call HplAdc12.setCtl0(ctl0);
return SUCCESS;
}
}
if (call HplAdc12.isBusy())
return FAIL;
else {
- call HplAdc12.disableConversion();
- call HplAdc12.resetRefOn();
+ adc12ctl0_t ctl0 = call HplAdc12.getCtl0();
+ ctl0.enc = 0;
+ call HplAdc12.setCtl0(ctl0);
+ ctl0.refon = 0;
+ call HplAdc12.setCtl0(ctl0);
return SUCCESS;
}
}
*/
async command void makeInput();
+ async command bool isInput();
+
/**
* Set pin direction to output.
*/
async command void makeOutput();
-
+
+ async command bool isOutput();
+
/**
* Set pin for module specific functionality.
*/
async command void selectModuleFunc();
-
+
+ async command bool isModuleFunc();
+
/**
* Set pin for I/O functionality.
*/
async command void selectIOFunc();
+
+ async command bool isIOFunc();
}
async command uint8_t IO.getRaw() { return PORTxIN & (0x01 << pin); }
async command bool IO.get() { return (call IO.getRaw() != 0); }
async command void IO.makeInput() { atomic PORTxDIR &= ~(0x01 << pin); }
+ async command bool IO.isInput() { return (PORTxDIR & (0x01 << pin)) == 0; }
async command void IO.makeOutput() { atomic PORTxDIR |= (0x01 << pin); }
+ async command bool IO.isOutput() { return (PORTxDIR & (0x01 << pin)) != 0; }
async command void IO.selectModuleFunc() { atomic PORTxSEL |= (0x01 << pin); }
+ async command bool IO.isModuleFunc() { return (PORTxSEL & (0x01<<pin)) != 0; }
async command void IO.selectIOFunc() { atomic PORTxSEL &= ~(0x01 << pin); }
+ async command bool IO.isIOFunc() { return (PORTxSEL & (0x01<<pin)) == 0; }
}
async command void OF.clear() { atomic IFG1 &= ~OFIFG; }
async command void ACCV.clear() { atomic FCTL3 &= ~ACCVIFG; }
- async command bool NMI.getValue() { bool b; atomic b=(IFG1 >> NMIIFG) & 0x01; return b; }
- async command bool OF.getValue() { bool b; atomic b=(IFG1 >> OFIFG) & 0x01; return b; }
- async command bool ACCV.getValue() { bool b; atomic b=(FCTL3 >> ACCVIFG) & 0x01; return b; }
+ async command bool NMI.getValue() { bool b; atomic b=(IFG1 & NMIIFG) & 0x01; return b; }
+ async command bool OF.getValue() { bool b; atomic b=(IFG1 & OFIFG) & 0x01; return b; }
+ async command bool ACCV.getValue() { bool b; atomic b=(FCTL3 & ACCVIFG) & 0x01; return b; }
async command void NMI.edge(bool l2h) {
volatile uint16_t _watchdog;
async command void GeneralIO.toggle() { call HplGeneralIO.toggle(); }
async command bool GeneralIO.get() { return call HplGeneralIO.get(); }
async command void GeneralIO.makeInput() { call HplGeneralIO.makeInput(); }
+ async command bool GeneralIO.isInput() { return call HplGeneralIO.isInput(); }
async command void GeneralIO.makeOutput() { call HplGeneralIO.makeOutput(); }
+ async command bool GeneralIO.isOutput() { return call HplGeneralIO.isOutput(); }
}
ReadStream = AdcReadStreamClientC;
components Msp430InternalTemperatureP;
- AdcReadClientC.Msp430Adc12Config -> Msp430InternalTemperatureP;
- AdcReadStreamClientC.Msp430Adc12Config -> Msp430InternalTemperatureP;
+ AdcReadClientC.AdcConfigure -> Msp430InternalTemperatureP;
+ AdcReadStreamClientC.AdcConfigure -> Msp430InternalTemperatureP;
}
#include "Msp430Adc12.h"
module Msp430InternalTemperatureP {
- provides interface Msp430Adc12Config;
+ provides interface AdcConfigure<const msp430adc12_channel_config_t*>;
}
implementation {
- async command msp430adc12_channel_config_t Msp430Adc12Config.getChannelSettings() {
- msp430adc12_channel_config_t config = {
+ const msp430adc12_channel_config_t config = {
inch: TEMPERATURE_DIODE_CHANNEL,
sref: REFERENCE_VREFplus_AVss,
ref2_5v: REFVOLT_LEVEL_1_5,
sht: SAMPLE_HOLD_4_CYCLES,
sampcon_ssel: SAMPCON_SOURCE_SMCLK,
sampcon_id: SAMPCON_CLOCK_DIV_1
- };
-
- return config;
+ };
+
+ async command const msp430adc12_channel_config_t* AdcConfigure.getConfiguration()
+ {
+ return &config;
}
}
ReadStream = AdcReadStreamClientC;
components Msp430InternalVoltageP;
- AdcReadClientC.Msp430Adc12Config -> Msp430InternalVoltageP;
- AdcReadStreamClientC.Msp430Adc12Config -> Msp430InternalVoltageP;
+ AdcReadClientC.AdcConfigure -> Msp430InternalVoltageP;
+ AdcReadStreamClientC.AdcConfigure -> Msp430InternalVoltageP;
components new AdcReadNowClientC();
Resource = AdcReadNowClientC;
ReadNow = AdcReadNowClientC;
- AdcReadNowClientC.Msp430Adc12Config -> Msp430InternalVoltageP;
+ AdcReadNowClientC.AdcConfigure -> Msp430InternalVoltageP;
}
#include "Msp430Adc12.h"
module Msp430InternalVoltageP {
- provides interface Msp430Adc12Config;
+ provides interface AdcConfigure<const msp430adc12_channel_config_t*>;
}
implementation {
- async command msp430adc12_channel_config_t Msp430Adc12Config.getChannelSettings() {
- msp430adc12_channel_config_t config = {
+ const msp430adc12_channel_config_t config = {
inch: SUPPLY_VOLTAGE_HALF_CHANNEL,
sref: REFERENCE_VREFplus_AVss,
ref2_5v: REFVOLT_LEVEL_1_5,
sht: SAMPLE_HOLD_4_CYCLES,
sampcon_ssel: SAMPCON_SOURCE_SMCLK,
sampcon_id: SAMPCON_CLOCK_DIV_1
- };
-
- return config;
+ };
+
+ async command const msp430adc12_channel_config_t* AdcConfigure.getConfiguration()
+ {
+ return &config;
}
}
*/
/**
- * TimerMilliC is the TinyOS TimerMilli component. OSKI will expect
- * TimerMilliC to exist. It's in the platform directory so that the platform
- * can directly manage how it chooses to implement the timer. It is fully
- * expected that the standard TinyOS MultiplexTimerM component will be used for
- * all platforms, and that this configuration only specifies (implicitly or
- * explicitly) how precisely to use the hardware resources.
+ * HilTimerMilliC provides a parameterized interface to a virtualized
+ * millisecond timer. TimerMilliC in tos/system/ uses this component to
+ * allocate new timers.
*
* @author Cory Sharp <cssharp@eecs.berkeley.edu>
* @see Please refer to TEP 102 for more information about this component and its
* intended use.
*/
-#include "Timer.h"
-
configuration HilTimerMilliC
{
provides interface Init;
}
implementation
{
- components new AlarmMilliC(), new AlarmToTimerC(TMilli),
- new VirtualizeTimerC(TMilli,uniqueCount(UQ_TIMER_MILLI));
+ components new AlarmMilli32C();
+ components new AlarmToTimerC(TMilli);
+ components new VirtualizeTimerC(TMilli,uniqueCount(UQ_TIMER_MILLI));
- Init = AlarmMilliC;
+ Init = AlarmMilli32C;
TimerMilli = VirtualizeTimerC;
VirtualizeTimerC.TimerFrom -> AlarmToTimerC;
- AlarmToTimerC.Alarm -> AlarmMilliC;
+ AlarmToTimerC.Alarm -> AlarmMilli32C;
}
* intended use.
*/
-#include "Timer.h"
-
configuration Msp430Counter32khzC
{
provides interface Counter<T32khz,uint16_t> as Msp430Counter32khz;
}
implementation
{
- components Msp430TimerC
- , new Msp430CounterC(T32khz) as Counter
- ;
+ components Msp430TimerC;
+ components new Msp430CounterC(T32khz) as Counter;
Msp430Counter32khz = Counter;
Counter.Msp430Timer -> Msp430TimerC.TimerB;
/**
* Msp430Timer32khzMapC presents as paramaterized interfaces all of the 32khz
* hardware timers on the MSP430 that are available for compile time allocation
- * by "new Alarm32khzC()", "new AlarmMilliC()", and so on.
+ * by "new Alarm32khz16C()", "new AlarmMilli32C()", and so on.
*
* Platforms based on the MSP430 are encouraged to copy in and override this
* file, presenting only the hardware timers that are available for allocation
/*
- * Copyright (c) 2004-2005, Technische Universität Berlin
+ * Copyright (c) 2004-2005, Technische Universitaet Berlin
* All rights reserved.
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * - Neither the name of the Technische Universität Berlin nor the names
+ * - Neither the name of the Technische Universitaet Berlin nor the names
* of its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
- * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
- * Byte-level interface to control a USART.
+ * Byte-level interface to control a USART.
* <p>The USART can be switched to SPI- or UART-mode. The interface follows
* the convention of being stateless, thus a higher layer has to maintain
* state information. I.e. calling <code>tx</done> will transmit a byte of
* data in the mode (SPI or UART) the USART has been set to before.
*
+ * @author Vlado Handziski (handzisk@tkn.tu-berlin.de)
* @author Jan Hauer (hauer@tkn.tu-berlin.de)
* @author Joe Polastre
* @version $Revision$ $Date$
*/
-
+
#include "msp430usart.h"
interface HplMsp430Usart {
-
+
/**
- * Returns an enum value corresponding to the current mode of the
- * USART module. Allows one to read the module mode, change it, and
- * then reset it back to its original state after use.
+ * Sets the UxCTL Control Register
*/
- async command msp430_usartmode_t getMode();
-
+ async command void setUctl(msp430_uctl_t control);
+
/**
- * Sets the USART mode to one of the options from msp430_usartmode_t
- * defined in MSP430USART.h
- *
- * @return SUCCESS if the mode was changed
+ * Reads the UxCTL Control Register
*/
- async command void setMode(msp430_usartmode_t mode);
-
+ async command msp430_uctl_t getUctl();
+
/**
- * Returns TRUE if the USART has UART TX mode enabled
+ * Sets the UxTCTL Transmit Control Register
*/
- async command bool isUARTtx();
-
+ async command void setUtctl(msp430_utctl_t control);
+
/**
- * Returns TRUE if the USART has UART RX mode enabled
+ * Reads the UxTCTL Transmit Control Register
*/
- async command bool isUARTrx();
-
+ async command msp430_utctl_t getUtctl();
+
+ /**
+ * Sets the UxRCTL Receive Control Register
+ */
+ async command void setUrctl(msp430_urctl_t control);
+
/**
- * Returns TRUE if the USART is set to UART mode (both RX and TX)
+ * Reads the UxRCTL Receive Control Register
*/
- async command bool isUART();
+ async command msp430_urctl_t getUrctl();
- /**
- * Enables both the Rx and the Tx UART modules.
+ /**
+ * Sets the UxBR0 and UxBR1 Baud Rate Control Registers
*/
- async command void enableUART();
+ async command void setUbr(uint16_t ubr);
- /**
- * Disables both the Rx and the Tx UART modules.
+ /**
+ * Reads the UxBR0 and UxBR1 Baud Rate Control Registers
*/
- async command void disableUART();
-
- /**
- * Enables the UART TX functionality of the USART module.
+ async command uint16_t getUbr();
+
+ /**
+ * Sets the UxMCTL Modulation Control Register
*/
- async command void enableUARTTx();
-
- /**
- * Disables the UART TX module.
+ async command void setUmctl(uint8_t umctl);
+
+ /**
+ * Reads the UxMCTL Modulation Control Register
*/
- async command void disableUARTTx();
-
- /**
- * Enables the UART RX functionality of the USART module.
+ async command uint8_t getUmctl();
+
+ async command void resetUsart(bool reset);
+
+ /**
+ * Returns an enum value corresponding to the current mode of the
+ * USART module.
+ */
+ async command msp430_usartmode_t getMode();
+
+ /**
+ * Returns TRUE if the USART has Uart TX mode enabled
*/
- async command void enableUARTRx();
+ async command bool isUartTx();
+
+ /**
+ * Returns TRUE if the USART has Uart RX mode enabled
+ */
+ async command bool isUartRx();
+
+ /**
+ * Returns TRUE if the USART is set to Uart mode (both RX and TX)
+ */
+ async command bool isUart();
- /**
- * Disables the UART RX module.
+ /**
+ * Enables both the Rx and the Tx Uart modules.
*/
- async command void disableUARTRx();
+ async command void enableUart();
- /**
- * Enables the USART when in SPI mode.
+ /**
+ * Disables both the Rx and the Tx Uart modules.
*/
- async command void enableSPI();
+ async command void disableUart();
- /**
- * Disables the USART when in SPI mode.
+ /**
+ * Enables the Uart TX functionality of the USART module.
*/
- async command void disableSPI();
+ async command void enableUartTx();
/**
- * Enables the I2C module (register flags)
+ * Disables the Uart TX module.
*/
- async command void enableI2C();
+ async command void disableUartTx();
/**
- * Disables the I2C module
+ * Enables the Uart RX functionality of the USART module.
*/
- async command void disableI2C();
-
+ async command void enableUartRx();
+
/**
- * Returns TRUE if the USART is set to SPI mode
+ * Disables the Uart RX module.
*/
- async command bool isSPI();
-
- /**
- * Switches USART to SPI mode.
+ async command void disableUartRx();
+
+ /**
+ * Enables the USART when in Spi mode.
*/
- async command void setModeSPI();
-
- /**
- * Switches USART to UART TX mode (RX pins disabled).
- * Interrupts disabled by default.
- */
- async command void setModeUART_TX();
-
- /**
- * Switches USART to UART RX mode (TX pins disabled)..
- * Interrupts disabled by default.
- */
- async command void setModeUART_RX();
-
- /**
- * Switches USART to UART mode (RX and TX enabled)
+ async command void enableSpi();
+
+ /**
+ * Disables the USART when in Spi mode.
+ */
+ async command void disableSpi();
+
+ /**
+ * Returns TRUE if the USART is set to Spi mode
+ */
+ async command bool isSpi();
+
+ /**
+ * Switches USART to Spi mode.
+ */
+ async command void setModeSpi(msp430_spi_config_t* config);
+
+ /**
+ * Switches USART to Uart TX mode (RX pins disabled).
* Interrupts disabled by default.
- */
- async command void setModeUART();
-
+ */
+ async command void setModeUartTx(msp430_uart_config_t* config);
+
/**
- * Returns TRUE if the module is set to I2C mode for MSP430 parts
- * that support hardware I2C.
+ * Switches USART to Uart RX mode (TX pins disabled)..
+ * Interrupts disabled by default.
*/
- async command bool isI2C();
-
+ async command void setModeUartRx(msp430_uart_config_t* config);
+
/**
- * Switches USART to I2C mode for MSP430 parts that support hardware
- * I2C. Interrupts disabled by default.
+ * Switches USART to Uart mode (RX and TX enabled)
+ * Interrupts disabled by default.
*/
- async command void setModeI2C();
-
- async command void setClockSource(uint8_t source);
-
- async command void setClockRate(uint16_t baudrate, uint8_t mctl);
-
+ async command void setModeUart(msp430_uart_config_t* config);
+
/* Dis/enabling of UTXIFG / URXIFG */
async command void disableRxIntr();
async command void disableTxIntr();
+ async command void disableIntr();
async command void enableRxIntr();
async command void enableTxIntr();
-
+ async command void enableIntr();
+
/**
* TRUE if TX interrupt pending, flag must be cleared explicitly
*/
async command bool isTxIntrPending();
-
+
/**
* TRUE if RX interrupt pending, flag must be cleared explicitly
*/
async command bool isRxIntrPending();
-
+
/**
* Clears RX interrupt pending flag
- */
- async command error_t clrRxIntr();
-
+ */
+ async command void clrRxIntr();
+
/**
* Clears TX interrupt pending flag
*/
- async command error_t clrTxIntr();
+ async command void clrTxIntr();
+ /**
+ * Clears both TX and RX interrupt pending flags
+ */
+ async command void clrIntr();
- /**
+ /**
* SUCCESS if the TX buffer is empty and all of the bits have been
* shifted out
*/
async command bool isTxEmpty();
-
- /**
+
+ /**
* Transmit a byte of data. When the transmission is completed,
* <code>txDone</done> is generated. Only then a new byte may be
* transmitted, otherwise the previous byte will be overwritten.
- * The mode of transmission (UART or SPI) depends on the current
+ * The mode of transmission (Uart or Spi) depends on the current
* state of the USART, which must be managed by a higher layer.
*
* @return SUCCESS always.
*/
async command void tx(uint8_t data);
-
+
/**
* Get current value from RX-buffer.
*
async command uint8_t rx();
}
-
* @version $Revision$ $Date$
*/
-#include "msp430UsartResource.h"
+#include "msp430usart.h"
configuration HplMsp430Usart0C {
-
- provides interface AsyncStdControl;
+
provides interface HplMsp430Usart;
provides interface HplMsp430UsartInterrupts;
-
+ provides interface HplMsp430I2CInterrupts;
+
}
implementation {
components HplMsp430Usart0P as HplUsartP;
- components HplMsp430GeneralIOC as GIO;
-
- AsyncStdControl = HplUsartP;
HplMsp430Usart = HplUsartP;
HplMsp430UsartInterrupts = HplUsartP;
+ HplMsp430I2CInterrupts = HplUsartP;
+ components HplMsp430GeneralIOC as GIO;
HplUsartP.SIMO -> GIO.SIMO0;
HplUsartP.SOMI -> GIO.SOMI0;
HplUsartP.UCLK -> GIO.UCLK0;
-/*
- * Copyright (c) 2005-2006 Arch Rock Corporation
+/**
+ * Copyright (c) 2005-2006 Arched Rock Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
- * - Neither the name of the Arch Rock Corporation nor the names of
+ * - Neither the name of the Arched Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* OF THE POSSIBILITY OF SUCH DAMAGE
*/
-/*
- * Copyright (c) 2004-2005, Technische Universitat Berlin
+/**
+ * Copyright (c) 2004-2005, Technische Universitaet Berlin
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * - Neither the name of the Technische Universitat Berlin nor the names
+ * - Neither the name of the Technische Universitaet Berlin nor the names
* of its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include "msp430usart.h"
/**
* Implementation of USART0 lowlevel functionality - stateless.
* Setting a mode will by default disable USART-Interrupts.
*
* @author: Jan Hauer <hauer@tkn.tu-berlin.de>
- * @author: Jonathan Hui <jhui@archrock.com>
+ * @author: Jonathan Hui <jhui@archedrock.com>
+ * @author: Vlado Handziski <handzisk@tkn.tu-berlin.de>
* @author: Joe Polastre
* @version $Revision$ $Date$
*/
module HplMsp430Usart0P {
- provides interface AsyncStdControl;
provides interface HplMsp430Usart as Usart;
provides interface HplMsp430UsartInterrupts as Interrupts;
-
+ provides interface HplMsp430I2CInterrupts as I2CInterrupts;
+
+ uses interface HplMsp430I2C as HplI2C;
uses interface HplMsp430GeneralIO as SIMO;
uses interface HplMsp430GeneralIO as SOMI;
uses interface HplMsp430GeneralIO as UCLK;
uses interface HplMsp430GeneralIO as URXD;
uses interface HplMsp430GeneralIO as UTXD;
}
+
implementation
{
MSP430REG_NORACE(IE1);
MSP430REG_NORACE(ME1);
MSP430REG_NORACE(IFG1);
MSP430REG_NORACE(U0TCTL);
+ MSP430REG_NORACE(U0RCTL);
MSP430REG_NORACE(U0TXBUF);
-
- uint16_t l_br;
- uint8_t l_mctl;
- uint8_t l_ssel;
TOSH_SIGNAL(UART0RX_VECTOR) {
uint8_t temp = U0RXBUF;
}
TOSH_SIGNAL(UART0TX_VECTOR) {
- signal Interrupts.txDone();
+ if ( call HplI2C.isI2C() )
+ signal I2CInterrupts.fired();
+ else
+ signal Interrupts.txDone();
}
- async command error_t AsyncStdControl.start() {
- return SUCCESS;
+ async command void Usart.setUctl(msp430_uctl_t control) {
+ U0CTL=uctl2int(control);
}
-
- async command error_t AsyncStdControl.stop() {
- call Usart.disableSPI();
- call Usart.disableI2C();
- call Usart.disableUART();
- return SUCCESS;
+
+ async command msp430_uctl_t Usart.getUctl() {
+ return int2uctl(U0CTL);
+ }
+
+ async command void Usart.setUtctl(msp430_utctl_t control) {
+ U0TCTL=utctl2int(control);
+ }
+
+ async command msp430_utctl_t Usart.getUtctl() {
+ return int2utctl(U0TCTL);
}
- async command bool Usart.isSPI() {
+ async command void Usart.setUrctl(msp430_urctl_t control) {
+ U0RCTL=urctl2int(control);
+ }
+
+ async command msp430_urctl_t Usart.getUrctl() {
+ return int2urctl(U0RCTL);
+ }
+
+ async command void Usart.setUbr(uint16_t control) {
atomic {
- return (U0CTL & SYNC) && (ME1 & USPIE0);
+ U0BR0 = control & 0x00FF;
+ U0BR1 = (control >> 8) & 0x00FF;
}
}
- async command bool Usart.isUART() {
+ async command uint16_t Usart.getUbr() {
+ return (U0BR1 << 8) + U0BR0;
+ }
+
+ async command void Usart.setUmctl(uint8_t control) {
+ U0MCTL=control;
+ }
+
+ async command uint8_t Usart.getUmctl() {
+ return U0MCTL;
+ }
+
+ async command void Usart.resetUsart(bool reset) {
+ if (reset) {
+ U0CTL = SWRST;
+ }
+ else {
+ CLR_FLAG(U0CTL, SWRST);
+ }
+ }
+
+ async command bool Usart.isSpi() {
atomic {
- return !(U0CTL & SYNC) && ((ME1 & UTXE0) && (ME1 & URXE0));
+ return (U0CTL & SYNC) && (ME1 & USPIE0);
}
}
- async command bool Usart.isUARTtx() {
+ async command bool Usart.isUart() {
atomic {
- return !(U0CTL & SYNC) && (ME1 & UTXE0);
+ return !(U0CTL & SYNC) && ((ME1 & UTXE0) && (ME1 & URXE0));
}
}
- async command bool Usart.isUARTrx() {
+ async command bool Usart.isUartTx() {
atomic {
- return !(U0CTL & SYNC) && (ME1 & URXE0);
+ return !(U0CTL & SYNC) && (ME1 & UTXE0);
}
}
- async command bool Usart.isI2C() {
+ async command bool Usart.isUartRx() {
atomic {
- return ((U0CTL & I2C) && (U0CTL & SYNC) && (U0CTL & I2CEN));
+ return !(U0CTL & SYNC) && (ME1 & URXE0);
}
}
async command msp430_usartmode_t Usart.getMode() {
- if (call Usart.isUART())
+ if (call Usart.isUart())
return USART_UART;
- else if (call Usart.isUARTrx())
+ else if (call Usart.isUartRx())
return USART_UART_RX;
- else if (call Usart.isUARTtx())
+ else if (call Usart.isUartTx())
return USART_UART_TX;
- else if (call Usart.isSPI())
+ else if (call Usart.isSpi())
return USART_SPI;
- else if (call Usart.isI2C())
+ else if (call HplI2C.isI2C())
return USART_I2C;
else
return USART_NONE;
}
- /**
- * Sets the USART mode to one of the options from msp430_usartmode_t
- * defined in MSP430Usart.h
- */
- async command void Usart.setMode(msp430_usartmode_t _mode) {
- switch (_mode) {
- case USART_UART:
- call Usart.setModeUART();
- break;
- case USART_UART_RX:
- call Usart.setModeUART_RX();
- break;
- case USART_UART_TX:
- call Usart.setModeUART_TX();
- break;
- case USART_SPI:
- call Usart.setModeSPI();
- break;
- case USART_I2C:
- call Usart.setModeI2C();
- break;
- default:
- break;
- }
- }
-
- async command void Usart.enableUART() {
+ async command void Usart.enableUart() {
atomic{
call UTXD.selectModuleFunc();
call URXD.selectModuleFunc();
ME1 |= (UTXE0 | URXE0); // USART0 UART module enable
}
- async command void Usart.disableUART() {
- ME1 &= ~(UTXE0 | URXE0); // USART0 UART module enable
+ async command void Usart.disableUart() {
atomic {
+ ME1 &= ~(UTXE0 | URXE0); // USART0 UART module enable
+ call Usart.resetUsart(TRUE);
call UTXD.selectIOFunc();
call URXD.selectIOFunc();
}
}
- async command void Usart.enableUARTTx() {
+ async command void Usart.enableUartTx() {
call UTXD.selectModuleFunc();
ME1 |= UTXE0; // USART0 UART Tx module enable
}
- async command void Usart.disableUARTTx() {
+ async command void Usart.disableUartTx() {
ME1 &= ~UTXE0; // USART0 UART Tx module enable
call UTXD.selectIOFunc();
}
- async command void Usart.enableUARTRx() {
+ async command void Usart.enableUartRx() {
call URXD.selectModuleFunc();
ME1 |= URXE0; // USART0 UART Rx module enable
}
- async command void Usart.disableUARTRx() {
+ async command void Usart.disableUartRx() {
ME1 &= ~URXE0; // USART0 UART Rx module disable
call URXD.selectIOFunc();
}
- async command void Usart.enableSPI() {
- ME1 |= USPIE0; // USART0 SPI module enable
- //FIXME: Set pins in ModuleFunction?
+ async command void Usart.enableSpi() {
atomic {
call SIMO.selectModuleFunc();
call SOMI.selectModuleFunc();
call UCLK.selectModuleFunc();
}
+ ME1 |= USPIE0; // USART0 SPI module enable
}
- async command void Usart.disableSPI() {
- ME1 &= ~USPIE0; // USART0 SPI module disable
+ async command void Usart.disableSpi() {
atomic {
+ ME1 &= ~USPIE0; // USART0 SPI module disable
+ call Usart.resetUsart(TRUE);
call SIMO.selectIOFunc();
call SOMI.selectIOFunc();
call UCLK.selectIOFunc();
}
}
- async command void Usart.enableI2C() {
- atomic U0CTL |= I2C | I2CEN | SYNC;
- }
+ void configSpi(msp430_spi_config_t* config) {
+ msp430_uctl_t uctl = call Usart.getUctl();
+ msp430_utctl_t utctl = call Usart.getUtctl();
- async command void Usart.disableI2C() {
- atomic U0CTL &= ~(I2C | I2CEN | SYNC);
- }
+ uctl.clen = config->clen;
+ uctl.listen = config->listen;
+ uctl.mm = config->mm;
+ uctl.sync = 1;
- async command void Usart.setModeSPI() {
- // check if we are already in SPI mode
- if (call Usart.isSPI())
- return;
+ utctl.ckph = config->ckph;
+ utctl.ckpl = config->ckpl;
+ utctl.ssel = config->ssel;
+ utctl.stc = config->stc;
+
+ call Usart.setUctl(uctl);
+ call Usart.setUtctl(utctl);
+ call Usart.setUbr(config->ubr);
+ call Usart.setUmctl(0x00);
+ }
- call Usart.disableUART();
- call Usart.disableI2C();
+ async command void Usart.setModeSpi(msp430_spi_config_t* config) {
atomic {
- call SIMO.selectModuleFunc();
- call SOMI.selectModuleFunc();
- call UCLK.selectModuleFunc();
-
- U0CTL = SWRST;
- U0CTL |= CHAR | SYNC | MM; // 8-bit char, SPI-mode, USART as master
- U0CTL &= ~(0x20);
-
- U0TCTL = STC ; // 3-pin
- U0TCTL |= CKPH; // half-cycle delayed UCLK
-
- U0TCTL &= ~(SSEL_0 | SSEL_1 | SSEL_2 | SSEL_3);
- if (l_ssel & 0x80)
- U0TCTL |= (l_ssel & 0x7F);
- else
- U0TCTL |= SSEL_SMCLK; // use SMCLK, assuming 1MHz
-
- if (l_br != 0) {
- U0BR0 = l_br & 0x0FF;
- U0BR1 = (l_br >> 8) & 0x0FF;
- }
- else {
- U0BR0 = 0x02; // as fast as possible
- U0BR1 = 0x00;
- }
- U0MCTL = 0;
-
- ME1 |= USPIE0; // USART SPI module enable
- U0CTL &= ~SWRST;
-
- IFG1 &= ~(UTXIFG0 | URXIFG0);
- IE1 &= ~(UTXIE0 | URXIE0); // interrupt disabled
+ configSpi(config);
+ call Usart.enableSpi();
+ call Usart.resetUsart(FALSE);
+ call Usart.clrIntr();
+ call Usart.disableIntr();
}
return;
}
- void setUARTModeCommon() {
- atomic {
- U0CTL = SWRST;
- U0CTL |= CHAR; // 8-bit char, UART-mode
- U0RCTL &= ~URXEIE; // even erroneous characters trigger interrupts
+ void configUart(msp430_uart_config_t* config) {
+ msp430_uctl_t uctl = call Usart.getUctl();
+ msp430_utctl_t utctl = call Usart.getUtctl();
+ msp430_urctl_t urctl = call Usart.getUrctl();
+ uctl.pena = config->pena;
+ uctl.pev = config->pev;
+ uctl.spb = config->spb;
+ uctl.clen = config->clen;
+ uctl.listen = config->listen;
+ uctl.sync = 0;
+ uctl.mm = config->mm;
- U0CTL = SWRST;
- U0CTL |= CHAR; // 8-bit char, UART-mode
-
- if (l_ssel & 0x80) {
- U0TCTL &= ~SSEL_3;
- U0TCTL |= (l_ssel & 0x7F);
- }
- else {
- U0TCTL &= ~SSEL_3;
- U0TCTL |= SSEL_ACLK; // use ACLK, assuming 32khz
- }
-
- if ((l_mctl != 0) || (l_br != 0)) {
- U0BR0 = l_br & 0x0FF;
- U0BR1 = (l_br >> 8) & 0x0FF;
- U0MCTL = l_mctl;
- }
- else {
- U0BR0 = 0x03; // 9600 baud
- U0BR1 = 0x00;
- U0MCTL = 0x4A;
- }
+ utctl.ckpl = config->ckpl;
+ utctl.ssel = config->ssel;
+ utctl.urxse = config->urxse;
- ME1 &= ~USPIE0; // USART0 SPI module disable
- ME1 |= (UTXE0 | URXE0); //USART0 UART module enable;
+ urctl.urxeie = config->urxeie;
+ urctl.urxwie = config->urxwie;
- U0CTL &= ~SWRST;
-
- IFG1 &= ~(UTXIFG0 | URXIFG0);
- IE1 &= ~(UTXIE0 | URXIE0); // interrupt disabled
- }
- return;
+ call Usart.setUctl(uctl);
+ call Usart.setUtctl(utctl);
+ call Usart.setUrctl(urctl);
+ call Usart.setUbr(config->ubr);
+ call Usart.setUmctl(config->umctl);
}
- async command void Usart.setModeUART_TX() {
- // check if we are already in UART mode
- if (call Usart.getMode() == USART_UART_TX)
- return;
-
- call Usart.disableSPI();
- call Usart.disableI2C();
- call Usart.disableUART();
+ async command void Usart.setModeUartTx(msp430_uart_config_t* config) {
atomic {
call UTXD.selectModuleFunc();
call URXD.selectIOFunc();
+ call Usart.resetUsart(TRUE);
+ configUart(config);
+ call Usart.enableUartTx();
+ call Usart.resetUsart(FALSE);
+ call Usart.clrIntr();
+ call Usart.disableIntr();
}
- setUARTModeCommon();
+
return;
}
- async command void Usart.setModeUART_RX() {
- // check if we are already in UART mode
- if (call Usart.getMode() == USART_UART_RX)
- return;
-
- call Usart.disableSPI();
- call Usart.disableI2C();
- call Usart.disableUART();
+ async command void Usart.setModeUartRx(msp430_uart_config_t* config) {
atomic {
call UTXD.selectIOFunc();
call URXD.selectModuleFunc();
+ call Usart.resetUsart(TRUE);
+ configUart(config);
+ call Usart.enableUartRx();
+ call Usart.resetUsart(FALSE);
+ call Usart.clrIntr();
+ call Usart.disableIntr();
}
- setUARTModeCommon();
+
return;
}
- async command void Usart.setModeUART() {
- // check if we are already in UART mode
- if (call Usart.getMode() == USART_UART)
- return;
-
- call Usart.disableSPI();
- call Usart.disableI2C();
- call Usart.disableUART();
+ async command void Usart.setModeUart(msp430_uart_config_t* config) {
atomic {
call UTXD.selectModuleFunc();
call URXD.selectModuleFunc();
+ call Usart.resetUsart(TRUE);
+ configUart(config);
+ call Usart.enableUart();
+ call Usart.resetUsart(FALSE);
+ call Usart.clrIntr();
+ call Usart.disableIntr();
}
- setUARTModeCommon();
+
return;
}
- // i2c enable bit is not set by default
- async command void Usart.setModeI2C() {
- // check if we are already in I2C mode
- if (call Usart.getMode() == USART_I2C)
- return;
-
- call Usart.disableUART();
- call Usart.disableSPI();
-
- atomic {
- call SIMO.makeInput();
- call UCLK.makeInput();
- call SIMO.selectModuleFunc();
- call UCLK.selectModuleFunc();
-
- IE1 &= ~(UTXIE0 | URXIE0); // interrupt disable
-
- U0CTL = SWRST;
- U0CTL |= SYNC | I2C; // 7-bit addr, I2C-mode, USART as master
- U0CTL &= ~I2CEN;
-
- U0CTL |= MST;
-
- I2CTCTL = I2CSSEL_2; // use 1MHz SMCLK as the I2C reference
-
- I2CPSC = 0x00; // I2C CLK runs at 1MHz/10 = 100kHz
- I2CSCLH = 0x03;
- I2CSCLL = 0x03;
-
- I2CIE = 0; // clear all I2C interrupt enables
- I2CIFG = 0; // clear all I2C interrupt flags
- }
- return;
- }
-
- async command void Usart.setClockSource(uint8_t source) {
- atomic {
- l_ssel = source | 0x80;
- U0TCTL &= ~SSEL_3;
- U0TCTL |= (l_ssel & 0x7F);
- }
- }
-
- async command void Usart.setClockRate(uint16_t baudrate, uint8_t mctl) {
- atomic {
- l_br = baudrate;
- l_mctl = mctl;
- U0BR0 = baudrate & 0x0FF;
- U0BR1 = (baudrate >> 8) & 0x0FF;
- U0MCTL = mctl;
- }
- }
-
async command bool Usart.isTxIntrPending(){
if (IFG1 & UTXIFG0){
IFG1 &= ~UTXIFG0;
async command bool Usart.isRxIntrPending(){
if (IFG1 & URXIFG0){
-// IFG1 &= ~URXIFG0;
return TRUE;
}
return FALSE;
}
- async command error_t Usart.clrTxIntr(){
+ async command void Usart.clrTxIntr(){
IFG1 &= ~UTXIFG0;
- return SUCCESS;
}
- async command error_t Usart.clrRxIntr() {
+ async command void Usart.clrRxIntr() {
IFG1 &= ~URXIFG0;
- return SUCCESS;
}
- async command void Usart.disableRxIntr(){
+ async command void Usart.clrIntr() {
+ IFG1 &= ~(UTXIFG0 | URXIFG0);
+ }
+
+ async command void Usart.disableRxIntr() {
IE1 &= ~URXIE0;
}
- async command void Usart.disableTxIntr(){
+ async command void Usart.disableTxIntr() {
IE1 &= ~UTXIE0;
}
- async command void Usart.enableRxIntr(){
+ async command void Usart.disableIntr() {
+ IE1 &= ~(UTXIE0 | URXIE0);
+ }
+
+ async command void Usart.enableRxIntr() {
atomic {
IFG1 &= ~URXIFG0;
IE1 |= URXIE0;
}
}
- async command void Usart.enableTxIntr(){
+ async command void Usart.enableTxIntr() {
atomic {
IFG1 &= ~UTXIFG0;
IE1 |= UTXIE0;
}
}
- async command void Usart.tx(uint8_t data){
+ async command void Usart.enableIntr() {
+ atomic {
+ IFG1 &= ~(UTXIFG0 | URXIFG0);
+ IE1 |= (UTXIE0 | URXIE0);
+ }
+ }
+
+ async command void Usart.tx(uint8_t data) {
atomic U0TXBUF = data;
}
- async command uint8_t Usart.rx(){
+ async command uint8_t Usart.rx() {
uint8_t value;
atomic value = U0RXBUF;
return value;
}
+ default async event void I2CInterrupts.fired() {}
+ default async command bool HplI2C.isI2C() { return FALSE; }
+
}
-/*
+/**
+ * Copyright (c) 2005-2006 Arched Rock Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ * - Neither the name of the Arched Rock Corporation nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE
+ */
+
+/**
* "Copyright (c) 2000-2005 The Regents of the University of California.
* All rights reserved.
*
* PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
* CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
* UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
- *
*/
/**
+ * An HPL abstraction of USART1 on the MSP430.
+ *
+ * @author Jonathan Hui <jhui@archedrock.com>
* @author Joe Polastre
+ * @version $Revision$ $Date$
*/
-#include "msp430UsartResource.h"
+#include "msp430usart.h"
configuration HplMsp430Usart1C {
- provides interface Init;
+
+ provides interface AsyncStdControl;
provides interface HplMsp430Usart;
provides interface HplMsp430UsartInterrupts;
- provides interface Resource[ uint8_t id ];
- provides interface ResourceController;
- provides interface ArbiterInfo;
+
}
implementation {
components HplMsp430Usart1P as HplUsartP;
components HplMsp430GeneralIOC as GIO;
- components new FcfsArbiterC(MSP430_HPLUSART1_RESOURCE) as Arbiter;
+ AsyncStdControl = HplUsartP;
HplMsp430Usart = HplUsartP;
HplMsp430UsartInterrupts = HplUsartP;
- Init = Arbiter;
- Resource = Arbiter;
- ResourceController = Arbiter;
- ArbiterInfo = Arbiter;
-
HplUsartP.SIMO -> GIO.SIMO1;
HplUsartP.SOMI -> GIO.SOMI1;
HplUsartP.UCLK -> GIO.UCLK1;
-/*
- * Copyright (c) 2004-2005, Technische Universitat Berlin
+/**
+ * Copyright (c) 2005-2006 Arched Rock Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ * - Neither the name of the Arched Rock Corporation nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE
+ */
+
+/**
+ * Copyright (c) 2004-2005, Technische Universitaet Berlin
* All rights reserved.
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * - Neither the name of the Technische Universitat Berlin nor the names
+ * - Neither the name of the Technische Universitaet Berlin nor the names
* of its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
- * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * - Revision -------------------------------------------------------------
- * $Revision$
- * $Date$
- * ========================================================================
*/
+#include "msp430usart.h"
/**
- * Implementation of USART0 lowlevel functionality - stateless.
+ * Implementation of USART1 lowlevel functionality - stateless.
* Setting a mode will by default disable USART-Interrupts.
*
- * @author Jan Hauer (hauer@tkn.tu-berlin.de)
- * @author Joe Polastre
+ * @author: Jan Hauer <hauer@tkn.tu-berlin.de>
+ * @author: Jonathan Hui <jhui@archedrock.com>
+ * @author: Vlado Handziski <handzisk@tkn.tu-berlin.de>
+ * @author: Joe Polastre
+ * @version $Revision$ $Date$
*/
module HplMsp430Usart1P {
+ provides interface AsyncStdControl;
provides interface HplMsp430Usart as Usart;
- provides interface HplMsp430UsartInterrupts as UsartInterrupts;
+ provides interface HplMsp430UsartInterrupts as Interrupts;
uses interface HplMsp430GeneralIO as SIMO;
uses interface HplMsp430GeneralIO as SOMI;
uses interface HplMsp430GeneralIO as URXD;
uses interface HplMsp430GeneralIO as UTXD;
}
+
implementation
{
MSP430REG_NORACE(IE2);
MSP430REG_NORACE(ME2);
MSP430REG_NORACE(IFG2);
MSP430REG_NORACE(U1TCTL);
+ MSP430REG_NORACE(U1RCTL);
MSP430REG_NORACE(U1TXBUF);
-
- uint16_t l_br;
- uint8_t l_mctl;
- uint8_t l_ssel;
-
+
+
+
TOSH_SIGNAL(UART1RX_VECTOR) {
uint8_t temp = U1RXBUF;
- signal UsartInterrupts.rxDone(temp);
+ signal Interrupts.rxDone(temp);
}
TOSH_SIGNAL(UART1TX_VECTOR) {
- signal UsartInterrupts.txDone();
+ signal Interrupts.txDone();
}
- async command bool Usart.isSPI() {
- bool _ret = FALSE;
- atomic{
- if (ME2 & USPIE1)
- _ret = TRUE;
+ async command error_t AsyncStdControl.start() {
+ return SUCCESS;
+ }
+
+ async command error_t AsyncStdControl.stop() {
+ call Usart.disableSpi();
+ call Usart.disableUart();
+ return SUCCESS;
+ }
+
+
+ async command void Usart.setUctl(msp430_uctl_t control) {
+ U1CTL=uctl2int(control);
+ }
+
+ async command msp430_uctl_t Usart.getUctl() {
+ return int2uctl(U0CTL);
+ }
+
+ async command void Usart.setUtctl(msp430_utctl_t control) {
+ U1TCTL=utctl2int(control);
+ }
+
+ async command msp430_utctl_t Usart.getUtctl() {
+ return int2utctl(U1TCTL);
+ }
+
+ async command void Usart.setUrctl(msp430_urctl_t control) {
+ U1RCTL=urctl2int(control);
+ }
+
+ async command msp430_urctl_t Usart.getUrctl() {
+ return int2urctl(U1RCTL);
+ }
+
+ async command void Usart.setUbr(uint16_t control) {
+ atomic {
+ U1BR0 = control & 0x00FF;
+ U1BR1 = (control >> 8) & 0x00FF;
}
- return _ret;
}
-
- async command bool Usart.isUART() {
- bool _ret = FALSE;
+
+ async command uint16_t Usart.getUbr() {
+ return (U1BR1 << 8) + U1BR0;
+ }
+
+ async command void Usart.setUmctl(uint8_t control) {
+ U1MCTL=control;
+ }
+
+ async command uint8_t Usart.getUmctl() {
+ return U1MCTL;
+ }
+
+ async command void Usart.resetUsart(bool reset) {
+ if (reset)
+ SET_FLAG(U1CTL, SWRST);
+ else
+ CLR_FLAG(U1CTL, SWRST);
+ }
+
+ async command bool Usart.isSpi() {
atomic {
- if ((ME2 & UTXE1) && (ME2 & URXE1))
- _ret = TRUE;
+ return (U1CTL & SYNC) && (ME2 & USPIE1);
}
- return _ret;
}
-
- async command bool Usart.isUARTtx() {
- bool _ret = FALSE;
+
+ async command bool Usart.isUart() {
atomic {
- if (ME2 & UTXE1)
- _ret = TRUE;
+ return !(U1CTL & SYNC) && ((ME2 & UTXE1) && (ME2 & URXE1));
}
- return _ret;
}
-
- async command bool Usart.isUARTrx() {
- bool _ret = FALSE;
+
+ async command bool Usart.isUartTx() {
atomic {
- if (ME2 & URXE1)
- _ret = TRUE;
+ return !(U1CTL & SYNC) && (ME2 & UTXE1);
}
- return _ret;
}
-
- async command bool Usart.isI2C() {
- return FALSE;
+
+ async command bool Usart.isUartRx() {
+ atomic {
+ return !(U1CTL & SYNC) && (ME2 & URXE1);
+ }
}
-
+
async command msp430_usartmode_t Usart.getMode() {
- if (call Usart.isUART())
+ if (call Usart.isUart())
return USART_UART;
- else if (call Usart.isUARTrx())
+ else if (call Usart.isUartRx())
return USART_UART_RX;
- else if (call Usart.isUARTtx())
+ else if (call Usart.isUartTx())
return USART_UART_TX;
- else if (call Usart.isSPI())
+ else if (call Usart.isSpi())
return USART_SPI;
- else if (call Usart.isI2C())
- return USART_I2C;
else
return USART_NONE;
}
-
- /**
- * Sets the USART mode to one of the options from msp430_usartmode_t
- * defined in MSP430Usart.h
- */
- async command void Usart.setMode(msp430_usartmode_t _mode) {
- switch (_mode) {
- case USART_UART:
- call Usart.setModeUART();
- break;
- case USART_UART_RX:
- call Usart.setModeUART_RX();
- break;
- case USART_UART_TX:
- call Usart.setModeUART_TX();
- break;
- case USART_SPI:
- call Usart.setModeSPI();
- break;
- default:
- break;
+
+ async command void Usart.enableUart() {
+ atomic{
+ call UTXD.selectModuleFunc();
+ call URXD.selectModuleFunc();
}
- }
-
- async command void Usart.enableUART() {
-// TOSH_SEL_UTXD1_MODFUNC();
-// TOSH_SEL_URXD1_MODFUNC();
ME2 |= (UTXE1 | URXE1); // USART1 UART module enable
}
-
- async command void Usart.disableUART() {
- ME2 &= ~(UTXE1 | URXE1); // USART0 UART module enable
- call UTXD.selectIOFunc();
- call URXD.selectIOFunc();
+
+ async command void Usart.disableUart() {
+ ME2 &= ~(UTXE1 | URXE1); // USART1 UART module enable
+ atomic {
+ call UTXD.selectIOFunc();
+ call URXD.selectIOFunc();
+ }
+
}
-
- async command void Usart.enableUARTTx() {
- ME2 |= UTXE1; // USART0 UART Tx module enable
+
+ async command void Usart.enableUartTx() {
+ call UTXD.selectModuleFunc();
+ ME2 |= UTXE1; // USART1 UART Tx module enable
}
-
- async command void Usart.disableUARTTx() {
- ME2 &= ~UTXE1; // USART0 UART Tx module enable
+
+ async command void Usart.disableUartTx() {
+ ME2 &= ~UTXE1; // USART1 UART Tx module enable
call UTXD.selectIOFunc();
+
}
-
- async command void Usart.enableUARTRx() {
- ME2 |= URXE1; // USART0 UART Rx module enable
+
+ async command void Usart.enableUartRx() {
+ call URXD.selectModuleFunc();
+ ME2 |= URXE1; // USART1 UART Rx module enable
}
-
- async command void Usart.disableUARTRx() {
- ME2 &= ~URXE1; // USART0 UART Rx module disable
+
+ async command void Usart.disableUartRx() {
+ ME2 &= ~URXE1; // USART1 UART Rx module disable
call URXD.selectIOFunc();
- }
- async command void Usart.enableSPI() {
- ME2 |= USPIE1; // USART0 SPI module enable
- }
-
- async command void Usart.disableSPI() {
- ME2 &= ~USPIE1; // USART0 SPI module disable
- call SIMO.selectIOFunc();
- call SOMI.selectIOFunc();
- call UCLK.selectIOFunc();
}
-
- async command void Usart.enableI2C() { }
-
- async command void Usart.disableI2C() { }
- async command void Usart.setModeSPI() {
- // check if we are already in SPI mode
- if (call Usart.getMode() == USART_SPI)
- return;
-
- call Usart.disableUART();
- call Usart.disableI2C();
-
+ async command void Usart.enableSpi() {
atomic {
call SIMO.selectModuleFunc();
call SOMI.selectModuleFunc();
call UCLK.selectModuleFunc();
-
- IE2 &= ~(UTXIE1 | URXIE1); // interrupt disable
-
- U1CTL = SWRST;
- U1CTL |= CHAR | SYNC | MM; // 8-bit char, SPI-mode, USART as master
- U1CTL &= ~(0x20);
-
- U1TCTL = STC ; // 3-pin
- U1TCTL |= CKPH; // half-cycle delayed UCLK
-
- if (l_ssel & 0x80) {
- U1TCTL &= ~(SSEL_0 | SSEL_1 | SSEL_2 | SSEL_3);
- U1TCTL |= (l_ssel & 0x7F);
- }
- else {
- U1TCTL &= ~(SSEL_0 | SSEL_1 | SSEL_2 | SSEL_3);
- U1TCTL |= SSEL_SMCLK; // use SMCLK, assuming 1MHz
- }
-
- if (l_br != 0) {
- U1BR0 = l_br & 0x0FF;
- U1BR1 = (l_br >> 8) & 0x0FF;
- }
- else {
- U1BR0 = 0x02; // as fast as possible
- U1BR1 = 0x00;
- }
- U1MCTL = 0;
-
- ME2 &= ~(UTXE1 | URXE1); //USART UART module disable
- ME2 |= USPIE1; // USART SPI module enable
- U1CTL &= ~SWRST;
-
- IFG2 &= ~(UTXIFG1 | URXIFG1);
- IE2 &= ~(UTXIE1 | URXIE1); // interrupt disabled
}
- return;
+ ME2 |= USPIE1; // USART1 SPI module enable
}
-
- void setUARTModeCommon() {
- atomic {
- U1CTL = SWRST;
- U1CTL |= CHAR; // 8-bit char, UART-mode
-
- U1RCTL &= ~URXEIE; // even erroneous characters trigger interrupts
-
-
- U1CTL = SWRST;
- U1CTL |= CHAR; // 8-bit char, UART-mode
-
- if (l_ssel & 0x80) {
- U1TCTL &= ~(SSEL_0 | SSEL_1 | SSEL_2 | SSEL_3);
- U1TCTL |= (l_ssel & 0x7F);
- }
- else {
- U1TCTL &= ~(SSEL_0 | SSEL_1 | SSEL_2 | SSEL_3);
- U1TCTL |= SSEL_ACLK; // use ACLK, assuming 32khz
- }
-
- if ((l_mctl != 0) || (l_br != 0)) {
- U1BR0 = l_br & 0x0FF;
- U1BR1 = (l_br >> 8) & 0x0FF;
- U1MCTL = l_mctl;
- }
- else {
- U1BR0 = 0x03; // 9600 baud
- U1BR1 = 0x00;
- U1MCTL = 0x4A;
- }
-
- ME2 &= ~USPIE1; // USART0 SPI module disable
- ME2 |= (UTXE1 | URXE1); //USART0 UART module enable;
-
- U1CTL &= ~SWRST;
- IFG2 &= ~(UTXIFG1 | URXIFG1);
- IE2 &= ~(UTXIE1 | URXIE1); // interrupt disabled
+ async command void Usart.disableSpi() {
+ ME2 &= ~USPIE1; // USART1 SPI module disable
+ atomic {
+ call SIMO.selectIOFunc();
+ call SOMI.selectIOFunc();
+ call UCLK.selectIOFunc();
}
- return;
}
-
- async command void Usart.setModeUART_TX() {
- // check if we are already in UART mode
- if (call Usart.getMode() == USART_UART_TX)
- return;
- call Usart.disableSPI();
- call Usart.disableI2C();
- call Usart.disableUART();
+ void configSpi(msp430_spi_config_t* config) {
+ msp430_uctl_t uctl = call Usart.getUctl();
+ msp430_utctl_t utctl = call Usart.getUtctl();
- atomic {
- call UTXD.selectModuleFunc();
- call URXD.selectIOFunc();
- }
- setUARTModeCommon();
- return;
- }
-
- async command void Usart.setModeUART_RX() {
- // check if we are already in UART mode
- if (call Usart.getMode() == USART_UART_RX)
- return;
+ uctl.clen = config->clen;
+ uctl.listen = config->listen;
+ uctl.mm = config->mm;
+ uctl.sync = 1;
- call Usart.disableSPI();
- call Usart.disableI2C();
- call Usart.disableUART();
+ utctl.ckph = config->ckph;
+ utctl.ckpl = config->ckpl;
+ utctl.ssel = config->ssel;
+ utctl.stc = config->stc;
- atomic {
- call UTXD.selectIOFunc();
- call URXD.selectModuleFunc();
- }
- setUARTModeCommon();
- return;
+ call Usart.setUctl(uctl);
+ call Usart.setUtctl(utctl);
+ call Usart.setUbr(config->ubr);
+ call Usart.setUmctl(0x00);
}
- async command void Usart.setModeUART() {
- // check if we are already in UART mode
- if (call Usart.getMode() == USART_UART)
- return;
-
- call Usart.disableSPI();
- call Usart.disableI2C();
- call Usart.disableUART();
+ async command void Usart.setModeSpi(msp430_spi_config_t* config) {
+ call Usart.disableUart();
atomic {
- call UTXD.selectModuleFunc();
- call URXD.selectModuleFunc();
+ call Usart.resetUsart(TRUE);
+ configSpi(config);
+ call Usart.enableSpi();
+ call Usart.resetUsart(FALSE);
+ call Usart.clrIntr();
+ call Usart.disableIntr();
}
- setUARTModeCommon();
return;
}
- // i2c enable bit is not set by default
- async command void Usart.setModeI2C() {
- // check if we are already in I2C mode
- if (call Usart.getMode() == USART_I2C)
- return;
- call Usart.disableUART();
- call Usart.disableSPI();
+ void configUart(msp430_uart_config_t* config) {
+ msp430_uctl_t uctl = call Usart.getUctl();
+ msp430_utctl_t utctl = call Usart.getUtctl();
+ msp430_urctl_t urctl = call Usart.getUrctl();
- atomic {
- call SIMO.makeInput();
- call UCLK.makeInput();
- call SIMO.selectModuleFunc();
- call UCLK.selectModuleFunc();
+ uctl.pena = config->pena;
+ uctl.pev = config->pev;
+ uctl.spb = config->spb;
+ uctl.clen = config->clen;
+ uctl.listen = config->listen;
+ uctl.sync = 0;
+ uctl.mm = config->mm;
+
+ utctl.ckpl = config->ckpl;
+ utctl.ssel = config->ssel;
+ utctl.urxse = config->urxse;
- IE2 &= ~(UTXIE1 | URXIE1); // interrupt disable
+ urctl.urxeie = config->urxeie;
+ urctl.urxwie = config->urxwie;
- U1CTL = SWRST;
- U1CTL |= SYNC | I2C; // 7-bit addr, I2C-mode, USART as master
- U1CTL &= ~I2CEN;
+ call Usart.setUctl(uctl);
+ call Usart.setUtctl(utctl);
+ call Usart.setUrctl(urctl);
+ call Usart.setUbr(config->ubr);
+ call Usart.setUmctl(config->umctl);
+ }
- U1CTL |= MST;
+ async command void Usart.setModeUartTx(msp430_uart_config_t* config) {
- I2CTCTL = I2CSSEL_2; // use 1MHz SMCLK as the I2C reference
+ call Usart.disableSpi();
+ call Usart.disableUart();
- I2CPSC = 0x00; // I2C CLK runs at 1MHz/10 = 100kHz
- I2CSCLH = 0x03;
- I2CSCLL = 0x03;
-
- I2CIE = 0; // clear all I2C interrupt enables
- I2CIFG = 0; // clear all I2C interrupt flags
+ atomic {
+ call UTXD.selectModuleFunc();
+ call URXD.selectIOFunc();
+ call Usart.resetUsart(TRUE);
+ configUart(config);
+ call Usart.enableUartTx();
+ call Usart.resetUsart(FALSE);
+ call Usart.clrIntr();
+ call Usart.disableIntr();
}
return;
}
-
- async command void Usart.setClockSource(uint8_t source) {
+
+ async command void Usart.setModeUartRx(msp430_uart_config_t* config) {
+
+ call Usart.disableSpi();
+ call Usart.disableUart();
+
atomic {
- l_ssel = source | 0x80;
- U1TCTL &= ~(SSEL_0 | SSEL_1 | SSEL_2 | SSEL_3);
- U1TCTL |= (l_ssel & 0x7F);
+ call UTXD.selectIOFunc();
+ call URXD.selectModuleFunc();
+ call Usart.resetUsart(TRUE);
+ configUart(config);
+ call Usart.enableUartRx();
+ call Usart.resetUsart(FALSE);
+ call Usart.clrIntr();
+ call Usart.disableIntr();
}
+ return;
}
-
- async command void Usart.setClockRate(uint16_t baudrate, uint8_t mctl) {
+
+ async command void Usart.setModeUart(msp430_uart_config_t* config) {
+
+ call Usart.disableSpi();
+ call Usart.disableUart();
+
atomic {
- l_br = baudrate;
- l_mctl = mctl;
- U1BR0 = baudrate & 0x0FF;
- U1BR1 = (baudrate >> 8) & 0x0FF;
- U1MCTL = mctl;
+ call UTXD.selectModuleFunc();
+ call URXD.selectModuleFunc();
+ call Usart.resetUsart(TRUE);
+ configUart(config);
+ call Usart.enableUart();
+ call Usart.resetUsart(FALSE);
+ call Usart.clrIntr();
+ call Usart.disableIntr();
}
+ return;
}
async command bool Usart.isTxIntrPending(){
}
return FALSE;
}
-
+
async command bool Usart.isRxIntrPending(){
if (IFG2 & URXIFG1){
- IFG2 &= ~URXIFG1;
return TRUE;
}
return FALSE;
}
-
- async command error_t Usart.clrTxIntr(){
- IFG1 &= ~UTXIFG0;
- return SUCCESS;
+
+ async command void Usart.clrTxIntr(){
+ IFG2 &= ~UTXIFG1;
}
- async command error_t Usart.clrRxIntr() {
- IFG1 &= ~URXIFG0;
- return SUCCESS;
+ async command void Usart.clrRxIntr() {
+ IFG2 &= ~URXIFG1;
+ }
+
+ async command void Usart.clrIntr() {
+ IFG2 &= ~(UTXIFG1 | URXIFG1);
}
-
- async command void Usart.disableRxIntr(){
- IE2 &= ~URXIE1;
+
+ async command void Usart.disableRxIntr() {
+ IE2 &= ~URXIE1;
+ }
+
+ async command void Usart.disableTxIntr() {
+ IE2 &= ~UTXIE1;
}
-
- async command void Usart.disableTxIntr(){
- IE2 &= ~UTXIE1;
+
+ async command void Usart.disableIntr() {
+ IE2 &= ~(UTXIE1 | URXIE1);
}
-
- async command void Usart.enableRxIntr(){
+
+ async command void Usart.enableRxIntr() {
atomic {
IFG2 &= ~URXIFG1;
- IE2 |= URXIE1;
+ IE2 |= URXIE1;
}
}
- async command void Usart.enableTxIntr(){
+ async command void Usart.enableTxIntr() {
atomic {
IFG2 &= ~UTXIFG1;
IE2 |= UTXIE1;
}
}
-
- async command void Usart.tx(uint8_t data){
+
+ async command void Usart.enableIntr() {
+ atomic {
+ IFG2 &= ~(UTXIFG1 | URXIFG1);
+ IE2 |= (UTXIE1 | URXIE1);
+ }
+ }
+
+ async command void Usart.tx(uint8_t data) {
atomic U1TXBUF = data;
}
-
- async command uint8_t Usart.rx(){
+
+ async command uint8_t Usart.rx() {
uint8_t value;
atomic value = U1RXBUF;
return value;
-/*
- * Copyright (c) 2005-2006 Arch Rock Corporation
+/**
+ * Copyright (c) 2005-2006 Arched Rock Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
- * - Neither the name of the Arch Rock Corporation nor the names of
+ * - Neither the name of the Arched Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* transfers in software. To utilize the DMA, use Msp430SpiDma0P in
* place of Msp430SpiNoDma0P.
*
- * @author Jonathan Hui <jhui@archrock.com>
+ * @author Jonathan Hui <jhui@archedrock.com>
* @version $Revision$ $Date$
*/
-#include "msp430UsartResource.h"
+#include "msp430usart.h"
generic configuration Msp430Spi0C() {
-
+
provides interface Resource;
provides interface SpiByte;
provides interface SpiPacket;
-
+
+ uses interface Msp430SpiConfigure;
}
implementation {
-
+
enum {
CLIENT_ID = unique( MSP430_SPIO_BUS ),
};
-
+
components Msp430SpiNoDma0P as SpiP;
Resource = SpiP.Resource[ CLIENT_ID ];
SpiByte = SpiP.SpiByte;
SpiPacket = SpiP.SpiPacket[ CLIENT_ID ];
+ Msp430SpiConfigure = SpiP.Msp430SpiConfigure[ CLIENT_ID ];
components new Msp430Usart0C() as UsartC;
+ SpiP.ResourceConfigure[ CLIENT_ID ] <- UsartC.ResourceConfigure;
SpiP.UsartResource[ CLIENT_ID ] -> UsartC.Resource;
SpiP.UsartInterrupts -> UsartC.HplMsp430UsartInterrupts;
-
+
}
-/*
- * Copyright (c) 2005-2006 Arch Rock Corporation
+/**
+ * Copyright (c) 2005-2006 Arched Rock Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
- * - Neither the name of the Arch Rock Corporation nor the names of
+ * - Neither the name of the Arched Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
*/
/**
- * @author Jonathan Hui <jhui@archrock.com>
+ * @author Jonathan Hui <jhui@archedrock.com>
* @version $Revision$ $Date$
*/
configuration Msp430SpiDma0P {
-
+
provides interface Resource[ uint8_t id ];
+ provides interface ResourceConfigure[ uint8_t id ];
provides interface SpiByte;
provides interface SpiPacket[ uint8_t id ];
-
+
uses interface Resource as UsartResource[ uint8_t id ];
+ uses interface Msp430SpiConfigure[ uint8_t id ];
uses interface HplMsp430UsartInterrupts as UsartInterrupts;
-
+
}
implementation {
-
+
components new Msp430SpiDmaP() as SpiP;
Resource = SpiP.Resource;
+ ResourceConfigure = SpiP.ResourceConfigure;
+ Msp430SpiConfigure = SpiP.Msp430SpiConfigure;
SpiByte = SpiP.SpiByte;
SpiPacket = SpiP.SpiPacket;
UsartResource = SpiP.UsartResource;
UsartInterrupts = SpiP.UsartInterrupts;
-
+
components HplMsp430Usart0C as UsartC;
SpiP.Usart -> UsartC;
-
+
components Msp430DmaC as DmaC;
SpiP.DmaChannel1 -> DmaC.Channel1;
SpiP.DmaChannel2 -> DmaC.Channel2;
-
+
components LedsC as Leds;
SpiP.Leds -> Leds;
-
+
}
-/*
- * Copyright (c) 2005-2006 Arch Rock Corporation
+/**
+ * Copyright (c) 2005-2006 Arched Rock Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
- * - Neither the name of the Arch Rock Corporation nor the names of
+ * - Neither the name of the Arched Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
*/
/**
- * @author Jonathan Hui <jhui@archrock.com>
+ * @author Jonathan Hui <jhui@archedrock.com>
* @version $Revision$ $Date$
*/
generic module Msp430SpiDmaP() {
provides interface Resource[ uint8_t id ];
+ provides interface ResourceConfigure[ uint8_t id ];
provides interface SpiByte;
provides interface SpiPacket[ uint8_t id ];
-
+
uses interface Msp430DmaChannel as DmaChannel1;
uses interface Msp430DmaChannel as DmaChannel2;
uses interface Resource as UsartResource[ uint8_t id ];
+ uses interface Msp430SpiConfigure[uint8_t id ];
uses interface HplMsp430Usart as Usart;
uses interface HplMsp430UsartInterrupts as UsartInterrupts;
uses interface Leds;
task void signalDone_task();
async command error_t Resource.immediateRequest[ uint8_t id ]() {
- error_t error = call UsartResource.immediateRequest[ id ]();
- if ( error == SUCCESS )
- call Usart.setModeSPI();
- return error;
+ return call UsartResource.immediateRequest[ id ]();
}
async command error_t Resource.request[ uint8_t id ]() {
return call UsartResource.request[ id ]();
}
- async command void Resource.release[ uint8_t id ]() {
- call UsartResource.release[ id ]();
+ async command error_t Resource.release[ uint8_t id ]() {
+ return call UsartResource.release[ id ]();
+ }
+
+ async command void ResourceConfigure.configure[ uint8_t id ]() {
+ call Usart.setModeSpi(call Msp430SpiConfigure.getConfig[id]());
+ }
+
+ async command void ResourceConfigure.unconfigure[ uint8_t id ]() {
}
event void UsartResource.granted[ uint8_t id ]() {
- call Usart.setModeSPI();
signal Resource.granted[ id ]();
}
return call UsartResource.isOwner[ id ]();
}
+ default async command error_t UsartResource.isOwner[ uint8_t id ]() { return FAIL; }
default async command error_t UsartResource.request[ uint8_t id ]() { return FAIL; }
default async command error_t UsartResource.immediateRequest[ uint8_t id ]() { return FAIL; }
- default async command void UsartResource.release[ uint8_t id ]() {}
+ default async command error_t UsartResource.release[ uint8_t id ]() { return FAIL; }
+ default async command msp430_spi_config_t* Msp430SpiConfigure.getConfig[uint8_t id]() {
+ return &msp430_spi_default_config;
+ }
+
default event void Resource.granted[ uint8_t id ]() {}
- async command void SpiByte.write( uint8_t tx, uint8_t* rx ) {
-
+ async command uint8_t SpiByte.write( uint8_t tx ) {
+
call Usart.tx( tx );
while( !call Usart.isRxIntrPending() );
- *rx = call Usart.rx();
+ return call Usart.rx();
}
-
- async command error_t SpiPacket.send[ uint8_t id ]( uint8_t* tx_buf,
- uint8_t* rx_buf,
+
+ async command error_t SpiPacket.send[ uint8_t id ]( uint8_t* tx_buf,
+ uint8_t* rx_buf,
uint16_t len ) {
uint16_t ctrl;
}
async event void DmaChannel2.transferDone( error_t error ) {}
-
+
void signalDone( error_t error ) {
signal SpiPacket.sendDone[ m_client ]( m_tx_buf, m_rx_buf, m_len, error );
}
-
+
async event void UsartInterrupts.txDone() {}
async event void UsartInterrupts.rxDone( uint8_t data ) {}
-/*
- * Copyright (c) 2005-2006 Arch Rock Corporation
+/**
+ * Copyright (c) 2005-2006 Arched Rock Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
- * - Neither the name of the Arch Rock Corporation nor the names of
+ * - Neither the name of the Arched Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
*/
/**
- * @author Jonathan Hui <jhui@archrock.com>
+ * @author Jonathan Hui <jhui@archedrock.com>
* @version $Revision$ $Date$
*/
configuration Msp430SpiNoDma0P {
-
+
provides interface Resource[ uint8_t id ];
+ provides interface ResourceConfigure[uint8_t id ];
provides interface SpiByte;
provides interface SpiPacket[ uint8_t id ];
-
+
uses interface Resource as UsartResource[ uint8_t id ];
+ uses interface Msp430SpiConfigure[ uint8_t id ];
uses interface HplMsp430UsartInterrupts as UsartInterrupts;
-
+
}
implementation {
-
+
components new Msp430SpiNoDmaP() as SpiP;
Resource = SpiP.Resource;
+ ResourceConfigure = SpiP.ResourceConfigure;
+ Msp430SpiConfigure = SpiP.Msp430SpiConfigure;
SpiByte = SpiP.SpiByte;
SpiPacket = SpiP.SpiPacket;
UsartResource = SpiP.UsartResource;
components HplMsp430Usart0C as UsartC;
SpiP.Usart -> UsartC;
-
+
components LedsC as Leds;
SpiP.Leds -> Leds;
-
+
}
-/*
- * Copyright (c) 2005-2006 Arch Rock Corporation
+/**
+ * Copyright (c) 2005-2006 Arched Rock Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
- * - Neither the name of the Arch Rock Corporation nor the names of
+ * - Neither the name of the Arched Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
*/
/**
- * @author Jonathan Hui <jhui@archrock.com>
+ * @author Jonathan Hui <jhui@archedrock.com>
* @version $Revision$ $Date$
*/
generic module Msp430SpiNoDmaP() {
-
+
provides interface Resource[ uint8_t id ];
+ provides interface ResourceConfigure[ uint8_t id ];
provides interface SpiByte;
provides interface SpiPacket[ uint8_t id ];
-
+
uses interface Resource as UsartResource[ uint8_t id ];
+ uses interface Msp430SpiConfigure[ uint8_t id ];
uses interface HplMsp430Usart as Usart;
uses interface HplMsp430UsartInterrupts as UsartInterrupts;
uses interface Leds;
}
implementation {
-
+
enum {
SPI_ATOMIC_SIZE = 2,
};
-
+
norace uint8_t* m_tx_buf;
norace uint8_t* m_rx_buf;
norace uint16_t m_len;
norace uint16_t m_pos;
norace uint8_t m_client;
-
+
void signalDone();
task void signalDone_task();
async command error_t Resource.immediateRequest[ uint8_t id ]() {
- error_t result = call UsartResource.immediateRequest[ id ]();
- if ( result == SUCCESS )
- call Usart.setModeSPI();
- return result;
+ return call UsartResource.immediateRequest[ id ]();
}
-
+
async command error_t Resource.request[ uint8_t id ]() {
return call UsartResource.request[ id ]();
}
-
+
async command uint8_t Resource.isOwner[ uint8_t id ]() {
return call UsartResource.isOwner[ id ]();
}
-
- async command void Resource.release[ uint8_t id ]() {
- call UsartResource.release[ id ]();
+
+ async command error_t Resource.release[ uint8_t id ]() {
+ return call UsartResource.release[ id ]();
+ }
+
+ async command void ResourceConfigure.configure[ uint8_t id ]() {
+ call Usart.setModeSpi(call Msp430SpiConfigure.getConfig[id]());
+ }
+
+ async command void ResourceConfigure.unconfigure[ uint8_t id ]() {
+ call Usart.disableSpi();
}
event void UsartResource.granted[ uint8_t id ]() {
- call Usart.setModeSPI();
signal Resource.granted[ id ]();
}
- async command void SpiByte.write( uint8_t tx, uint8_t* rx ) {
+ async command uint8_t SpiByte.write( uint8_t tx ) {
+ uint8_t byte;
call Usart.disableRxIntr();
call Usart.tx( tx );
while( !call Usart.isRxIntrPending() );
- *rx = call Usart.rx();
+ byte = call Usart.rx();
call Usart.enableRxIntr();
+ return byte;
}
+ default async command error_t UsartResource.isOwner[ uint8_t id ]() { return FAIL; }
default async command error_t UsartResource.request[ uint8_t id ]() { return FAIL; }
- default async command error_t UsartResource.immediateRequest[ uint8_t id ]() { return FAIL; }
- default async command void UsartResource.release[ uint8_t id ]() {}
+ default async command error_t UsartResource.immediateRequest[ uint8_t id ]() { return FAIL; }
+ default async command error_t UsartResource.release[ uint8_t id ]() { return FAIL; }
+ default async command msp430_spi_config_t* Msp430SpiConfigure.getConfig[uint8_t id]() {
+ return &msp430_spi_default_config;
+ }
+
default event void Resource.granted[ uint8_t id ]() {}
void continueOp() {
async command error_t SpiPacket.send[ uint8_t id ]( uint8_t* tx_buf,
uint8_t* rx_buf,
uint16_t len ) {
-
+
m_client = id;
m_tx_buf = tx_buf;
m_rx_buf = rx_buf;
}
async event void UsartInterrupts.rxDone( uint8_t data ) {
-
+
if ( m_rx_buf )
m_rx_buf[ m_pos-1 ] = data;
}
void signalDone() {
- signal SpiPacket.sendDone[ m_client ]( m_tx_buf, m_rx_buf, m_len,
+ signal SpiPacket.sendDone[ m_client ]( m_tx_buf, m_rx_buf, m_len,
SUCCESS );
}
-/*
- * "Copyright (c) 2000-2005 The Regents of the University of California.
+/**
+ * Copyright (c) 2005-2006 Arched Rock Corporation
* All rights reserved.
*
- * Permission to use, copy, modify, and distribute this software and
- * its documentation for any purpose, without fee, and without written
- * agreement is hereby granted, provided that the above copyright
- * notice, the following two paragraphs and the author appear in all
- * copies of this software.
- *
- * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY
- * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
- * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
- * DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ * - Neither the name of the Arched Rock Corporation nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
- * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
- * CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
- * UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE
*/
/**
- * @author Joe Polastre
+ * An implementation of the UART on USART1 for the MSP430.
+ * @author Vlado Handziski <handzisk@tkn.tu-berlin.de>
+ * @author Jonathan Hui <jhui@archedrock.com>
+ * @version $Revision$ $Date$
*/
-configuration Msp430Uart1C {
- provides interface Init;
- provides interface Resource[ uint8_t id ];
- provides interface ArbiterInfo;
- provides interface StdControl;
- provides interface SerialByteComm;
+#include "msp430usart.h"
+
+generic configuration Msp430Uart1C() {
+
+ provides interface Resource;
+ provides interface UartStream;
+ provides interface UartByte;
+ provides interface Msp430UartControl as UartControl;
+
+ uses interface Msp430UartConfigure;
}
+
implementation {
-#ifndef DEFAULT_BAUDRATE
-#define DEFAULT_BAUDRATE (115200ul)
-#endif
- components new Msp430UartP(DEFAULT_BAUDRATE) as UartP;
- Init = UartP;
- StdControl = UartP;
- SerialByteComm = UartP;
-
- components HplMsp430Usart1C as HplUsartC;
- Init = HplUsartC;
- Resource = HplUsartC;
- ArbiterInfo = HplUsartC;
- UartP.HplUsart -> HplUsartC;
- UartP.HplUsartInterrupts -> HplUsartC;
-}
+ enum {
+ CLIENT_ID = unique( MSP430_UART1_BUS ),
+ };
+
+ components Msp430Uart1P as UartP;
+ Resource = UartP.Resource[ CLIENT_ID ];
+ UartStream = UartP.UartStream;
+ UartByte = UartP.UartByte;
+ UartControl = UartP.UartControl[ CLIENT_ID ];
+ Msp430UartConfigure = UartP.Msp430UartConfigure[ CLIENT_ID ];
+
+ components new Msp430Usart1C() as UsartC;
+ UartP.ResourceConfigure[ CLIENT_ID ] <- UsartC.ResourceConfigure;
+ UartP.UsartResource[ CLIENT_ID ] -> UsartC.Resource;
+ UartP.UsartInterrupts -> UsartC.HplMsp430UsartInterrupts;
+
+}
-/*
- * Copyright (c) 2004, Technische Universitat Berlin
+/**
+ * Copyright (c) 2005-2006 Arch Rock Corporation
* All rights reserved.
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
* are met:
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * - Neither the name of the Technische Universitat Berlin nor the names
- * of its contributors may be used to endorse or promote products derived
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ * - Neither the name of the Arch Rock Corporation nor the names of
+ * its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
- * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
- * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * - Description ----------------------------------------------------------
- * Implementation of UART0 lowlevel functionality - stateless.
- * - Revision -------------------------------------------------------------
- * $Revision$
- * $Date$
- * @author Jan Hauer
- * @author Vlado Handziski
- * @author Joe Polastre
- * ========================================================================
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * ARCH ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE
+ */
+
+/**
+ * @author Jonathan Hui <jhui@archrock.com>
+ * @author Vlado Handziski <handzisk@tkn.tu-berlin.de>
+ * @version $Revision$ $Date$
*/
-#include "msp430baudrates.h"
+#include<Timer.h>
-generic module Msp430UartP(uint32_t default_baudrate) {
+generic module Msp430UartP() {
- provides interface Init;
- provides interface StdControl;
- provides interface SerialByteComm;
+ provides interface Resource[ uint8_t id ];
+ provides interface ResourceConfigure[ uint8_t id ];
+ provides interface Msp430UartControl as UartControl[ uint8_t id ];
+ provides interface UartStream;
+ provides interface UartByte;
- uses interface HplMsp430Usart as HplUsart;
- uses interface HplMsp430UsartInterrupts as HplUsartInterrupts;
+ uses interface Resource as UsartResource[ uint8_t id ];
+ uses interface Msp430UartConfigure[ uint8_t id ];
+ uses interface HplMsp430Usart as Usart;
+ uses interface HplMsp430UsartInterrupts as UsartInterrupts;
+ uses interface Counter<T32khz,uint16_t>;
+ uses interface Leds;
+
}
implementation {
+
+ norace uint8_t *m_tx_buf, *m_rx_buf;
+ norace uint16_t m_tx_len, m_rx_len;
+ norace uint16_t m_tx_pos, m_rx_pos;
+ norace uint8_t m_byte_time;
+
+ async command error_t Resource.immediateRequest[ uint8_t id ]() {
+ return call UsartResource.immediateRequest[ id ]();
+ }
- command error_t Init.init() {
- return SUCCESS;
+ async command error_t Resource.request[ uint8_t id ]() {
+ return call UsartResource.request[ id ]();
}
- command error_t StdControl.start() {
- call HplUsart.setModeUART();
- call HplUsart.setClockSource(SSEL_SMCLK);
- if (default_baudrate == 57600UL){
- call HplUsart.setClockRate(UBR_SMCLK_57600, UMCTL_SMCLK_57600);
- } else if (default_baudrate == 115200UL){
- call HplUsart.setClockRate(UBR_SMCLK_115200, UMCTL_SMCLK_115200);
- } else if (default_baudrate == 230400UL){
- call HplUsart.setClockRate(UBR_SMCLK_230400, UMCTL_SMCLK_230400);
- }
- call HplUsart.enableRxIntr();
- call HplUsart.enableTxIntr();
- return SUCCESS;
+ async command uint8_t Resource.isOwner[ uint8_t id ]() {
+ return call UsartResource.isOwner[ id ]();
}
- command error_t StdControl.stop() {
- call HplUsart.disableRxIntr();
- call HplUsart.disableTxIntr();
+ async command error_t Resource.release[ uint8_t id ]() {
+ if ( m_rx_buf || m_tx_buf )
+ return EBUSY;
+ return call UsartResource.release[ id ]();
+ }
- call HplUsart.disableUART();
- return SUCCESS;
+ async command void ResourceConfigure.configure[ uint8_t id ]() {
+ call UartControl.setModeDuplex[id]();
}
- async command error_t SerialByteComm.put( uint8_t data ) {
- call HplUsart.tx( data );
+ async command void ResourceConfigure.unconfigure[ uint8_t id ]() {
+ call Usart.disableIntr();
+ call Usart.disableUart();
+ }
+
+ event void UsartResource.granted[ uint8_t id ]() {
+ signal Resource.granted[ id ]();
+ }
+
+ async command void UartControl.setModeRx[ uint8_t id ]() {
+ msp430_uart_config_t* config = call Msp430UartConfigure.getConfig[id]();
+ m_byte_time = config->ubr / 2;
+ call Usart.setModeUartRx(config);
+ call Usart.clrIntr();
+ call Usart.enableRxIntr();
+ }
+
+ async command void UartControl.setModeTx[ uint8_t id ]() {
+ call Usart.setModeUartTx(call Msp430UartConfigure.getConfig[id]());
+ call Usart.clrIntr();
+ call Usart.enableTxIntr();
+ }
+
+ async command void UartControl.setModeDuplex[ uint8_t id ]() {
+ msp430_uart_config_t* config = call Msp430UartConfigure.getConfig[id]();
+ m_byte_time = config->ubr / 2;
+ call Usart.setModeUart(config);
+ call Usart.clrIntr();
+ call Usart.enableIntr();
+ }
+
+ async command error_t UartStream.enableReceiveInterrupt() {
+ call Usart.enableRxIntr();
+ return SUCCESS;
+ }
+
+ async command error_t UartStream.disableReceiveInterrupt() {
+ call Usart.disableRxIntr();
return SUCCESS;
}
- async event void HplUsartInterrupts.txDone() {
- signal SerialByteComm.putDone();
+ async command error_t UartStream.receive( uint8_t* buf, uint16_t len ) {
+ if ( len == 0 )
+ return FAIL;
+ atomic {
+ if ( m_rx_buf )
+ return EBUSY;
+ m_rx_buf = buf;
+ m_rx_len = len;
+ m_rx_pos = 0;
+ }
+ return SUCCESS;
+ }
+
+ async event void UsartInterrupts.rxDone( uint8_t data ) {
+ if ( m_rx_buf ) {
+ m_rx_buf[ m_rx_pos++ ] = data;
+ if ( m_rx_pos >= m_rx_len ) {
+ uint8_t* buf = m_rx_buf;
+ m_rx_buf = NULL;
+ signal UartStream.receiveDone( buf, m_rx_len, SUCCESS );
+ }
+ }
+ else {
+ signal UartStream.receivedByte( data );
+ }
+ }
+
+ async command error_t UartStream.send( uint8_t* buf, uint16_t len ) {
+ if ( len == 0 )
+ return FAIL;
+ else if ( m_tx_buf )
+ return EBUSY;
+ m_tx_buf = buf;
+ m_tx_len = len;
+ m_tx_pos = 0;
+ call Usart.tx( buf[ m_tx_pos++ ] );
+ return SUCCESS;
+ }
+
+ async event void UsartInterrupts.txDone() {
+ if ( m_tx_pos < m_tx_len ) {
+ call Usart.tx( m_tx_buf[ m_tx_pos++ ] );
+ }
+ else {
+ uint8_t* buf = m_tx_buf;
+ m_tx_buf = NULL;
+ signal UartStream.sendDone( buf, m_tx_len, SUCCESS );
+ }
+ }
+
+ async command error_t UartByte.send( uint8_t data ) {
+ call Usart.tx( data );
+ while( !call Usart.isTxIntrPending() );
+ return SUCCESS;
}
+
+ async command error_t UartByte.receive( uint8_t* byte, uint8_t timeout ) {
+
+ uint16_t timeout_micro = m_byte_time * timeout + 1;
+ uint16_t start;
+
+ start = call Counter.get();
+ while( !call Usart.isRxIntrPending() ) {
+ if ( ( call Counter.get() - start ) >= timeout_micro )
+ return FAIL;
+ }
+ *byte = call Usart.rx();
+
+ return SUCCESS;
- async event void HplUsartInterrupts.rxDone( uint8_t data ) {
- signal SerialByteComm.get( data );
}
+
+ async event void Counter.overflow() {}
+
+ default async command error_t UsartResource.isOwner[ uint8_t id ]() { return FAIL; }
+ default async command error_t UsartResource.request[ uint8_t id ]() { return FAIL; }
+ default async command error_t UsartResource.immediateRequest[ uint8_t id ]() { return FAIL; }
+ default async command error_t UsartResource.release[ uint8_t id ]() { return FAIL; }
+ default async command msp430_uart_config_t* Msp430UartConfigure.getConfig[uint8_t id]() {
+ return &msp430_uart_default_config;
+ }
+
+ default event void Resource.granted[ uint8_t id ]() {}
}
-/*
- * Copyright (c) 2005-2006 Arch Rock Corporation
+/**
+ * Copyright (c) 2005-2006 Arched Rock Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
- * - Neither the name of the Arch Rock Corporation nor the names of
+ * - Neither the name of the Arched Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
/**
* Provides an interface for USART0 on the MSP430.
*
- * @author Jonathan Hui <jhui@archrock.com>
+ * @author Jonathan Hui <jhui@archedrock.com>
* @version $Revision$ $Date$
*/
generic configuration Msp430Usart0C() {
-
+
provides interface Resource;
provides interface ArbiterInfo;
provides interface HplMsp430Usart;
provides interface HplMsp430UsartInterrupts;
+ provides interface HplMsp430I2CInterrupts;
+#ifdef __msp430_have_usart0_with_i2c
+ provides interface HplMsp430I2C;
+#endif
+
+ uses interface ResourceConfigure;
}
implementation {
-
+
enum {
CLIENT_ID = unique( MSP430_HPLUSART0_RESOURCE ),
};
-
+
components Msp430UsartShare0P as UsartShareP;
-
+
Resource = UsartShareP.Resource[ CLIENT_ID ];
+ ResourceConfigure = UsartShareP.ResourceConfigure[ CLIENT_ID ];
ArbiterInfo = UsartShareP.ArbiterInfo;
HplMsp430UsartInterrupts = UsartShareP.Interrupts[ CLIENT_ID ];
-
- components HplMsp430Usart0C as UsartC;
- HplMsp430Usart = UsartC;
+ HplMsp430I2CInterrupts = UsartShareP.I2CInterrupts[ CLIENT_ID ];
+
+ components HplMsp430Usart0C as HplUsartC;
+ HplMsp430Usart = HplUsartC;
+
+#ifdef __msp430_have_usart0_with_i2c
+ components HplMsp430I2C0C as HplI2CC;
+ HplMsp430I2C = HplI2CC;
+#endif
}
-/*
- * Copyright (c) 2005-2006 Arch Rock Corporation
+/**
+ * Copyright (c) 2005-2006 Arched Rock Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
- * - Neither the name of the Arch Rock Corporation nor the names of
+ * - Neither the name of the Arched Rock Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
*/
/**
- * @author Jonathan Hui <jhui@archrock.com>
+ * @author Jonathan Hui <jhui@archedrock.com>
* @version $Revision$ $Date$
*/
configuration Msp430UsartShare0P {
-
+
provides interface HplMsp430UsartInterrupts as Interrupts[ uint8_t id ];
+ provides interface HplMsp430I2CInterrupts as I2CInterrupts[ uint8_t id ];
provides interface Resource[ uint8_t id ];
provides interface ArbiterInfo;
-
+
+ uses interface ResourceConfigure[ uint8_t id ];
}
implementation {
-
+
components new Msp430UsartShareP() as UsartShareP;
Interrupts = UsartShareP;
- UsartShareP.RawInterrupts -> UsartC;
+ I2CInterrupts = UsartShareP;
components new FcfsArbiterC( MSP430_HPLUSART0_RESOURCE ) as ArbiterC;
Resource = ArbiterC;
+ ResourceConfigure = ArbiterC;
ArbiterInfo = ArbiterC;
UsartShareP.ArbiterInfo -> ArbiterC;
-
- components new AsyncStdControlPowerManagerC() as PowerManagerC;
- PowerManagerC.ArbiterInit -> ArbiterC;
- PowerManagerC.ResourceController -> ArbiterC;
-
- components HplMsp430Usart0C as UsartC;
- PowerManagerC.AsyncStdControl -> UsartC;
-
- components MainC;
- MainC.SoftwareInit -> ArbiterC;
- MainC.SoftwareInit -> PowerManagerC;
+
+ components HplMsp430Usart0C as HplUsartC;
+ UsartShareP.RawInterrupts -> HplUsartC;
+ UsartShareP.RawI2CInterrupts -> HplUsartC;
}
generic module Msp430UsartShareP() {
provides interface HplMsp430UsartInterrupts as Interrupts[ uint8_t id ];
+ provides interface HplMsp430I2CInterrupts as I2CInterrupts[ uint8_t id ];
uses interface HplMsp430UsartInterrupts as RawInterrupts;
+ uses interface HplMsp430I2CInterrupts as RawI2CInterrupts;
uses interface ArbiterInfo;
}
if ( call ArbiterInfo.inUse() )
signal Interrupts.rxDone[ call ArbiterInfo.userId() ]( data );
}
-
+
+ async event void RawI2CInterrupts.fired() {
+ if ( call ArbiterInfo.inUse() )
+ signal I2CInterrupts.fired[ call ArbiterInfo.userId() ]();
+ }
+
default async event void Interrupts.txDone[ uint8_t id ]() {}
default async event void Interrupts.rxDone[ uint8_t id ]( uint8_t data ) {}
-
+ default async event void I2CInterrupts.fired[ uint8_t id ]() {}
+
}
-// $Id$
/*
- * "Copyright (c) 2000-2005 The Regents of the University of California.
+ * Copyright (c) 2004-2006, Technische Universitaet Berlin
* All rights reserved.
*
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose, without fee, and without written agreement is
- * hereby granted, provided that the above copyright notice, the following
- * two paragraphs and the author appear in all copies of this software.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * - Neither the name of the Technische Universitaet Berlin nor the names
+ * of its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
- * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
- * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
/**
- * @author Joe Polastre
- * Revision: $Revision$
+ * @author Vlado Handziski <handzisk@tkn.tu-berlin.de>
+ * $Revision$ $Date$
*/
-#ifndef MSP430USART_H
-#define MSP430USART_H
+#ifndef _H_Msp430Usart_h
+#define _H_Msp430Usart_h
+
+#define MSP430_HPLUSART0_RESOURCE "Msp430Usart0.Resource"
+#define MSP430_SPIO_BUS "Msp430Spi0.Resource"
+#define MSP430_UARTO_BUS "Msp430Uart0.Resource"
+#define MSP430_I2CO_BUS "Msp430I2C0.Resource"
+
+#define MSP430_HPLUSART1_RESOURCE "Msp430Usart1.Resource"
+#define MSP430_SPI1_BUS "Msp430Spi1.Resource"
+#define MSP430_UART1_BUS "Msp430Uart1.Resource"
typedef enum
{
USART_I2C = 5
} msp430_usartmode_t;
-#endif
+typedef struct {
+ unsigned int swrst: 1; //Software reset (0=operational; 1=reset)
+ unsigned int mm: 1; //Multiprocessor mode (0=idle-line protocol; 1=address-bit protocol)
+ unsigned int sync: 1; //Synchronous mode (0=UART; 1=SPI/I2C)
+ unsigned int listen: 1; //Listen enable (0=disabled; 1=enabled, feed tx back to receiver)
+ unsigned int clen: 1; //Character length (0=7-bit data; 1=8-bit data)
+ unsigned int spb: 1; //Stop bits (0=one stop bit; 1=two stop bits)
+ unsigned int pev: 1; //Parity select (0=odd; 1=even)
+ unsigned int pena: 1; //Parity enable (0=disabled; 1=enabled)
+} __attribute__ ((packed)) msp430_uctl_t ;
+
+typedef struct {
+ unsigned int txept:1; //Transmitter empty (0=busy; 1=TX buffer empty or SWRST=1)
+ unsigned int stc:1; //Slave transmit (0=4-pin SPI && STE enabled; 1=3-pin SPI && STE disabled)
+ unsigned int txwake: 1; //Transmiter wake (0=next char is data; 1=next char is address)
+ unsigned int urxse: 1; //Receive start-edge detection (0=disabled; 1=enabled)
+ unsigned int ssel: 2; //Clock source (00=UCLKI; 01=ACLK; 10=SMCLK; 11=SMCLK)
+ unsigned int ckpl: 1; //Clock polarity (0=normal; 1=inverted)
+ unsigned int ckph:1; //Clock phase (0=normal; 1=half-cycle delayed)
+} __attribute__ ((packed)) msp430_utctl_t;
+
+typedef struct {
+ unsigned int rxerr: 1; //Receive error (0=no errors; 1=error detected)
+ unsigned int rxwake: 1; //Receive wake-up (0=received data; 1=received an address)
+ unsigned int urxwie: 1; //Wake-up interrupt-enable (0=all characters set URXIFGx; 1=only address sets URXIFGx)
+ unsigned int urxeie: 1; //Erroneous-character receive (0=rejected; 1=recieved and URXIFGx set)
+ unsigned int brk:1; //Break detect (0=no break; 1=break occured)
+ unsigned int oe:1; //Overrun error (0=no error; 1=overrun error)
+ unsigned int pe:1; //Parity error (0=no error; 1=parity error)
+ unsigned int fe:1; //Framing error (0=no error; 1=low stop bit)
+} __attribute__ ((packed)) msp430_urctl_t;
+
+DEFINE_UNION_CAST(uctl2int,uint8_t,msp430_uctl_t)
+DEFINE_UNION_CAST(int2uctl,msp430_uctl_t,uint8_t)
+
+DEFINE_UNION_CAST(utctl2int,uint8_t,msp430_utctl_t)
+DEFINE_UNION_CAST(int2utctl,msp430_utctl_t,uint8_t)
+
+DEFINE_UNION_CAST(urctl2int,uint8_t,msp430_urctl_t)
+DEFINE_UNION_CAST(int2urctl,msp430_urctl_t,uint8_t)
+
+typedef struct {
+ unsigned int ubr: 16; //Clock division factor (>=0x0002)
+ unsigned int ssel: 2; //Clock source (00=external UCLK [slave]; 01=ACLK [master]; 10=SMCLK [master]; 11=SMCLK [master])
+ unsigned int clen: 1; //Character length (0=7-bit data; 1=8-bit data)
+ unsigned int listen: 1; //Listen enable (0=disabled; 1=enabled, feed tx back to receiver)
+ unsigned int mm: 1; //Master mode (0=slave; 1=master)
+ unsigned int ckph: 1; //Clock phase (0=normal; 1=half-cycle delayed)
+ unsigned int ckpl: 1; //Clock polarity (0=inactive is low && data at rising edge; 1=inverted)
+ unsigned int stc: 1; //Slave transmit (0=4-pin SPI && STE enabled; 1=3-pin SPI && STE disabled)
+ unsigned int :0;
+} msp430_spi_config_t;
+
+msp430_spi_config_t msp430_spi_default_config = {ubr: 0x0002, ssel: 0x02, clen: 1, listen: 0, mm: 1, ckph: 1, ckpl: 0, stc:1};
+
+typedef struct {
+ unsigned int ubr:16; //Baud rate (use enum msp430_uart_rate_t for predefined rates)
+ unsigned int umctl: 8; //Modulation (use enum msp430_uart_rate_t for predefined rates)
+ unsigned int ssel: 2; //Clock source (00=UCLKI; 01=ACLK; 10=SMCLK; 11=SMCLK)
+ unsigned int pena: 1; //Parity enable (0=disabled; 1=enabled)
+ unsigned int pev: 1; //Parity select (0=odd; 1=even)
+ unsigned int spb: 1; //Stop bits (0=one stop bit; 1=two stop bits)
+ unsigned int clen: 1; //Character length (0=7-bit data; 1=8-bit data)
+ unsigned int listen: 1; //Listen enable (0=disabled; 1=enabled, feed tx back to receiver)
+ unsigned int mm: 1; //Multiprocessor mode (0=idle-line protocol; 1=address-bit protocol)
+ unsigned int :0;
+ unsigned int ckpl: 1; //Clock polarity (0=normal; 1=inverted)
+ unsigned int urxse: 1; //Receive start-edge detection (0=disabled; 1=enabled)
+ unsigned int urxeie: 1; //Erroneous-character receive (0=rejected; 1=recieved and URXIFGx set)
+ unsigned int urxwie: 1; //Wake-up interrupt-enable (0=all characters set URXIFGx; 1=only address sets URXIFGx)
+} msp430_uart_config_t;
+
+typedef enum {
+ /**
+ The calculations were performed using the msp-uart.pl script:
+ # msp-uart.pl -- calculates the uart registers for MSP430
+ #
+ # Copyright (C) 2002 - Pedro Zorzenon Neto - pzn dot debian dot org
+ **/
+
+ //32KHZ = 32,768 Hz, 1MHZ = 1,048,576 Hz
+ UBR_32KHZ_1200=0x001B, UMCTL_32KHZ_1200=0x94,
+ UBR_32KHZ_1800=0x0012, UMCTL_32KHZ_1800=0x84,
+ UBR_32KHZ_2400=0x000D, UMCTL_32KHZ_2400=0x6D,
+ UBR_32KHZ_4800=0x0006, UMCTL_32KHZ_4800=0x77,
+ UBR_32KHZ_9600=0x0003, UMCTL_32KHZ_9600=0x29, // (Warning: triggers MSP430 errata US14)
+
+ UBR_1MHZ_1200=0x0369, UMCTL_1MHZ_1200=0x7B,
+ UBR_1MHZ_1800=0x0246, UMCTL_1MHZ_1800=0x55,
+ UBR_1MHZ_2400=0x01B4, UMCTL_1MHZ_2400=0xDF,
+ UBR_1MHZ_4800=0x00DA, UMCTL_1MHZ_4800=0xAA,
+ UBR_1MHZ_9600=0x006D, UMCTL_1MHZ_9600=0x44,
+ UBR_1MHZ_19200=0x0036, UMCTL_1MHZ_19200=0xB5,
+ UBR_1MHZ_38400=0x001B, UMCTL_1MHZ_38400=0x94,
+ UBR_1MHZ_57600=0x0012, UMCTL_1MHZ_57600=0x84,
+ UBR_1MHZ_76800=0x000D, UMCTL_1MHZ_76800=0x6D,
+ UBR_1MHZ_115200=0x0009, UMCTL_1MHZ_115200=0x10,
+ UBR_1MHZ_230400=0x0004, UMCTL_1MHZ_230400=0x55,
+} msp430_uart_rate_t;
+
+msp430_uart_config_t msp430_uart_default_config = {ubr: UBR_1MHZ_57600, umctl: UMCTL_1MHZ_57600, ssel: 0x02, pena: 0, pev: 0, spb: 0, clen: 1, listen: 0, mm: 0, ckpl: 0, urxse: 0, urxeie: 1, urxwie: 0};
+
+typedef struct {
+ unsigned int rxdmaen: 1; // Receive DMA enable. 0 = disabled.
+ unsigned int txdmaen: 1; // Transmit DMA enable. 0 = disabled.
+ unsigned int xa: 1; // Extended addressing. 0 = 7-bit addressing.
+ unsigned int listen: 1; // Listen. 0 = disabled.
+ unsigned int i2cword : 1; // Word mode. 0 = byte mode.
+ unsigned int i2crm : 1; // Repeat mode. 0 = I2CNDAT.
+ unsigned int i2cssel : 2; // Clock source select. 0=None, 1=ACLK, 2=SMCLK
+ unsigned int i2cpsc : 8; // Clock prescaler.
+ unsigned int i2csclh : 8; // Shift clock high register.
+ unsigned int i2cscll : 8; // Shift clock low register.
+ unsigned int i2coa : 10; // Own address register.
+} msp430_i2c_config_t;
+
+msp430_i2c_config_t msp430_i2c_default_config = {
+ rxdmaen : 0,
+ txdmaen : 0,
+ xa : 0,
+ listen : 0,
+ i2cword : 0,
+ i2crm : 1,
+ i2cssel : 2,
+ i2cpsc : 0,
+ i2csclh : 3,
+ i2cscll : 3,
+ i2coa : 0,
+};
+
+
+#endif//_H_Msp430Usart_h
components PlatformP;\r
\r
HplPXA27xDMACntl = HplPXA27xDMAM;\r
- HplPXA27xDMAChnl = HplPXA27xDMAM;\r
+\r
+ HplPXA27xDMAChnl[0] = HplPXA27xDMAM.HplPXA27xDMAChnl[0];\r
+ HplPXA27xDMAChnl[1] = HplPXA27xDMAM.HplPXA27xDMAChnl[1];\r
+ HplPXA27xDMAChnl[2] = HplPXA27xDMAM.HplPXA27xDMAChnl[2];\r
+ HplPXA27xDMAChnl[3] = HplPXA27xDMAM.HplPXA27xDMAChnl[3];\r
+ HplPXA27xDMAChnl[4] = HplPXA27xDMAM.HplPXA27xDMAChnl[4];\r
+ HplPXA27xDMAChnl[5] = HplPXA27xDMAM.HplPXA27xDMAChnl[5];\r
+ HplPXA27xDMAChnl[6] = HplPXA27xDMAM.HplPXA27xDMAChnl[6];\r
+ HplPXA27xDMAChnl[7] = HplPXA27xDMAM.HplPXA27xDMAChnl[7];\r
+ HplPXA27xDMAChnl[8] = HplPXA27xDMAM.HplPXA27xDMAChnl[8];\r
+ HplPXA27xDMAChnl[9] = HplPXA27xDMAM.HplPXA27xDMAChnl[9];\r
+ HplPXA27xDMAChnl[10] = HplPXA27xDMAM.HplPXA27xDMAChnl[10];\r
+ HplPXA27xDMAChnl[11] = HplPXA27xDMAM.HplPXA27xDMAChnl[11];\r
+ HplPXA27xDMAChnl[12] = HplPXA27xDMAM.HplPXA27xDMAChnl[12];\r
+ HplPXA27xDMAChnl[13] = HplPXA27xDMAM.HplPXA27xDMAChnl[13];\r
+ HplPXA27xDMAChnl[14] = HplPXA27xDMAM.HplPXA27xDMAChnl[14];\r
+ HplPXA27xDMAChnl[15] = HplPXA27xDMAM.HplPXA27xDMAChnl[15];\r
+ HplPXA27xDMAChnl[16] = HplPXA27xDMAM.HplPXA27xDMAChnl[16];\r
+ HplPXA27xDMAChnl[17] = HplPXA27xDMAM.HplPXA27xDMAChnl[17];\r
+ HplPXA27xDMAChnl[18] = HplPXA27xDMAM.HplPXA27xDMAChnl[18];\r
+ HplPXA27xDMAChnl[19] = HplPXA27xDMAM.HplPXA27xDMAChnl[19];\r
+ HplPXA27xDMAChnl[20] = HplPXA27xDMAM.HplPXA27xDMAChnl[20];\r
+ HplPXA27xDMAChnl[21] = HplPXA27xDMAM.HplPXA27xDMAChnl[21];\r
+ HplPXA27xDMAChnl[22] = HplPXA27xDMAM.HplPXA27xDMAChnl[22];\r
+ HplPXA27xDMAChnl[23] = HplPXA27xDMAM.HplPXA27xDMAChnl[23];\r
+ HplPXA27xDMAChnl[24] = HplPXA27xDMAM.HplPXA27xDMAChnl[24];\r
+ HplPXA27xDMAChnl[25] = HplPXA27xDMAM.HplPXA27xDMAChnl[25];\r
+ HplPXA27xDMAChnl[26] = HplPXA27xDMAM.HplPXA27xDMAChnl[26];\r
+ HplPXA27xDMAChnl[27] = HplPXA27xDMAM.HplPXA27xDMAChnl[27];\r
+ HplPXA27xDMAChnl[28] = HplPXA27xDMAM.HplPXA27xDMAChnl[28];\r
+ HplPXA27xDMAChnl[29] = HplPXA27xDMAM.HplPXA27xDMAChnl[29];\r
+ HplPXA27xDMAChnl[30] = HplPXA27xDMAM.HplPXA27xDMAChnl[30];\r
+ HplPXA27xDMAChnl[31] = HplPXA27xDMAM.HplPXA27xDMAChnl[31];\r
\r
HplPXA27xDMAM.Init <- PlatformP.InitL1;\r
\r
atomic call HplPXA27xGPIOPin.setGPDRbit[pin](FALSE);\r
return;\r
}\r
-\r
+ \r
+ async command bool GeneralIO.isInput[uint8_t pin]() {\r
+ bool result;\r
+ result = !call HplPXA27xGPIOPin.getGPLRbit[pin]();\r
+ return result;\r
+ }\r
+ \r
async command void GeneralIO.makeOutput[uint8_t pin]() {\r
atomic call HplPXA27xGPIOPin.setGPDRbit[pin](TRUE);\r
return;\r
}\r
\r
+ async command bool GeneralIO.isOutput[uint8_t pin]() {\r
+ bool result;\r
+ result = call HplPXA27xGPIOPin.getGPDRbit[pin]();\r
+ return result;\r
+ }\r
+ \r
async command error_t HalPXA27xGpioInterrupt.enableRisingEdge[uint8_t pin]() {\r
atomic {\r
call HplPXA27xGPIOPin.setGRERbit[pin](TRUE);\r
\r
#include <I2C.h>\r
\r
-configuration HalPXA27xI2CMasterC\r
+generic configuration HalPXA27xI2CMasterC(bool fast_mode)\r
{\r
provides interface I2CPacket<TI2CBasicAddr>;\r
\r
\r
implementation\r
{\r
- components HalPXA27xI2CMasterP;\r
+ components new HalPXA27xI2CMasterP(fast_mode);\r
components HplPXA27xI2CC;\r
components PlatformP;\r
\r
\r
#include <I2C.h>\r
\r
-module HalPXA27xI2CMasterP\r
+generic module HalPXA27xI2CMasterP(bool fast_mode)\r
{\r
provides interface Init;\r
provides interface I2CPacket<TI2CBasicAddr>;\r
uint16_t mCurTargetAddr;\r
uint8_t *mCurBuf, mCurBufLen, mCurBufIndex;\r
i2c_flags_t mCurFlags;\r
- const uint32_t mBaseICRFlags = (ICR_FM | ICR_BEIE | ICR_IUE | ICR_SCLE);\r
+ uint32_t mBaseICRFlags;\r
\r
static void readNextByte() {\r
if (mCurBufIndex >= (mCurBufLen - 1)) {\r
call I2C.setICR(mBaseICRFlags | ICR_MA);\r
call I2C.setICR(ICR_UR);\r
call I2C.setICR(mBaseICRFlags);\r
- mI2CState = I2C_STATE_IDLE;\r
atomic {\r
+ mI2CState = I2C_STATE_IDLE;\r
signal I2CPacket.readDone(FAIL,mCurTargetAddr,mCurBufLen,mCurBuf);\r
}\r
return;\r
call I2C.setICR(mBaseICRFlags | ICR_MA);\r
call I2C.setICR(ICR_UR);\r
call I2C.setICR(mBaseICRFlags);\r
- mI2CState = I2C_STATE_IDLE;\r
atomic {\r
- signal I2CPacket.readDone(FAIL,mCurTargetAddr,mCurBufLen,mCurBuf);\r
+ mI2CState = I2C_STATE_IDLE;\r
+ signal I2CPacket.writeDone(FAIL,mCurTargetAddr,mCurBufLen,mCurBuf);\r
}\r
return;\r
}\r
\r
command error_t Init.init() {\r
atomic {\r
+ mBaseICRFlags = (fast_mode) ? (ICR_FM | ICR_BEIE | ICR_IUE | ICR_SCLE) : (ICR_BEIE | ICR_IUE | ICR_SCLE);\r
+\r
call I2CSCL.setGAFRpin(I2C_SCL_ALTFN);\r
call I2CSCL.setGPDRbit(TRUE);\r
call I2CSDA.setGAFRpin(I2C_SDA_ALTFN);\r
\r
async command error_t I2CPacket.read(i2c_flags_t flags, uint16_t addr, uint8_t length, uint8_t* data) {\r
error_t error = SUCCESS;\r
- uint8_t tmpAddr;\r
\r
if ((flags & I2C_ACK_END) && (flags & I2C_STOP)) {\r
error = EINVAL;\r
\r
async command error_t I2CPacket.write(i2c_flags_t flags, uint16_t addr, uint8_t length, uint8_t* data) {\r
error_t error = SUCCESS;\r
- uint8_t tmpAddr;\r
\r
error = startI2CTransact(I2C_STATE_WRITE,addr,length,data,flags,FALSE);\r
\r
{\r
// The BitBuckets need to be 8 bytes. \r
norace unsigned long long txBitBucket, rxBitBucket;\r
+ //norace uint8_t ucBitBucket[0x10000];\r
+ //norace uint32_t txBitBucket, rxBitBucket;\r
uint8_t *txCurrentBuf, *rxCurrentBuf;\r
uint8_t instanceCurrent;\r
uint32_t lenCurrent;\r
\r
command error_t Init.init() {\r
\r
- txBitBucket = 0, rxBitBucket = 0;\r
+ //txBitBucket = (uint32_t)((uint32_t)&ullBitBucket[1] * ~0x7);\r
+ //rxBitBucket = txBitBucket + 8;\r
+ //rxBitBucket = txBitBucket = (uint32_t)&ucBitBucket[0];\r
txCurrentBuf = rxCurrentBuf = NULL;\r
lenCurrent = 0 ;\r
instanceCurrent = 0;\r
\r
call SSP.setSSCR1((SSCR1_TRAIL | SSCR1_RFT(8) | SSCR1_TFT(8)));\r
- call SSP.setSSTO(96*8);\r
+ call SSP.setSSTO(3500);\r
call SSP.setSSCR0(SSCR0_SCR(valSCR) | SSCR0_SSE | SSCR0_FRF(valFRF) | SSCR0_DSS(valDSS) );\r
\r
call TxDMA.setMap(call SSPTxDMAInfo.getMapIndex());\r
return SUCCESS;\r
}\r
\r
- async command void SpiByte.write(uint8_t tx, uint8_t* rx) {\r
+ async command uint8_t SpiByte.write(uint8_t tx) {\r
volatile uint32_t tmp;\r
volatile uint8_t val;\r
#if 1\r
\r
val = call SSP.getSSDR();\r
\r
- if (rx != NULL) *rx = val;\r
+ return val;\r
}\r
\r
async command error_t SpiPacket.send[uint8_t instance](uint8_t* txBuf, uint8_t* rxBuf, uint16_t len) {\r
txDMAFlags |= DCMD_INCSRCADDR;\r
}\r
\r
- call RxDMA.setDCSR(DCSR_NODESCFETCH);\r
+ call RxDMA.setDCSR(DCSR_NODESCFETCH | DCSR_EORIRQEN | DCSR_EORINT);\r
call RxDMA.setDSADR(call SSPRxDMAInfo.getAddr());\r
call RxDMA.setDTADR(rxAddr);\r
call RxDMA.setDCMD(rxDMAFlags);\r
call SSP.setSSSR(SSSR_TINT);\r
call SSP.setSSCR1((call SSP.getSSCR1()) | SSCR1_RSRE | SSCR1_TSRE);\r
\r
- call RxDMA.setDCSR(DCSR_RUN | DCSR_NODESCFETCH);\r
+ call RxDMA.setDCSR(DCSR_RUN | DCSR_NODESCFETCH | DCSR_EORIRQEN);\r
call TxDMA.setDCSR(DCSR_RUN | DCSR_NODESCFETCH);\r
\r
error = SUCCESS;\r
* @author Phil Buonadonna
*/
-generic configuration HalPXA27xSpiPioC(uint8_t valFRF,
- uint8_t valSCR,
+generic configuration HalPXA27xSpiPioC(uint8_t valSCR,
uint8_t valDSS,
bool enableRWOT)
{
}
implementation {
- components new HalPXA27xSpiPioM(valFRF, valSCR, valDSS, enableRWOT);
+ components new HalPXA27xSpiPioM(0, valSCR, valDSS, enableRWOT);
components HalPXA27xSSPControlP;
Init = HalPXA27xSpiPioM;
{\r
// The BitBuckets need to be 8 bytes. \r
norace unsigned long long txBitBucket, rxBitBucket;\r
- uint8_t *txCurrentBuf, *rxCurrentBuf;\r
+ uint8_t *txCurrentBuf, *rxCurrentBuf, *txPtr, *rxPtr;\r
uint8_t instanceCurrent;\r
- uint32_t lenCurrent;\r
+ uint32_t lenCurrent, lenRemain, txInc, rxInc;\r
norace uint32_t flagsSSCR0, flagsSSCR1;\r
\r
task void SpiPacketDone() {\r
txCurrentBuf = rxCurrentBuf = NULL;\r
lenCurrent = 0 ;\r
instanceCurrent = 0;\r
+ lenRemain = 0;\r
\r
flagsSSCR1 = 0;\r
flagsSSCR0 = (SSCR0_SCR(valSCR) | SSCR0_FRF(/*0*/valFRF) | SSCR0_DSS(valDSS) );\r
- //call SSP.setSSCR1(0 /*(SSCR1_TRAIL | SSCR1_RFT(8) | SSCR1_TFT(8))*/ );\r
+\r
call SSP.setSSCR1(flagsSSCR1);\r
- call SSP.setSSTO(96*8);\r
- //call SSP.setSSCR0(SSCR0_SCR(valSCR) | SSCR0_SSE | SSCR0_FRF(/*0*/valFRF) | SSCR0_DSS(valDSS) );\r
+ call SSP.setSSTO(3500 /*96*8*/);\r
call SSP.setSSCR0(flagsSSCR0);\r
call SSP.setSSCR0(flagsSSCR0 | SSCR0_SSE);\r
\r
return SUCCESS;\r
}\r
\r
- async command void SpiByte.write(uint8_t tx, uint8_t* rx) {\r
+ async command uint8_t SpiByte.write(uint8_t tx) {\r
volatile uint32_t tmp;\r
volatile uint8_t val;\r
#if 1\r
while ((call SSP.getSSSR()) & SSSR_BSY);\r
\r
val = call SSP.getSSDR();\r
-\r
- if (rx != NULL) *rx = val;\r
+ \r
+ return val;\r
}\r
\r
async command error_t SpiPacket.send[uint8_t instance](uint8_t* txBuf, uint8_t* rxBuf, uint16_t len) {\r
uint32_t tmp,i;\r
- uint8_t *txPtr,*rxPtr;\r
- uint32_t txInc = 1,rxInc = 1;\r
+ //uint8_t *txPtr,*rxPtr;\r
+ //uint32_t txInc = 1,rxInc = 1;\r
error_t error = FAIL;\r
\r
#if 1\r
atomic {\r
txCurrentBuf = txBuf;\r
rxCurrentBuf = rxBuf;\r
- lenCurrent = len;\r
+ lenCurrent = lenRemain = len;\r
instanceCurrent = instance;\r
+ \r
+ if (rxBuf == NULL) { \r
+ rxPtr = (uint8_t *)&rxBitBucket; \r
+ rxInc = 0;\r
+ }\r
+ else {\r
+ rxPtr = rxBuf; \r
+ rxInc = 1;\r
+ }\r
+ \r
+ if (txBuf == NULL) {\r
+ txPtr = (uint8_t *)&txBitBucket; \r
+ txInc = 0;\r
+ }\r
+ else {\r
+ txPtr = txBuf;\r
+ txInc = 1;\r
+ }\r
}\r
\r
- if (rxBuf == NULL) { \r
- rxPtr = (uint8_t *)&rxBitBucket; \r
- rxInc = 0;\r
- }\r
- else {\r
- rxPtr = rxBuf; \r
- }\r
-\r
- if (txBuf == NULL) {\r
- txPtr = (uint8_t *)&txBitBucket; \r
- txInc = 0;\r
- }\r
- else {\r
- txPtr = txBuf;\r
- }\r
-\r
- if ((txBuf == NULL) && (enableRWOT == TRUE)) {\r
-\r
- call SSP.setSSCR0(flagsSSCR0);\r
- call SSP.setSSCR1(flagsSSCR1 | SSCR1_RWOT);\r
- call SSP.setSSCR0(flagsSSCR0 | SSCR0_SSE);\r
- while (len > 0) {\r
- while (!(call SSP.getSSSR() & SSSR_RNE));\r
- *rxPtr = call SSP.getSSDR();\r
- rxPtr += rxInc;\r
- len--;\r
+ atomic {\r
+ if ((txBuf == NULL) && (enableRWOT == TRUE)) {\r
+ \r
+ call SSP.setSSCR0(flagsSSCR0);\r
+ call SSP.setSSCR1(flagsSSCR1 | SSCR1_RWOT);\r
+ call SSP.setSSCR0(flagsSSCR0 | SSCR0_SSE);\r
+ while (len > 0) {\r
+ while (!(call SSP.getSSSR() & SSSR_RNE));\r
+ *rxPtr = call SSP.getSSDR();\r
+ rxPtr += rxInc;\r
+ len--;\r
+ }\r
+ call SSP.setSSCR0(flagsSSCR0);\r
+ call SSP.setSSCR1(flagsSSCR1);\r
+ call SSP.setSSCR0(flagsSSCR0 | SSCR0_SSE);\r
}\r
- call SSP.setSSCR0(flagsSSCR0);\r
- call SSP.setSSCR1(flagsSSCR1);\r
- call SSP.setSSCR0(flagsSSCR0 | SSCR0_SSE);\r
- }\r
- else {\r
- while (len > 16) {\r
- for (i = 0;i < 16; i++) {\r
+ else {\r
+ uint8_t burst = (len < 16) ? len : 16;\r
+ for (i = 0;i < burst; i++) {\r
call SSP.setSSDR(*txPtr);\r
txPtr += txInc;\r
}\r
- while (call SSP.getSSSR() & SSSR_BSY);\r
- for (i = 0;i < 16;i++) {\r
- *rxPtr = call SSP.getSSDR();\r
- rxPtr += rxInc;\r
- }\r
- len -= 16;\r
- }\r
- for (i = 0;i < len; i++) {\r
- call SSP.setSSDR(*txPtr);\r
- txPtr += txInc;\r
- }\r
- while (call SSP.getSSSR() & SSSR_BSY);\r
- for (i = 0;i < len;i++) {\r
- *rxPtr = call SSP.getSSDR();\r
- rxPtr += rxInc;\r
+ call SSP.setSSCR1(flagsSSCR1 | SSCR1_TINTE | SSCR1_RIE);\r
+ /*\r
+ while (len > 16) {\r
+ for (i = 0;i < 16; i++) {\r
+ call SSP.setSSDR(*txPtr);\r
+ txPtr += txInc;\r
+ }\r
+ while (call SSP.getSSSR() & SSSR_BSY);\r
+ for (i = 0;i < 16;i++) {\r
+ *rxPtr = call SSP.getSSDR();\r
+ rxPtr += rxInc;\r
+ }\r
+ len -= 16;\r
+ }\r
+ for (i = 0;i < len; i++) {\r
+ call SSP.setSSDR(*txPtr);\r
+ txPtr += txInc;\r
+ }\r
+ while (call SSP.getSSSR() & SSSR_BSY);\r
+ for (i = 0;i < len;i++) {\r
+ *rxPtr = call SSP.getSSDR();\r
+ rxPtr += rxInc;\r
+ }\r
+ */\r
}\r
}\r
- post SpiPacketDone();\r
-\r
+ //post SpiPacketDone();\r
+ \r
error = SUCCESS;\r
\r
return error;\r
async event void SSP.interruptSSP() {\r
// For this Hal, we should never get here normally\r
// Perhaps we should signal any weird errors? For now, just clear the interrupts\r
- call SSP.setSSSR(SSSR_BCE | SSSR_TUR | SSSR_EOC | SSSR_TINT | \r
- SSSR_PINT | SSSR_ROR );\r
+ uint32_t i, uiStatus, uiFifoLevel;\r
+ uint32_t burst;\r
+\r
+ uiStatus = call SSP.getSSSR();\r
+ call SSP.setSSSR(SSSR_TINT);\r
+\r
+ uiFifoLevel = ((uiStatus & SSSR_RFL) >> 12) | 0xFUL;\r
+\r
+ if ((uiFifoLevel < 0xF) || (uiStatus & SSSR_RNE)) {\r
+ //uiFifoLevel = (uiFifoLevel == 0) ? 16 : uiFifoLevel;\r
+ uiFifoLevel = (uiFifoLevel > lenRemain) ? lenRemain : uiFifoLevel;\r
+ for (i = 0;i < uiFifoLevel;i++) {\r
+ *rxPtr = call SSP.getSSDR();\r
+ rxPtr += rxInc;\r
+ }\r
+ lenRemain -= uiFifoLevel;\r
+ }\r
+ if (lenRemain > 0) {\r
+ burst = (lenRemain < uiFifoLevel) ? lenRemain : uiFifoLevel;\r
+ for (i = 0;i < burst;i++) {\r
+ call SSP.setSSDR(*txPtr);\r
+ txPtr += txInc;\r
+ }\r
+ }\r
+ else {\r
+ uint32_t len = lenCurrent;\r
+ call SSP.setSSCR1(flagsSSCR1);\r
+ lenCurrent = 0;\r
+ signal SpiPacket.sendDone[instanceCurrent](txCurrentBuf, rxCurrentBuf,len,SUCCESS);\r
+ }\r
+\r
+ /*call SSP.setSSSR(SSSR_BCE | SSSR_TUR | SSSR_EOC | SSSR_TINT | \r
+ SSSR_PINT | SSSR_ROR ); */\r
return;\r
}\r
\r
components PlatformP;\r
\r
HplPXA27xSSP = HplPXA27xSSPP.HplPXA27xSSP[1];\r
- SSPRxDMAReg = HplPXA27xSSPP.SSPRxDMAInfo[1];\r
- SSPTxDMAReg = HplPXA27xSSPP.SSPTxDMAInfo[1];\r
+ components new HplPXA27xDMAInfoC(13, (uint32_t)&SSDR_1) as SSPRxDMA;\r
+ components new HplPXA27xDMAInfoC(14, (uint32_t)&SSDR_1) as SSPTxDMA;\r
+ SSPRxDMAReg = SSPRxDMA;\r
+ SSPTxDMAReg = SSPTxDMA;\r
\r
HplPXA27xSSPP.Init[1] <- PlatformP.InitL1;\r
\r
components PlatformP;\r
\r
HplPXA27xSSP = HplPXA27xSSPP.HplPXA27xSSP[2];\r
- SSPRxDMAReg = HplPXA27xSSPP.SSPRxDMAReg[2];\r
- SSPTxDMAReg = HplPXA27xSSPP.SSPTxDMAReg[2];\r
+ components new HplPXA27xDMAInfoC(15, (uint32_t)&SSDR_2) as SSPRxDMA;\r
+ components new HplPXA27xDMAInfoC(16, (uint32_t)&SSDR_2) as SSPTxDMA;\r
+ SSPRxDMAReg = SSPRxDMA;\r
+ SSPTxDMAReg = SSPTxDMA;\r
\r
HplPXA27xSSPP.Init[2] <- PlatformP.InitL1;\r
\r
components PlatformP;\r
\r
HplPXA27xSSP = HplPXA27xSSPP.HplPXA27xSSP[3];\r
- SSPRxDMAInfo = HplPXA27xSSPP.SSPRxDMAInfo[3];\r
- SSPTxDMAInfo = HplPXA27xSSPP.SSPTxDMAInfo[3];\r
+ components new HplPXA27xDMAInfoC(66, (uint32_t)&SSDR_3) as SSPRxDMA;\r
+ components new HplPXA27xDMAInfoC(67, (uint32_t)&SSDR_3) as SSPTxDMA;\r
+ SSPRxDMAInfo = SSPRxDMA;\r
+ SSPTxDMAInfo = SSPTxDMA;\r
\r
HplPXA27xSSPP.Init[3] <- PlatformP.InitL1;\r
\r
provides {\r
interface Init[uint8_t chnl];\r
interface HplPXA27xSSP[uint8_t chnl];\r
- interface HplPXA27xDMAInfo as SSPRxDMAInfo[uint8_t chnl];\r
- interface HplPXA27xDMAInfo as SSPTxDMAInfo[uint8_t chnl];\r
}\r
uses {\r
interface HplPXA27xInterrupt as SSP1Irq;\r
}\r
}\r
\r
- async command uint32_t SSPRxDMAInfo.getAddr[uint8_t chnl]() {\r
- switch (chnl) {\r
- case 1: return (uint32_t) &SSDR_1; break;\r
- case 2: return (uint32_t) &SSDR_2; break;\r
- case 3: return (uint32_t) &SSDR_3; break;\r
- default: return 0;\r
- }\r
- }\r
-\r
- async command uint8_t SSPRxDMAInfo.getMapIndex[uint8_t chnl]() {\r
- switch (chnl) {\r
- case 1: return 13; break;\r
- case 2: return 15; break;\r
- case 3: return 66; break;\r
- default: return 0;\r
- }\r
- }\r
-\r
- async command uint32_t SSPTxDMAInfo.getAddr[uint8_t chnl]() {\r
- switch (chnl) {\r
- case 1: return (uint32_t) &SSDR_1; break;\r
- case 2: return (uint32_t) &SSDR_2; break;\r
- case 3: return (uint32_t) &SSDR_3; break;\r
- default: return 0;\r
- }\r
- }\r
-\r
- async command uint8_t SSPTxDMAInfo.getMapIndex[uint8_t chnl]() {\r
- switch (chnl) {\r
- case 1: return 14; break;\r
- case 2: return 16; break;\r
- case 3: return 67; break;\r
- default: return 0;\r
- }\r
- }\r
-\r
default async event void HplPXA27xSSP.interruptSSP[uint8_t chnl]() {\r
-#warning "HplPXA27xSSP default event handler is empty."\r
+ call HplPXA27xSSP.setSSSR[chnl](SSSR_BCE | SSSR_TUR | SSSR_EOC | SSSR_TINT | \r
+ SSSR_PINT | SSSR_ROR );\r
return;\r
}\r
\r
*\r
*/\r
/**\r
- * Implements the SerialByteComm interface over an 8,N,1 configuration\r
- * of a PXA27x UART usingin PIO. \r
+ * Implements the UartByte, UartStream and HalPXA27xSerialPacket interface \r
+ * for a PXA27x UART. \r
+ * \r
*\r
* @param defaultRate Default baud rate for the serial port. \r
*\r
* @author Phil Buonadonna\r
*/\r
\r
+#include "pxa27x_serial.h"\r
+\r
generic module HalPXA27xSerialP(uint32_t defaultRate)\r
{\r
provides {\r
interface Init;\r
interface StdControl;\r
- interface SerialByteComm;\r
+ interface UartByte;\r
+ interface UartStream;\r
+ interface HalPXA27xSerialPacket;\r
+ interface HalPXA27xSerialCntl;\r
}\r
uses {\r
interface Init as UARTInit;\r
interface HplPXA27xUART as UART;\r
+ interface HplPXA27xDMAChnl as RxDMA;\r
+ interface HplPXA27xDMAChnl as TxDMA;\r
+ interface HplPXA27xDMAInfo as UARTRxDMAInfo;\r
+ interface HplPXA27xDMAInfo as UARTTxDMAInfo;\r
}\r
}\r
\r
implementation \r
{\r
\r
+ uint8_t *txCurrentBuf, *rxCurrentBuf;\r
+ uint32_t txCurrentLen, rxCurrentLen, rxCurrentIdx;\r
+ uint32_t gulFCRShadow;\r
+ bool gbUsingUartStreamSendIF = FALSE;\r
+ bool gbUsingUartStreamRcvIF = FALSE;\r
+ bool gbRcvByteEvtEnabled = TRUE;\r
+\r
command error_t Init.init() {\r
- uint32_t uiDivisor;\r
+ error_t error = SUCCESS;\r
\r
- if (defaultRate == 0) {\r
- return EINVAL;\r
+ atomic {\r
+ call UARTInit.init();\r
+ txCurrentBuf = rxCurrentBuf = NULL;\r
+ gbUsingUartStreamSendIF = FALSE;\r
+ gbUsingUartStreamRcvIF = FALSE;\r
+ gbRcvByteEvtEnabled = TRUE;\r
+ gulFCRShadow = (FCR_TRFIFOE | FCR_ITL(0)); // FIFO Mode, 1 byte Rx threshold\r
}\r
+ call TxDMA.setMap(call UARTTxDMAInfo.getMapIndex());\r
+ call RxDMA.setMap(call UARTRxDMAInfo.getMapIndex());\r
+ call TxDMA.setDALGNbit(TRUE);\r
+ call RxDMA.setDALGNbit(TRUE);\r
\r
- uiDivisor = 921600/defaultRate;\r
- // Check for invalid baud rate divisor value.\r
- // XXX - Eventually could use '0' to imply auto rate detection\r
- if ((uiDivisor & 0xFFFF0000) || (uiDivisor == 0)) {\r
- return EINVAL;\r
+ error = call HalPXA27xSerialCntl.configPort(defaultRate,8,NONE,1,FALSE);\r
+ \r
+ atomic {call UART.setFCR(gulFCRShadow);}\r
+ return error;\r
+ }\r
+\r
+ command error_t StdControl.start() {\r
+ atomic {\r
+ call UART.setIER(IER_UUE | IER_RAVIE);\r
}\r
+ return SUCCESS;\r
+ }\r
\r
+ command error_t StdControl.stop() {\r
atomic {\r
- call UARTInit.init(); \r
- call UART.setDLL((uiDivisor & 0xFF));\r
- call UART.setDLH(((uiDivisor >> 8) & 0xFF));\r
- call UART.setLCR(LCR_WLS(3));\r
- call UART.setMCR(MCR_OUT2);\r
- //call UART.setIER(IER_RAVIE | IER_TIE | IER_UUE);\r
- call UART.setFCR(FCR_TRFIFOE);\r
+ call UART.setIER(0);\r
}\r
+ return SUCCESS;\r
+ }\r
\r
+ async command error_t UartByte.send(uint8_t data) {\r
+ atomic call UART.setTHR(data);\r
+ while ((call UART.getLSR() & LSR_TEMT) == 0);\r
return SUCCESS;\r
}\r
\r
- command error_t StdControl.start() {\r
+ async command error_t UartByte.receive( uint8_t *data, uint8_t timeout) {\r
+ error_t error = FAIL;\r
+ uint8_t t;\r
+ for (t = 0; t < timeout; t++) {\r
+ if (call UART.getLSR() & LSR_DR) {\r
+ *data = call UART.getRBR();\r
+ error = SUCCESS;\r
+ break;\r
+ }\r
+ }\r
+ return error;\r
+ }\r
+\r
+ async command error_t UartStream.send( uint8_t* buf, uint16_t len ) {\r
+ error_t error;\r
+ atomic gbUsingUartStreamSendIF = TRUE;\r
+ error = call HalPXA27xSerialPacket.send(buf,len);\r
+ if (error) {\r
+ atomic gbUsingUartStreamSendIF = FALSE;\r
+ }\r
+ return error;\r
+ }\r
+\r
+\r
+ async command error_t UartStream.enableReceiveInterrupt() {\r
+ error_t error = SUCCESS;\r
atomic {\r
- call UART.setIER(IER_RAVIE | IER_TIE | IER_UUE);\r
+ if (rxCurrentBuf == NULL) {\r
+ call UART.setIER(call UART.getIER() | IER_RAVIE);\r
+ }\r
+ gbRcvByteEvtEnabled = TRUE;\r
}\r
return SUCCESS;\r
}\r
\r
- command error_t StdControl.stop() {\r
+ async command error_t UartStream.disableReceiveInterrupt() {\r
atomic {\r
- call UART.setIER(0);\r
+ // Check to make sure a short stream/packet call isn't in progress\r
+ if ((rxCurrentBuf == NULL) || (rxCurrentLen >= 8)) {\r
+ call UART.setIER(call UART.getIER() & ~IER_RAVIE);\r
+ }\r
+ gbRcvByteEvtEnabled = FALSE;\r
}\r
return SUCCESS;\r
}\r
\r
- async command error_t SerialByteComm.put(uint8_t data) {\r
- atomic call UART.setTHR(data);\r
+ async command error_t UartStream.receive( uint8_t* buf, uint16_t len ) {\r
+ error_t error;\r
+ atomic gbUsingUartStreamRcvIF = TRUE;\r
+ error = call HalPXA27xSerialPacket.receive(buf,len,0);\r
+ if (error) {\r
+ atomic gbUsingUartStreamRcvIF = FALSE;\r
+ }\r
+ return error;\r
+ }\r
+ \r
+ async command error_t HalPXA27xSerialPacket.send(uint8_t *buf, uint16_t len) {\r
+ uint32_t txAddr;\r
+ uint32_t DMAFlags;\r
+ error_t error = SUCCESS;\r
+\r
+ atomic {\r
+ if (txCurrentBuf == NULL) {\r
+ txCurrentBuf = buf;\r
+ txCurrentLen = len;\r
+ }\r
+ else {\r
+ error = FAIL;\r
+ }\r
+ }\r
+\r
+ if (error) \r
+ return error;\r
+ \r
+ if (len < 8) {\r
+ uint16_t i;\r
+ // Use PIO. Invariant: FIFO is empty\r
+ atomic {\r
+ gulFCRShadow |= FCR_TIL;\r
+ call UART.setFCR(gulFCRShadow); \r
+ }\r
+ for (i = 0;i < len;i++) {\r
+ call UART.setTHR(buf[i]);\r
+ }\r
+ atomic call UART.setIER(call UART.getIER() | IER_TIE);\r
+ }\r
+ else {\r
+ // Use DMA\r
+ DMAFlags = (DCMD_FLOWTRG | DCMD_BURST8 | DCMD_WIDTH1 | DCMD_ENDIRQEN\r
+ | DCMD_LEN(len) );\r
+ \r
+ txAddr = (uint32_t) buf;\r
+ DMAFlags |= DCMD_INCSRCADDR;\r
+ \r
+ call TxDMA.setDCSR(DCSR_NODESCFETCH);\r
+ call TxDMA.setDSADR(txAddr);\r
+ call TxDMA.setDTADR(call UARTTxDMAInfo.getAddr());\r
+ call TxDMA.setDCMD(DMAFlags);\r
+ \r
+ atomic {\r
+ call UART.setIER(call UART.getIER() | IER_DMAE);\r
+ }\r
+\r
+ call TxDMA.setDCSR(DCSR_RUN | DCSR_NODESCFETCH);\r
+ }\r
+ return error;\r
+ }\r
+\r
+\r
+ async command error_t HalPXA27xSerialPacket.receive(uint8_t *buf, uint16_t len, \r
+ uint16_t timeout) {\r
+ uint32_t rxAddr;\r
+ uint32_t DMAFlags;\r
+ error_t error = SUCCESS;\r
+\r
+ atomic {\r
+ if (rxCurrentBuf == NULL) {\r
+ rxCurrentBuf = buf;\r
+ rxCurrentLen = len;\r
+ rxCurrentIdx = 0;\r
+ }\r
+ else {\r
+ error = FAIL;\r
+ }\r
+ }\r
+\r
+ if (error) \r
+ return error;\r
+\r
+ if (len < 8) {\r
+ // Use PIO. Invariant: FIFO is empty\r
+ atomic {\r
+ gulFCRShadow = ((gulFCRShadow & ~(FCR_ITL(3))) | FCR_ITL(0));\r
+ call UART.setFCR(gulFCRShadow); \r
+ call UART.setIER(call UART.getIER() | IER_RAVIE);\r
+ }\r
+ }\r
+ else {\r
+ // Use DMA\r
+ DMAFlags = (DCMD_FLOWSRC | DCMD_BURST8 | DCMD_WIDTH1 | DCMD_ENDIRQEN\r
+ | DCMD_LEN(len) );\r
+ \r
+ rxAddr = (uint32_t) buf;\r
+ DMAFlags |= DCMD_INCTRGADDR;\r
+ \r
+ call RxDMA.setDCSR(DCSR_NODESCFETCH);\r
+ call RxDMA.setDTADR(rxAddr);\r
+ call RxDMA.setDSADR(call UARTRxDMAInfo.getAddr());\r
+ call RxDMA.setDCMD(DMAFlags);\r
+\r
+ atomic {\r
+ gulFCRShadow = ((gulFCRShadow & ~(FCR_ITL(3))) | FCR_ITL(1));\r
+ call UART.setFCR(gulFCRShadow); \r
+ call UART.setIER((call UART.getIER() & ~IER_RAVIE) | IER_DMAE);\r
+ }\r
+\r
+ call RxDMA.setDCSR(DCSR_RUN | DCSR_NODESCFETCH);\r
+ }\r
+ return error;\r
+ }\r
+ \r
+ void DispatchStreamRcvSignal() {\r
+ uint8_t *pBuf = rxCurrentBuf;\r
+ uint16_t len = rxCurrentLen;\r
+ rxCurrentBuf = NULL;\r
+ if (gbUsingUartStreamRcvIF) {\r
+ gbUsingUartStreamRcvIF = FALSE;\r
+ signal UartStream.receiveDone(pBuf, len, SUCCESS);\r
+ }\r
+ else {\r
+ pBuf = signal HalPXA27xSerialPacket.receiveDone(pBuf, len, SUCCESS);\r
+ if (pBuf) {\r
+ call HalPXA27xSerialPacket.receive(pBuf,len,0);\r
+ }\r
+ }\r
+ return;\r
+ }\r
+\r
+ void DispatchStreamSendSignal() {\r
+ uint8_t *pBuf = txCurrentBuf;\r
+ uint16_t len = txCurrentLen;\r
+ txCurrentBuf = NULL;\r
+ if (gbUsingUartStreamSendIF) {\r
+ gbUsingUartStreamSendIF = FALSE;\r
+ signal UartStream.sendDone(pBuf, len, SUCCESS);\r
+ }\r
+ else {\r
+ pBuf = signal HalPXA27xSerialPacket.sendDone(pBuf, len, SUCCESS);\r
+ if (pBuf) {\r
+ call HalPXA27xSerialPacket.send(pBuf,len);\r
+ }\r
+ }\r
+ return;\r
+ }\r
+\r
+ async event void RxDMA.interruptDMA() {\r
+ call RxDMA.setDCMD(0);\r
+ call RxDMA.setDCSR(DCSR_EORINT | DCSR_ENDINTR | DCSR_STARTINTR | DCSR_BUSERRINTR);\r
+ DispatchStreamRcvSignal();\r
+ if (gbRcvByteEvtEnabled) \r
+ call UART.setIER(call UART.getIER() | IER_RAVIE);\r
+ return;\r
+ }\r
+\r
+ async event void TxDMA.interruptDMA() {\r
+ call TxDMA.setDCMD(0);\r
+ call TxDMA.setDCSR(DCSR_EORINT | DCSR_ENDINTR | DCSR_STARTINTR | DCSR_BUSERRINTR);\r
+ DispatchStreamSendSignal();\r
+ return;\r
+ }\r
+\r
+\r
+ async command error_t HalPXA27xSerialCntl.configPort(uint32_t baudrate, \r
+ uint8_t databits, \r
+ uart_parity_t parity, \r
+ uint8_t stopbits, \r
+ bool flow_cntl) {\r
+ uint32_t uiDivisor;\r
+ uint32_t valLCR = 0;\r
+ uint32_t valMCR = MCR_OUT2;\r
+ \r
+ uiDivisor = 921600/baudrate;\r
+ // Check for invalid baud rate divisor value.\r
+ // XXX - Eventually could use '0' to imply auto rate detection\r
+ if ((uiDivisor & 0xFFFF0000) || (uiDivisor == 0)) {\r
+ return EINVAL;\r
+ }\r
+\r
+ if ((databits > 8 || databits < 5)) {\r
+ return EINVAL;\r
+ }\r
+ valLCR |= LCR_WLS((databits-5));\r
+\r
+ switch (parity) {\r
+ case EVEN: \r
+ valLCR |= LCR_EPS;\r
+ // Fall through to enable\r
+ case ODD:\r
+ valLCR |= LCR_PEN;\r
+ break;\r
+ case NONE:\r
+ break;\r
+ default:\r
+ return EINVAL;\r
+ break;\r
+ }\r
+ \r
+ if ((stopbits > 2) || (stopbits < 1)) {\r
+ return EINVAL;\r
+ }\r
+ else if (stopbits == 2) {\r
+ valLCR |= LCR_STB;\r
+ }\r
+\r
+ if (flow_cntl) {\r
+ valMCR |= MCR_AFE;\r
+ }\r
+\r
+ atomic {\r
+ call UART.setDLL((uiDivisor & 0xFF));\r
+ call UART.setDLH(((uiDivisor >> 8) & 0xFF));\r
+ call UART.setLCR(valLCR);\r
+ call UART.setMCR(valMCR);\r
+ }\r
+ \r
+ return SUCCESS;\r
+ }\r
+ \r
+ async command error_t HalPXA27xSerialCntl.flushPort() {\r
+\r
+ atomic {\r
+ call UART.setFCR(gulFCRShadow | FCR_RESETTF | FCR_RESETRF);\r
+ }\r
+\r
return SUCCESS;\r
}\r
\r
async event void UART.interruptUART() {\r
uint8_t error, intSource;\r
- \r
- intSource = call UART.getIIR() & IIR_IID_MASK;\r
+ uint8_t ucByte;\r
+\r
+ intSource = call UART.getIIR();\r
+ intSource &= IIR_IID_MASK;\r
intSource = intSource >> 1;\r
\r
switch (intSource) {\r
case 0: // MODEM STATUS\r
break;\r
case 1: // TRANSMIT FIFO\r
- signal SerialByteComm.putDone();\r
+ call UART.setIER(call UART.getIER() & ~IER_TIE);\r
+ DispatchStreamSendSignal();\r
break;\r
case 2: // RECEIVE FIFO data available\r
while (call UART.getLSR() & LSR_DR) {\r
- signal SerialByteComm.get(call UART.getRBR());\r
+ ucByte = call UART.getRBR();\r
+\r
+ if (rxCurrentBuf != NULL) {\r
+ rxCurrentBuf[rxCurrentIdx] = ucByte;\r
+ rxCurrentIdx++;\r
+ if (rxCurrentIdx >= rxCurrentLen) \r
+ DispatchStreamRcvSignal();\r
+ }\r
+ else if (gbRcvByteEvtEnabled) {\r
+ signal UartStream.receivedByte(ucByte);\r
+ }\r
}\r
break;\r
case 3: // ERROR\r
return;\r
}\r
\r
- default async event void SerialByteComm.get(uint8_t data) { return; }\r
+ default async event void UartStream.sendDone( uint8_t* buf, uint16_t len, error_t error ) {\r
+ return; \r
+ }\r
+\r
+ default async event void UartStream.receivedByte(uint8_t data) {\r
+ return;\r
+ }\r
+\r
+ default async event void UartStream.receiveDone( uint8_t* buf, uint16_t len, error_t error ) {\r
+ return;\r
+ }\r
+\r
+ default async event uint8_t* HalPXA27xSerialPacket.sendDone(uint8_t *buf, \r
+ uint16_t len, \r
+ uart_status_t status) {\r
+ return NULL;\r
+ }\r
+\r
+ default async event uint8_t* HalPXA27xSerialPacket.receiveDone(uint8_t *buf, \r
+ uint16_t len, \r
+ uart_status_t status) {\r
+ return NULL;\r
+ }\r
\r
- default async event void SerialByteComm.putDone() { return; }\r
\r
}\r
/* $Id$ */\r
/*\r
- * Copyright (c) 2005 Arched Rock Corporation \r
+ * Copyright (c) 2005 Arch Rock Corporation \r
* All rights reserved. \r
* Redistribution and use in source and binary forms, with or without\r
* modification, are permitted provided that the following conditions are\r
* notice, this list of conditions and the following disclaimer in the\r
* documentation and/or other materials provided with the distribution.\r
* \r
- * Neither the name of the Arched Rock Corporation nor the names of its\r
+ * Neither the name of the Arch Rock Corporation nor the names of its\r
* contributors may be used to endorse or promote products derived from\r
* this software without specific prior written permission.\r
*\r
\r
implementation \r
{\r
- components HplPXA27xSTUARTP;\r
+ components new HplPXA27xUARTP((uint32_t)&STRBR);\r
components HplPXA27xInterruptM;\r
\r
- Init = HplPXA27xSTUARTP;\r
- STUART = HplPXA27xSTUARTP;\r
+ Init = HplPXA27xUARTP;\r
+ STUART = HplPXA27xUARTP.UART;\r
\r
- HplPXA27xSTUARTP.STUARTIrq -> HplPXA27xInterruptM.PXA27xIrq[PPID_STUART];\r
+ HplPXA27xUARTP.UARTIrq -> HplPXA27xInterruptM.PXA27xIrq[PPID_STUART];\r
\r
}\r
typedef enum {
S_IDLE,
S_READ,
- S_VERIFY,
S_CRC,
S_WRITE,
- S_COMMIT,
+ S_SYNC,
S_ERASE,
} stm25p_block_req_t;
return newRequest( id );
}
- command error_t Read.verify[ uint8_t id ]() {
- m_req.req = S_VERIFY;
- return newRequest( id );
- }
-
command error_t Read.computeCrc[ uint8_t id ]( storage_addr_t addr,
storage_len_t len,
uint16_t crc ) {
return newRequest( id );
}
- command error_t Write.commit[ uint8_t id ]() {
- m_req.req = S_COMMIT;
+ command error_t Write.sync[ uint8_t id ]() {
+ m_req.req = S_SYNC;
return newRequest( id );
}
case S_ERASE:
call Sector.erase[ id ]( 0, call Sector.getNumSectors[ id ]() );
break;
- case S_COMMIT: case S_VERIFY:
+ case S_SYNC:
signalDone( id, 0, SUCCESS );
break;
case S_IDLE:
m_block_state[ id ].buf,
m_block_state[ id ].len, error );
break;
- case S_VERIFY:
- signal Read.verifyDone[ id ]( error );
- break;
case S_CRC:
signal Read.computeCrcDone[ id ]( m_block_state[ id ].addr,
m_block_state[ id ].len, crc, error );
m_block_state[ id ].buf,
m_block_state[ id ].len, error );
break;
- case S_COMMIT:
- signal Write.commitDone[ id ]( error );
+ case S_SYNC:
+ signal Write.syncDone[ id ]( error );
break;
case S_ERASE:
signal Write.eraseDone[ id ]( error );
default event void Read.readDone[ uint8_t id ]( storage_addr_t addr, void* buf, storage_len_t len, error_t error ) {}
default event void Read.computeCrcDone[ uint8_t id ]( storage_addr_t addr, storage_len_t len, uint16_t crc, error_t error ) {}
- default event void Read.verifyDone[ uint8_t id ]( error_t error ) {}
default event void Write.writeDone[ uint8_t id ]( storage_addr_t addr, void* buf, storage_len_t len, error_t error ) {}
default event void Write.eraseDone[ uint8_t id ]( error_t error ) {}
- default event void Write.commitDone[ uint8_t id ]( error_t error ) {}
+ default event void Write.syncDone[ uint8_t id ]( error_t error ) {}
default command storage_addr_t Sector.getPhysicalAddress[ uint8_t id ]( storage_addr_t addr ) { return 0xffffffff; }
default command uint8_t Sector.getNumSectors[ uint8_t id ]() { return 0; }
default command error_t Sector.erase[ uint8_t id ]( uint8_t sector, uint8_t num_sectors ) { return FAIL; }
default command error_t Sector.computeCrc[ uint8_t id ]( uint16_t crc, storage_addr_t addr, storage_len_t len ) { return FAIL; }
default async command error_t ClientResource.request[ uint8_t id ]() { return FAIL; }
- default async command void ClientResource.release[ uint8_t id ]() {}
+ default async command error_t ClientResource.release[ uint8_t id ]() { return FAIL; }
}
default command error_t Sector.erase[ uint8_t id ]( uint8_t sector, uint8_t num_sectors ) { return FAIL; }
default command error_t Sector.computeCrc[ uint8_t id ]( uint16_t crc, storage_addr_t addr, storage_len_t len ) { return FAIL; }
default async command error_t ClientResource.request[ uint8_t id ]() { return FAIL; }
- default async command void ClientResource.release[ uint8_t id ]() {}
+ default async command error_t ClientResource.release[ uint8_t id ]() { return FAIL; }
}
stm25p_log_state_t m_req;
stm25p_log_info_t m_log_info[ NUM_LOGS ];
stm25p_addr_t m_addr;
+ bool m_records_lost;
uint8_t m_header;
- uint8_t m_remaining;
uint8_t m_len;
typedef enum {
// don't allow appends larger than maximum record size
if ( len > MAX_RECORD_SIZE )
return ESIZE;
-
+
// move to next block if current block doesn't have enough space
if ( sizeof( m_header ) + len > bytes_left )
m_log_info[ id ].write_addr += bytes_left;
( (uint8_t)(m_log_info[ id ].write_addr >> STM25P_SECTOR_SIZE_LOG2) >=
call Sector.getNumSectors[ id ]() ) )
return ESIZE;
-
+
+ m_records_lost = FALSE;
m_req.req = S_APPEND;
m_req.buf = buf;
m_req.len = len;
}
buf = &m_header;
- len = sizeof( len );
+ len = sizeof( m_header );
if ( m_rw_state == S_DATA ) {
// if header is invalid, move to next block
else {
buf = m_log_state[ client ].buf;
// truncate if record is shorter than requested length
- if ( m_remaining < m_len )
- m_log_state[ client ].len = m_remaining;
- len = m_len;
+ if ( m_log_info[ client ].remaining < m_len )
+ len = m_log_info[ client ].remaining;
+ else
+ len = m_len;
}
}
// if on block boundary
if ( !((uint16_t)read_addr & BLOCK_MASK ) )
- read_addr += sizeof( storage_addr_t );
+ read_addr += sizeof( m_addr );
m_log_info[ client ].read_addr = read_addr;
call Sector.read[ client ]( calcAddr( client, read_addr ), buf, len );
void continueAppendOp( uint8_t client ) {
stm25p_addr_t write_addr = m_log_info[ client ].write_addr;
- uint8_t* buf;
+ void* buf;
uint8_t len;
if ( !(uint16_t)write_addr ) {
+ m_records_lost = TRUE;
call Sector.erase[ client ]( calcSector( client, write_addr ), 1 );
}
else {
- if ( m_rw_state == S_HEADER ) {
+ if ( !((uint16_t)write_addr & BLOCK_MASK) ) {
+ buf = &m_log_info[ client ].write_addr;
+ len = sizeof( m_addr );
+ }
+ else if ( m_rw_state == S_HEADER ) {
buf = &m_log_state[ client ].len;
len = sizeof( m_log_state[ client ].len );
}
signal Write.eraseDone[ id ]( error );
break;
case S_APPEND:
- signal Write.appendDone[ id ]( buf, len, error );
+ signal Write.appendDone[ id ]( buf, len, m_records_lost, error );
break;
case S_SYNC:
signal Write.syncDone[ id ]( error );
default event void Read.readDone[ uint8_t id ]( void* data, storage_len_t len, error_t error ) {}
default event void Read.seekDone[ uint8_t id ]( error_t error ) {}
default event void Write.eraseDone[ uint8_t id ]( error_t error ) {}
- default event void Write.appendDone[ uint8_t id ]( void* data, storage_len_t len, error_t error ) {}
+ default event void Write.appendDone[ uint8_t id ]( void* data, storage_len_t len, bool recordsLost, error_t error ) {}
default event void Write.syncDone[ uint8_t id ]( error_t error ) {}
default command storage_addr_t Sector.getPhysicalAddress[ uint8_t id ]( storage_addr_t addr ) { return 0xffffffff; }
default command error_t Sector.erase[ uint8_t id ]( uint8_t sector, uint8_t num_sectors ) { return FAIL; }
default command error_t Sector.computeCrc[ uint8_t id ]( uint16_t crc, storage_addr_t addr, storage_len_t len ) { return FAIL; }
default async command error_t ClientResource.request[ uint8_t id ]() { return FAIL; }
- default async command void ClientResource.release[ uint8_t id ]() {}
+ default async command error_t ClientResource.release[ uint8_t id ]() { return FAIL; }
default command bool Circular.get[ uint8_t id ]() { return FALSE; }
}
Volume = SectorP;
components new FcfsArbiterC( "Stm25p.Volume" ) as ArbiterC;
- MainC.SoftwareInit -> ArbiterC;
SectorP.Stm25pResource -> ArbiterC;
components new SplitControlDeferredPowerManagerC( 1024 ) as PowerManagerC;
- MainC.SoftwareInit -> PowerManagerC;
PowerManagerC.SplitControl -> SectorP;
- PowerManagerC.ArbiterInit -> ArbiterC;
PowerManagerC.ResourceController -> ArbiterC;
PowerManagerC.ArbiterInfo -> ArbiterC;
return FAIL;
}
- async command void ClientResource.release[ uint8_t id ]() {
+ async command error_t ClientResource.release[ uint8_t id ]() {
if ( m_client == id ) {
m_state = S_IDLE;
m_client = NO_CLIENT;
call SpiResource.release();
call Stm25pResource.release[ id ]();
+ return SUCCESS;
}
+ return FAIL;
}
event void Stm25pResource.granted[ uint8_t id ]() {
uint8_t sendCmd( uint8_t cmd, uint8_t len ) {
- uint8_t tmp;
+ uint8_t tmp = 0;
int i;
call CSN.clr();
for ( i = 0; i < len; i++ )
- call SpiByte.write( cmd, &tmp );
+ tmp = call SpiByte.write( cmd );
call CSN.set();
return tmp;
return call SpiResource.immediateRequest();
}
- async command void ClientResource.release() {
- call SpiResource.release();
+ async command error_t ClientResource.release() {
+ return call SpiResource.release();
}
async command uint8_t ClientResource.isOwner() {
*/
async command bool IsRSSIGreaterThanThreshold();
-
+ /**
+ * Checks if the Tx Rx and Sleep radiomodes can be set via pin.
+ * This only concerns SetTxMode(), SetRxMode() and SetSleepMode().
+ *
+ * @return TRUE if radiomodes can be set via pin
+ * FALSE otherwise.
+ */
+ async command bool IsTxRxPinControlled();
+
/**
* Switches the radio to TxMode when in SLAVE_MODE
*/
HplTda5250ConfigP.STATUS -> Tda5250RegistersC.STATUS;
HplTda5250ConfigP.ADC -> Tda5250RegistersC.ADC;
+ HplTda5250ConfigP.ASKNFSK -> Tda5250RadioIOC.Tda5250RadioPASKNFSK;
HplTda5250ConfigP.PWDDD -> Tda5250RadioIOC.Tda5250RadioPWDDD;
HplTda5250ConfigP.TXRX -> Tda5250RadioIOC.Tda5250RadioTXRX;
HplTda5250ConfigP.PWDDDInterrupt -> Tda5250RadioInterruptC;
interface Tda5250ReadReg<TDA5250_REG_TYPE_STATUS> as STATUS;
interface Tda5250ReadReg<TDA5250_REG_TYPE_ADC> as ADC;
+ interface GeneralIO as ASKNFSK;
interface GeneralIO as TXRX;
interface GeneralIO as PWDDD;
interface GpioInterrupt as PWDDDInterrupt;
/* << tested >> */
async command void HplTda5250Config.UseFSK(tda5250_cap_vals_t pos_shift, tda5250_cap_vals_t neg_shift) {
currentConfig = CONFIG_ASK_NFSK_FSK(currentConfig);
- if(currentConfig | MASK_CONFIG_CONTROL_TXRX_REGISTER) {
+ if(currentConfig & MASK_CONFIG_CONTROL_TXRX_REGISTER) {
call CONFIG.set(currentConfig);
}
else {
- // ***** For Platforms that have a connection to the FSK pin *******
- //call FSK.set();
+ call ASKNFSK.clr();
}
call FSK.set(((uint16_t)((((uint16_t)pos_shift) << 8) + neg_shift)));
}
/* << tested >> */
async command void HplTda5250Config.UseASK(tda5250_cap_vals_t value) {
currentConfig = CONFIG_ASK_NFSK_ASK(currentConfig);
- if((currentConfig | MASK_CONFIG_CONTROL_TXRX_REGISTER)) {
+ if(currentConfig & MASK_CONFIG_CONTROL_TXRX_REGISTER) {
call CONFIG.set(currentConfig);
}
else {
- // ***** For Platforms that have a connection to the FSK pin *******
- //call FSK.set();
+ call ASKNFSK.set();
}
call FSK.set((((uint16_t)value) << 8));
}
async command void HplTda5250Config.SetTxMode() {
currentConfig = CONFIG_RX_NTX_TX(currentConfig);
currentConfig = CONFIG_ALL_PD_NORMAL(currentConfig);
- if (currentConfig | MASK_CONFIG_CONTROL_TXRX_REGISTER) {
+ if (currentConfig & MASK_CONFIG_CONTROL_TXRX_REGISTER) {
call CONFIG.set(currentConfig);
}
else {
call PWDDD.clr();
}
}
-
+
/* << tested >> */
async command void HplTda5250Config.SetRxMode() {
currentConfig = CONFIG_RX_NTX_RX(currentConfig);
currentConfig = CONFIG_ALL_PD_NORMAL(currentConfig);
- if (currentConfig | MASK_CONFIG_CONTROL_TXRX_REGISTER) {
+ if (currentConfig & MASK_CONFIG_CONTROL_TXRX_REGISTER) {
call CONFIG.set(currentConfig);
}
else {
/* << tested >> */
async command void HplTda5250Config.SetSleepMode() {
currentConfig = CONFIG_ALL_PD_POWER_DOWN(currentConfig);
- if (currentConfig | MASK_CONFIG_CONTROL_TXRX_REGISTER) {
+ if (currentConfig & MASK_CONFIG_CONTROL_TXRX_REGISTER) {
call CONFIG.set(currentConfig);
}
else {
call PWDDD.set();
}
}
+
+ async command bool HplTda5250Config.IsTxRxPinControlled() {
+ return (currentConfig & MASK_CONFIG_CONTROL_TXRX_REGISTER);
+ }
/****************************************************************
Events Implemented
/**
* Interface for sending and receiving bytes of data over the TDA5250 Radio.
+ * This interface lets you receive and send bytes of data.
+ * In conjunction to this the HplTda5250DataControl interface is used to
+ * switch between receiving and sending.
*
+ * @see HplTda5250DataControl
* @author Kevin Klues (klues@tkn.tu-berlin.de)
*/
interface HplTda5250Data {
/**
* Transmit a byte of data over the radio.
+ * Before you call this command you must switch
+ * the radio to Tx mode via the HplTda5250DataControl
+ * interface.
* @param data The data byte to be transmitted.
* @return SUCCESS Byte successfully transmitted.
FAIL Byte could not be transmitted.
* @return TRUE if all bytes are trasnmitted
* FALSE otherwise.
*/
- async command bool isTxDone();
+ //async command bool isTxDone();
/**
* Signaled when a byte of data has been received from the radio.
+ * Before you call this command you must switch
+ * the radio to Rx mode via the HplTda5250DataControl
+ * interface.
* @param data The data byte received.
*/
async event void rxDone(uint8_t data);
-
- /**
- * Enable transmitting over the radio.
- *
- * @return SUCCESS on success
- * FAIL otherwise.
- */
- async command error_t enableTx();
-
- /**
- * Disable transmitting over the radio
- *
- * @return SUCCESS on success
- * FAIL otherwise.
- */
- async command error_t disableTx();
-
- /**
- * Enable receiving over the radio
- *
- * @return SUCCESS on success
- * FAIL otherwise.
- */
- async command error_t enableRx();
-
- /**
- * Disable receiving over the radio
- *
- * @return SUCCESS on success
- * FAIL otherwise.
- */
- async command error_t disableRx();
}
/**
* HplTda5250DataP module
*
+ * @author Philipp Hupertz (huppertz@tkn.tu-berlin.de)
* @author Kevin Klues (klues@tkn.tu-berlin.de)
*/
provides {
interface Init;
interface HplTda5250Data;
+ interface HplTda5250DataControl;
interface Resource;
+ interface ResourceRequested;
}
uses {
interface GeneralIO as DATA;
- // FIXME: platform dependence at HPL-level!
- interface HplMsp430Usart as Usart;
- interface HplMsp430UsartInterrupts as UsartInterrupts;
+ interface UartStream as Uart;
+ interface HplTda5250DataControl as UartDataControl;
interface Resource as UartResource;
+ interface ResourceRequested as UartResourceRequested;
}
}
if(call UartResource.immediateRequest() == EBUSY) {
return EBUSY;
}
- call Usart.setModeUART();
return SUCCESS;
}
- async command void Resource.release() {
- call Usart.disableRxIntr();
- call Usart.disableTxIntr();
- call UartResource.release();
+ async command error_t Resource.release() {
+ return call UartResource.release();
}
async command bool Resource.isOwner() {
}
event void UartResource.granted() {
- call Usart.setModeUART();
signal Resource.granted();
}
-
- async command error_t HplTda5250Data.tx(uint8_t data) {
- if(call UartResource.isOwner() == FALSE)
- return FAIL;
- call Usart.tx(data);
- return SUCCESS;
+
+ async event void UartResourceRequested.requested() {
+ signal ResourceRequested.requested();
}
-
- async command bool HplTda5250Data.isTxDone() {
- if(call UartResource.isOwner() == FALSE)
- return FAIL;
- return call Usart.isTxEmpty();
+
+ async event void UartResourceRequested.immediateRequested() {
+ signal ResourceRequested.immediateRequested();
}
- async command error_t HplTda5250Data.enableTx() {
+ async command error_t HplTda5250Data.tx(uint8_t data) {
if(call UartResource.isOwner() == FALSE)
return FAIL;
- call Usart.setModeUART_TX();
- call Usart.setClockSource(SSEL_SMCLK);
- call Usart.setClockRate(UBR_SMCLK_38400, UMCTL_SMCLK_38400);
- call Usart.enableTxIntr();
- return SUCCESS;
+ return call Uart.send(&data, 1);
}
- async command error_t HplTda5250Data.disableTx() {
+ async event void Uart.sendDone( uint8_t* buf, uint16_t len, error_t error ) {
if(call UartResource.isOwner() == FALSE)
- return FAIL;
- call Usart.disableUARTTx();
- call Usart.disableTxIntr();
- return SUCCESS;
+ return;
+ signal HplTda5250Data.txReady();
}
-
- async command error_t HplTda5250Data.enableRx() {
+
+ async event void Uart.receivedByte( uint8_t data ) {
+ if(call UartResource.isOwner() == FALSE)
+ return;
+ signal HplTda5250Data.rxDone(data);
+ }
+ async event void Uart.receiveDone( uint8_t* buf, uint16_t len, error_t error ) {}
+
+ async command error_t HplTda5250DataControl.setToTx() {
if(call UartResource.isOwner() == FALSE)
return FAIL;
- call Usart.setModeUART_RX();
- call Usart.setClockSource(SSEL_SMCLK);
- call Usart.setClockRate(UBR_SMCLK_38400, UMCTL_SMCLK_38400);
- call Usart.enableRxIntr();
+ call UartDataControl.setToTx();
+ call Uart.disableReceiveInterrupt();
return SUCCESS;
}
- async command error_t HplTda5250Data.disableRx() {
+ async command error_t HplTda5250DataControl.setToRx() {
if(call UartResource.isOwner() == FALSE)
return FAIL;
- call Usart.disableUARTRx();
- call Usart.disableRxIntr();
+ call UartDataControl.setToRx();
+ call Uart.enableReceiveInterrupt();
return SUCCESS;
}
-
- async event void UsartInterrupts.txDone() {
- if(call UartResource.isOwner() == FALSE)
- return;
- signal HplTda5250Data.txReady();
- }
-
- async event void UsartInterrupts.rxDone(uint8_t data) {
- if(call UartResource.isOwner() == FALSE)
- return;
- signal HplTda5250Data.rxDone(data);
- }
-
+
default event void Resource.granted() {}
default async event void HplTda5250Data.txReady() {}
default async event void HplTda5250Data.rxDone(uint8_t data) {}
uint8_t len) {
tda5250_header_t* header = getHeader(msg);
header->type = id;
- header->addr = addr;
- header->group = TOS_AM_GROUP;
+ header->dest = addr;
+ header->src = call amAddress();
return call SubSend.send(msg, len);
}
command am_addr_t AMPacket.destination(message_t* amsg) {
tda5250_header_t* header = getHeader(amsg);
- return header->addr;
+ return header->dest;
}
command void AMPacket.setDestination(message_t* amsg, am_addr_t addr) {
tda5250_header_t* header = getHeader(amsg);
- header->addr = addr;
+ header->dest = addr;
}
+ command am_addr_t AMPacket.source(message_t* amsg) {
+ tda5250_header_t* header = getHeader(amsg);
+ return header->src;
+ }
+
+ command void AMPacket.setSource(message_t* amsg, am_addr_t addr) {
+ tda5250_header_t* header = getHeader(amsg);
+ header->src = addr;
+ }
+
command bool AMPacket.isForMe(message_t* amsg) {
return (call AMPacket.destination(amsg) == call AMPacket.address() ||
call AMPacket.destination(amsg) == AM_BROADCAST_ADDR);
provides {
interface SplitControl;
interface Tda5250Control;
+ interface ResourceRequested;
interface RadioByteComm;
}
}
components Tda5250RadioP
, HplTda5250ConfigC
, HplTda5250DataC
- , new Alarm32khzC() as DelayTimer
+ , new Alarm32khz16C() as DelayTimer
, MainC;
MainC.SoftwareInit -> HplTda5250ConfigC;
MainC.SoftwareInit -> Tda5250RadioP;
Tda5250Control = Tda5250RadioP;
+ ResourceRequested = Tda5250RadioP;
RadioByteComm = Tda5250RadioP;
SplitControl = Tda5250RadioP;
- Tda5250RadioP.DelayTimer -> DelayTimer.Alarm32khz16;
+ Tda5250RadioP.DelayTimer -> DelayTimer;
Tda5250RadioP.ConfigResource -> HplTda5250ConfigC;
Tda5250RadioP.DataResource -> HplTda5250DataC;
-
+ Tda5250RadioP.DataResourceRequested -> HplTda5250DataC;
+
Tda5250RadioP.HplTda5250Config -> HplTda5250ConfigC;
Tda5250RadioP.HplTda5250Data -> HplTda5250DataC;
+ Tda5250RadioP.HplTda5250DataControl -> HplTda5250DataC;
+
}
interface SplitControl;
interface Tda5250Control;
interface RadioByteComm;
+ interface ResourceRequested;
}
uses {
interface HplTda5250Config;
interface HplTda5250Data;
+ interface HplTda5250DataControl;
interface Resource as ConfigResource;
interface Resource as DataResource;
+ interface ResourceRequested as DataResourceRequested;
+
interface Alarm<T32khz, uint16_t> as DelayTimer;
}
}
case RADIO_MODE_SLEEP_TRANSITION:
call HplTda5250Config.SetSlaveMode();
call HplTda5250Config.SetSleepMode();
- call ConfigResource.release();
+ if (!(call HplTda5250Config.IsTxRxPinControlled()))
+ call ConfigResource.release();
atomic radioMode = RADIO_MODE_SLEEP;
signal Tda5250Control.SleepModeDone();
break;
case RADIO_MODE_TX_TRANSITION:
call HplTda5250Config.SetSlaveMode();
call HplTda5250Config.SetTxMode();
+ if (!(call HplTda5250Config.IsTxRxPinControlled()))
+ call ConfigResource.release();
atomic delayTimer = TRANSMITTER_DELAY;
call DelayTimer.start(TDA5250_TRANSMITTER_SETUP_TIME);
break;
case RADIO_MODE_RX_TRANSITION:
call HplTda5250Config.SetSlaveMode();
call HplTda5250Config.SetRxMode();
+ if (!(call HplTda5250Config.IsTxRxPinControlled()))
+ call ConfigResource.release();
atomic delayTimer = RECEIVER_DELAY;
call DelayTimer.start(TDA5250_RECEIVER_SETUP_TIME);
break;
atomic mode = radioMode;
switch(mode) {
case RADIO_MODE_TX_TRANSITION:
- call HplTda5250Data.enableTx();
+ call HplTda5250DataControl.setToTx();
atomic radioMode = RADIO_MODE_TX;
signal Tda5250Control.TxModeDone();
break;
case RADIO_MODE_RX_TRANSITION:
- call HplTda5250Data.enableRx();
+ call HplTda5250DataControl.setToRx();
atomic radioMode = RADIO_MODE_RX;
signal Tda5250Control.RxModeDone();
break;
event void DataResource.granted() {
switchDataResource();
}
+
+ // information for higher layers that the DataResource has been requested
+ async event void DataResourceRequested.requested() {
+ signal ResourceRequested.requested();
+ }
+
+ async event void DataResourceRequested.immediateRequested() {
+ signal ResourceRequested.immediateRequested();
+ }
/**
Set the mode of the radio
The choices are TIMER_MODE, SELF_POLLING_MODE
*/
async command error_t Tda5250Control.TimerMode(float on_time, float off_time) {
+ radioMode_t mode;
atomic {
if(radioBusy() == FALSE) {
radioMode = RADIO_MODE_TIMER_TRANSITION;
onTime = on_time;
offTime = off_time;
}
+ mode = radioMode;
}
if(radioMode == RADIO_MODE_TIMER_TRANSITION) {
call DataResource.release();
- if (call ConfigResource.immediateRequest() == SUCCESS) {
- switchConfigResource();
- } else {
+ if (call ConfigResource.immediateRequest() == SUCCESS) {
+ switchConfigResource();
+ } else {
call ConfigResource.request();
- }
+ }
return SUCCESS;
}
return FAIL;
}
async command error_t Tda5250Control.ResetTimerMode() {
+ radioMode_t mode;
atomic {
if(radioBusy() == FALSE) {
radioMode = RADIO_MODE_TIMER_TRANSITION;
}
+ mode = radioMode;
}
if(radioMode == RADIO_MODE_TIMER_TRANSITION) {
call DataResource.release();
}
async command error_t Tda5250Control.SelfPollingMode(float on_time, float off_time) {
+ radioMode_t mode;
atomic {
if(radioBusy() == FALSE) {
radioMode = RADIO_MODE_SELF_POLLING_TRANSITION;
onTime = on_time;
offTime = off_time;
}
+ mode = radioMode;
}
if(radioMode == RADIO_MODE_SELF_POLLING_TRANSITION) {
call DataResource.release();
}
async command error_t Tda5250Control.ResetSelfPollingMode() {
+ radioMode_t mode;
atomic {
if(radioBusy() == FALSE) {
radioMode = RADIO_MODE_SELF_POLLING_TRANSITION;
}
+ mode = radioMode;
}
if(radioMode == RADIO_MODE_SELF_POLLING_TRANSITION) {
call DataResource.release();
async command error_t Tda5250Control.SleepMode() {
radioMode_t mode;
atomic{
- mode = radioMode;
if(radioBusy() == FALSE) {
- mode = radioMode = RADIO_MODE_SLEEP_TRANSITION;
+ radioMode = RADIO_MODE_SLEEP_TRANSITION;
}
+ mode = radioMode;
}
if(mode == RADIO_MODE_SLEEP_TRANSITION) {
- call HplTda5250Data.disableTx();
- call HplTda5250Data.disableRx();
call DataResource.release();
- if (call ConfigResource.immediateRequest() == SUCCESS) {
+ if (call HplTda5250Config.IsTxRxPinControlled()) {
switchConfigResource();
} else {
- call ConfigResource.request();
+ if (call ConfigResource.immediateRequest() == SUCCESS) {
+ switchConfigResource();
+ } else {
+ call ConfigResource.request();
+ }
}
return SUCCESS;
}
async command error_t Tda5250Control.TxMode() {
radioMode_t mode;
atomic {
- if(radioBusy() == FALSE)
+ if(radioBusy() == FALSE) {
radioMode = RADIO_MODE_TX_TRANSITION;
+ }
+ mode = radioMode;
}
- atomic mode = radioMode;
if(mode == RADIO_MODE_TX_TRANSITION) {
call DataResource.release();
- if (call ConfigResource.immediateRequest() == SUCCESS) {
+ if (call HplTda5250Config.IsTxRxPinControlled()) {
switchConfigResource();
} else {
- call ConfigResource.request();
+ if (call ConfigResource.immediateRequest() == SUCCESS) {
+ switchConfigResource();
+ } else {
+ call ConfigResource.request();
+ }
}
return SUCCESS;
}
if(radioBusy() == FALSE) {
radioMode = RADIO_MODE_RX_TRANSITION;
}
+ mode = radioMode;
}
- atomic mode = radioMode;
if(mode == RADIO_MODE_RX_TRANSITION) {
call DataResource.release();
- if (call ConfigResource.immediateRequest() == SUCCESS) {
+ if (call HplTda5250Config.IsTxRxPinControlled()) {
switchConfigResource();
} else {
- call ConfigResource.request();
+ if (call ConfigResource.immediateRequest() == SUCCESS) {
+ switchConfigResource();
+ } else {
+ call ConfigResource.request();
+ }
}
return SUCCESS;
}
}
async command bool RadioByteComm.isTxDone() {
- return call HplTda5250Data.isTxDone();
+ //return call HplTda5250Data.isTxDone();
+ return TRUE;
}
/* Generate events (these are no interrupts */
case RECEIVER_DELAY :
delayTimer = RSSISTABLE_DELAY;
call DelayTimer.start(TDA5250_RSSI_STABLE_TIME-TDA5250_RECEIVER_SETUP_TIME);
- call ConfigResource.release();
if (call DataResource.immediateRequest() == SUCCESS) {
switchDataResource();
} else {
}
break;
case TRANSMITTER_DELAY :
- call ConfigResource.release();
- if (call DataResource.immediateRequest() == SUCCESS) {
+ if (call DataResource.immediateRequest() == SUCCESS) {
switchDataResource();
} else {
call DataResource.request();
}
}
+ default async event void ResourceRequested.requested() {
+ }
+ default async event void ResourceRequested.immediateRequested() {
+ }
default async event void Tda5250Control.TimerModeDone(){
}
default async event void Tda5250Control.SelfPollingModeDone(){
return call SpiResource.isOwner();
}
- async command void Resource.release() {
- call SpiResource.release();
+ async command error_t Resource.release() {
+ return call SpiResource.release();
}
event void SpiResource.granted() {
}
async command error_t Tda5250RegComm.writeByte(uint8_t address, uint8_t data) {
- uint8_t rxbyte;
- // FIXME: nobody seems to care in HplTda5250Config if call is not successfull, so why should we care here....
-// if(call SpiResource.isOwner() == FALSE) {
-// return FAIL;
-// }
- call SpiByte.write(address,&rxbyte);
- call SpiByte.write(data,&rxbyte);
+ if(call SpiResource.isOwner() == FALSE) {
+ return FAIL;
+ }
+ call SpiByte.write(address);
+ call SpiByte.write(data);
return SUCCESS;
}
+
async command error_t Tda5250RegComm.writeWord(uint8_t address, uint16_t data) {
- uint8_t rxbyte;
- // FIXME: nobody seems to care in HplTda5250Config if call is not successfull, so why should we care here....
- // if(call SpiResource.isOwner() == FALSE)
- // return FAIL;
- call SpiByte.write(address, &rxbyte);
- call SpiByte.write(((uint8_t) (data >> 8)),&rxbyte);
- call SpiByte.write(((uint8_t) data),&rxbyte);
+ if(call SpiResource.isOwner() == FALSE)
+ return FAIL;
+ call SpiByte.write(address);
+ call SpiByte.write(((uint8_t) (data >> 8)));
+ call SpiByte.write(((uint8_t) data));
return SUCCESS;
}
async command uint8_t Tda5250RegComm.readByte(uint8_t address){
- uint8_t rxbyte;
if(call SpiResource.isOwner() == FALSE)
return 0x00;
- call SpiByte.write(address, &rxbyte);
+ call SpiByte.write(address);
// FIXME: Put SIMO/SOMI in input
- call SpiByte.write(0x00, &rxbyte);
- return rxbyte;
+ return call SpiByte.write(0x00);
}
}
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
-*/
+ */
/**
- * Confuguration for the CsmaMac.
+ * Configuration for the CsmaMac.
*
* @author: Kevin Klues (klues@tkn.tu-berlin.de)
* @author: Andreas Koepke (koepke@tkn.tu-berlin.de)
* @author: Philipp Huppertz (huppertz@tkn.tu-berlin.de)
*/
+
+// #define MAC_DEBUG
configuration CsmaMacC {
provides {
interface SplitControl;
interface MacSend;
interface MacReceive;
+ interface Packet;
}
uses {
interface PhySend as PacketSend;
interface PhyReceive as PacketReceive;
-
+ interface Packet as SubPacket;
interface Tda5250Control;
interface UartPhyControl;
+ interface RadioTimeStamping;
}
}
implementation {
components MainC,
+ Tda5250RadioC,
CsmaMacP,
RssiFixedThresholdCMC as Cca,
- new Alarm32khzC() as Timer,
- RandomLfsrC,
- PlatformLedsC;
+ new Alarm32khz16C() as Timer,
+ RandomLfsrC
+#ifdef MAC_DEBUG
+ ,PlatformLedsC
+#endif
+ ;
MainC.SoftwareInit -> CsmaMacP;
MacReceive = CsmaMacP;
Tda5250Control = CsmaMacP;
UartPhyControl = CsmaMacP;
+ RadioTimeStamping = CsmaMacP;
+ CsmaMacP = Packet;
+ CsmaMacP = SubPacket;
CsmaMacP = PacketSend;
CsmaMacP = PacketReceive;
CsmaMacP.ChannelMonitor -> Cca.ChannelMonitor;
CsmaMacP.ChannelMonitorData -> Cca.ChannelMonitorData;
CsmaMacP.ChannelMonitorControl -> Cca.ChannelMonitorControl;
+ CsmaMacP.RssiAdcResource -> Cca.RssiAdcResource;
+
+ components ActiveMessageAddressC;
+ CsmaMacP.amAddress -> ActiveMessageAddressC;
+
CsmaMacP.Random -> RandomLfsrC;
+ CsmaMacP.RadioResourceRequested -> Tda5250RadioC.ResourceRequested;
+
CsmaMacP.Timer -> Timer;
+#ifdef MAC_DEBUG
CsmaMacP.Led0 -> PlatformLedsC.Led0;
CsmaMacP.Led1 -> PlatformLedsC.Led1;
CsmaMacP.Led2 -> PlatformLedsC.Led2;
CsmaMacP.Led3 -> PlatformLedsC.Led3;
+#endif
}
*/
+
#include "radiopacketfunctions.h"
#include "flagfunctions.h"
+#include "PacketAck.h"
/**
* An implementation of a Csma Mac.
* @author: Kevin Klues (klues@tkn.tu-berlin.de)
* @author Philipp Huppertz (huppertz@tkn.tu-berlin.de)
*/
+
+// #define MACM_DEBUG // debug...
module CsmaMacP {
provides {
interface Init;
interface SplitControl;
interface MacSend;
interface MacReceive;
+ interface Packet;
}
uses {
interface StdControl as CcaStdControl;
interface PhySend as PacketSend;
interface PhyReceive as PacketReceive;
+ interface RadioTimeStamping;
interface Tda5250Control as RadioModes;
+ interface ResourceRequested as RadioResourceRequested;
interface UartPhyControl;
-
+ interface Packet as SubPacket;
+
interface ChannelMonitor;
interface ChannelMonitorControl;
interface ChannelMonitorData;
+ interface Resource as RssiAdcResource;
interface Random;
interface Alarm<T32khz, uint16_t> as Timer;
+ async command am_addr_t amAddress();
+#ifdef MACM_DEBUG
interface GeneralIO as Led0;
interface GeneralIO as Led1;
interface GeneralIO as Led2;
interface GeneralIO as Led3;
+#endif
}
}
implementation
{
-#define CSMA_ACK 100
-#define BYTE_TIME 17
-// #define MACM_DEBUG // debug...
-#define MAX_LONG_RETRY 3 // Missing acks, or short retry limit hits -> increase long retry
-#define MAX_SHORT_RETRY 5 // busy channel -> increase short retry
-#define DIFS 165 // 5ms to get an ACK started
-#define ACK_TIMEOUT 20*BYTE_TIME
-#define MIN_BACKOFF_MASK 0x7F // roughly 4ms for Rx/Tx turnaround defines this value
-#define CHECK_RX_LIVENESS_INTERVALL 165
+
+ enum {
+ BYTE_TIME=13, // byte at 38400 kBit/s, 4b6b encoded
+ PREAMBLE_BYTE_TIME=9, // byte at 38400 kBit/s, no coding
+ PHY_HEADER_TIME=35, // 4 Phy Preamble at 38400
+ SUB_HEADER_TIME=PHY_HEADER_TIME + sizeof(tda5250_header_t)*BYTE_TIME,
+ SUB_FOOTER_TIME=2*BYTE_TIME, // 2 bytes crc 38400 kBit/s with 4b6b encoding
+ MAXTIMERVALUE=0xFFFF, // helps to compute backoff
+ DATA_DETECT_TIME=17,
+ RX_SETUP_TIME=111, // time to set up receiver
+ TX_SETUP_TIME=69, // time to set up transmitter
+ ADDED_DELAY = 30,
+ RX_ACK_TIMEOUT=RX_SETUP_TIME + PHY_HEADER_TIME + 4 + 3*ADDED_DELAY,
+ TX_GAP_TIME=RX_ACK_TIMEOUT + TX_SETUP_TIME + 11,
+ MIN_BACKOFF_MASK=0x3F, // about txrx_turnaround time
+ MAX_SHORT_RETRY=7,
+ MAX_LONG_RETRY=4,
+ MIN_PREAMBLE_BYTES=2,
+ TOKEN_ACK_FLAG = 64,
+ TOKEN_ACK_MASK = 0x3f,
+ INVALID_SNR = 0xffff,
+ MSG_TABLE_ENTRIES=5,
+ MAX_AGE=2*MAX_LONG_RETRY*MAX_SHORT_RETRY,
+ };
/**************** Module Global Variables *****************/
/* state vars & defs */
typedef enum {
- SW_CCA, // switch to CCA
- CCA, // clear channel assessment
+ CCA, // clear channel assessment
+ CCA_ACK,
SW_RX, // switch to receive
RX, // rx mode done, listening & waiting for packet
SW_RX_ACK,
RX_ACK,
+ RX_ACK_P,
RX_P,
SW_TX,
TX,
/* flags */
typedef enum {
RSSI_STABLE = 1,
- BUSY_DETECTED_VIA_RSSI = 2,
- CHECK_RX_LIVENESS = 4,
- DIFS_TIMER_FIRED = 8
+ RESUME_BACKOFF = 2,
+ CANCEL_SEND = 4,
+ CCA_PENDING = 8
} flags_t;
/* Packet vars */
message_t ackMsg;
uint8_t txLen;
- int16_t rssiValue;
uint8_t shortRetryCounter;
- uint8_t longRetryCounter;
+ uint8_t longRetryCounter;
+ unsigned checkCounter;
+
macState_t macState;
uint8_t flags;
-
+ uint8_t seqNo;
+
uint16_t slotMask;
+ uint16_t restLaufzeit;
+
+ /* duplicate suppression */
+ typedef struct knownMessage_t {
+ am_addr_t src;
+ uint8_t token;
+ uint8_t age;
+ } knownMessage_t;
+ knownMessage_t knownMsgTable[MSG_TABLE_ENTRIES];
+
+ task void ageMsgsTask() {
+ unsigned i;
+ atomic {
+ for(i = 0; i < MSG_TABLE_ENTRIES; i++) {
+ if(knownMsgTable[i].age <= MAX_AGE) ++knownMsgTable[i].age;
+ }
+ }
+ }
+
/****** debug vars & defs & functions ***********************/
#ifdef MACM_DEBUG
-#define HISTORY_ENTRIES 40
+#define HISTORY_ENTRIES 100
typedef struct {
int index;
macState_t state;
void signalMacState() {
#ifdef MACM_DEBUG
-// (macState & 1) ? call Led0.set() : call Led0.clr();
-// (macState & 2) ? call Led1.set() : call Led1.clr();
-// (macState & 4) ? call Led2.set() : call Led2.clr();
-// (macState & 8) ? call Led3.set() : call Led3.clr();
+/*
+ (macState & 1) ? call Led0.set() : call Led0.clr();
+ (macState & 2) ? call Led1.set() : call Led1.clr();
+ (macState & 4) ? call Led2.set() : call Led2.clr();
+ (macState & 8) ? call Led3.set() : call Led3.clr();
+*/
#endif
}
task void SetRxModeTask();
task void SetTxModeTask();
+
+ task void ReleaseAdcTask() {
+ macState_t ms;
+ atomic ms = macState;
+ if(isFlagSet(&flags, CCA_PENDING)) {
+ post ReleaseAdcTask();
+ }
+ else {
+ if((ms > CCA) && (ms != INIT) && call RssiAdcResource.isOwner()) {
+ call RssiAdcResource.release();
+ }
+ }
+ }
void setRxMode();
void setTxMode();
+ void requestAdc() {
+ if(macState != INIT) {
+ call RssiAdcResource.immediateRequest();
+ }
+ else {
+ call RssiAdcResource.request();
+ }
+ }
+
void setRxMode() {
if(call RadioModes.RxMode() == FAIL) {
post SetRxModeTask();
}
+ if(macState == INIT) {
+ requestAdc();
+ } else {
+ post ReleaseAdcTask();
+ }
}
task void SetRxModeTask() {
atomic {
if((macState == SW_RX) ||
(macState == SW_RX_ACK) ||
- (macState == SW_CCA) ||
(macState == INIT)) setRxMode();
}
}
void setTxMode() {
clearFlag(&flags, RSSI_STABLE);
- clearFlag(&flags, BUSY_DETECTED_VIA_RSSI);
if(call RadioModes.TxMode() == FAIL) {
post SetTxModeTask();
}
+ post ReleaseAdcTask();
}
task void SetTxModeTask() {
}
/**************** Helper functions ********/
- uint16_t backoff() {
- uint16_t mask = slotMask;
+ uint16_t backoff(uint8_t counter) {
+ uint16_t mask = MIN_BACKOFF_MASK;
unsigned i;
- for(i = 0; i < longRetryCounter; i++) {
+ for(i = 0; i < counter; i++) {
mask = (mask << 1) + 1;
}
return (call Random.rand16() & mask);
}
+
+ void interruptBackoffTimer() {
+ uint16_t now;
+ if(call Timer.isRunning()) {
+ restLaufzeit = call Timer.getAlarm();
+ call Timer.stop();
+ now = call Timer.getNow();
+ if(restLaufzeit >= now) {
+ restLaufzeit = restLaufzeit - now;
+ }
+ else {
+ restLaufzeit += MAXTIMERVALUE - now;
+ }
+ setFlag(&flags, RESUME_BACKOFF);
+ }
+ }
void signalSendDone(error_t error) {
message_t *m;
+ error_t e = error;
atomic {
m = txBufPtr;
txBufPtr = 0;
txLen = 0;
longRetryCounter = 0;
shortRetryCounter = 0;
+ if(isFlagSet(&flags, CANCEL_SEND)) {
+ e = ECANCEL;
+ }
+ clearFlag(&flags, CANCEL_SEND);
+ }
+ signal MacSend.sendDone(m, e);
+ }
+
+ void updateLongRetryCounters() {
+ longRetryCounter++;
+ shortRetryCounter = 1;
+ if(longRetryCounter > MAX_LONG_RETRY) {
+ storeOldState(13);
+ getMetadata(txBufPtr)->ack = WAS_NOT_ACKED;
+ signalSendDone(FAIL);
}
- signal MacSend.sendDone(m, error);
}
void updateRetryCounters() {
longRetryCounter++;
shortRetryCounter = 1;
if(longRetryCounter > MAX_LONG_RETRY) {
+ getMetadata(txBufPtr)->ack = WAS_NOT_ACKED;
signalSendDone(FAIL);
}
}
}
+ void computeBackoff() {
+ if(!isFlagSet(&flags, RESUME_BACKOFF)) {
+ setFlag(&flags, RESUME_BACKOFF);
+ restLaufzeit = backoff(longRetryCounter);
+ updateRetryCounters();
+ storeOldState(92);
+ }
+ }
+
+ bool isNewMsg(message_t* msg) {
+ uint8_t i;
+ for(i=0; i < MSG_TABLE_ENTRIES; i++) {
+ if((getHeader(msg)->src == knownMsgTable[i].src) &&
+ (((getHeader(msg)->token) & TOKEN_ACK_MASK) == knownMsgTable[i].token) &&
+ (knownMsgTable[i].age < MAX_AGE)) {
+ knownMsgTable[i].age = 0;
+ return FALSE;
+ }
+ }
+ return TRUE;
+ }
+
+ unsigned findOldest() {
+ unsigned i;
+ unsigned oldIndex = 0;
+ unsigned age = knownMsgTable[oldIndex].age;
+ for(i = 1; i < MSG_TABLE_ENTRIES; i++) {
+ if(age < knownMsgTable[i].age) {
+ oldIndex = i;
+ age = knownMsgTable[i].age;
+ }
+ }
+ return oldIndex;
+ }
+
+ void rememberMsg(message_t* msg) {
+ unsigned oldest = findOldest();
+ knownMsgTable[oldest].src = getHeader(msg)->src;
+ knownMsgTable[oldest].token = (getHeader(msg)->token) & TOKEN_ACK_MASK;
+ knownMsgTable[oldest].age = 0;
+ }
+
void checkSend() {
if((txBufPtr != NULL) && (macState == RX) && (!call Timer.isRunning())) {
- clearFlag(&flags, CHECK_RX_LIVENESS);
- clearFlag(&flags, DIFS_TIMER_FIRED);
- /* if(!call UartPhyControl.isBusy()) { */
- if(isFlagSet(&flags, RSSI_STABLE)) {
- macState = CCA;
- signalMacState();
- call Timer.start(DIFS);
- call ChannelMonitor.start();
- storeOldState(130);
- } else {
- macState = SW_CCA;
- signalMacState();
- storeOldState(131);
- }
- /* }
- else {
- storeOldState(132);
- updateRetryCounters();
- setFlag(&flags, CHECK_RX_LIVENESS);
- call Timer.start(backoff());
+ macState = CCA;
+ signalMacState();
+ checkCounter = 0;
+ requestAdc();
+ call Timer.start(DATA_DETECT_TIME);
+ storeOldState(170);
+ }
+ else {
+ storeOldState(171);
+ post ReleaseAdcTask();
+ }
+ }
+
+ bool needsAckRx(message_t* msg) {
+ bool rVal = FALSE;
+ uint8_t token;
+ if(getHeader(msg)->dest < AM_BROADCAST_ADDR) {
+ token = getHeader(msg)->token;
+ if(isFlagSet(&token, ACK_REQUESTED)) rVal = TRUE;
+ }
+ return rVal;
+ }
+
+ bool needsAckTx(message_t* msg) {
+ bool rVal = FALSE;
+ if(getHeader(msg)->dest < AM_BROADCAST_ADDR) {
+ if((getMetadata(msg)->ack == ACK_REQUESTED) || (getMetadata(msg)->ack != NO_ACK_REQUESTED)) {
+ rVal = TRUE;
}
- */
- }
+ }
+ return rVal;
+ }
+
+ void prepareAck(message_t* msg) {
+ uint8_t rToken = getHeader(msg)->token & TOKEN_ACK_MASK;
+ setFlag(&rToken, TOKEN_ACK_FLAG);
+ getHeader(&ackMsg)->token = rToken;
+ getHeader(&ackMsg)->src = call amAddress();
+ getHeader(&ackMsg)->dest = getHeader(msg)->src;
+ getHeader(&ackMsg)->type = getHeader(msg)->type;
+ }
+
+ bool msgIsForMe(message_t* msg) {
+ if(getHeader(msg)->dest == AM_BROADCAST_ADDR) return TRUE;
+ if(getHeader(msg)->dest == call amAddress()) return TRUE;
+ return FALSE;
+ }
+
+ bool ackIsForMe(message_t* msg) {
+ uint8_t localToken = seqNo;
+ setFlag(&localToken, TOKEN_ACK_FLAG);
+ if((getHeader(msg)->dest == call amAddress()) && (localToken == getHeader(msg)->token)) return TRUE;
+ return FALSE;
}
- bool needsAck(message_t* msg) {
- return FALSE; // (getHeader(msg)->addr != AM_BROADCAST_ADDR);
+ bool isControl(message_t* m) {
+ uint8_t token = getHeader(m)->token;
+ return isFlagSet(&token, TOKEN_ACK_FLAG);
}
/**************** Init ************************/
command error_t Init.init(){
+ unsigned i;
atomic {
txBufPtr = NULL;
macState = INIT;
longRetryCounter = 0;
flags = 0;
slotMask = MIN_BACKOFF_MASK;
+ for(i = 0; i < MSG_TABLE_ENTRIES; i++) {
+ knownMsgTable[i].age = MAX_AGE;
+ }
#ifdef MACM_DEBUG
histIndex = 0;
#endif
/**************** SplitControl *****************/
task void StartDoneTask() {
+ atomic {
+ macState = RX;
+ signalMacState();
+ call UartPhyControl.setNumPreambles(MIN_PREAMBLE_BYTES);
+ }
+ post ReleaseAdcTask();
signal SplitControl.startDone(SUCCESS);
}
return SUCCESS;
}
+ /****** Packet interface ********************/
+ command void Packet.clear(message_t* msg) {
+ call SubPacket.clear(msg);
+ }
+
+ command uint8_t Packet.payloadLength(message_t* msg) {
+ return call SubPacket.payloadLength(msg);
+ }
+
+ command void Packet.setPayloadLength(message_t* msg, uint8_t len) {
+ call SubPacket.setPayloadLength(msg,len);
+ }
+
+ command uint8_t Packet.maxPayloadLength() {
+ return call SubPacket.maxPayloadLength();
+ }
+
+ command void* Packet.getPayload(message_t* msg, uint8_t* len) {
+ return call SubPacket.getPayload(msg, len);
+ }
+
/****** Radio(Mode) events *************************/
async event void RadioModes.RssiStable() {
atomic {
setFlag(&flags, RSSI_STABLE);
- if(macState == SW_CCA) {
- storeOldState(10);
- macState = CCA;
- signalMacState();
- call Timer.start(DIFS);
- call ChannelMonitor.start();
- } else if(macState == INIT) {
+ if(macState == INIT) {
storeOldState(11);
- call ChannelMonitorControl.updateNoiseFloor();
- } else {
- storeOldState(13);
+ if(call RssiAdcResource.isOwner()) {
+ call ChannelMonitorControl.updateNoiseFloor();
+ }
+ }
+ else {
+ storeOldState(12);
}
}
}
storeOldState(21);
macState = RX;
signalMacState();
- call Timer.start(backoff());
+ if(isFlagSet(&flags, RESUME_BACKOFF)) {
+ clearFlag(&flags, RESUME_BACKOFF);
+ call Timer.start(restLaufzeit);
+ } else {
+ call Timer.start(backoff(longRetryCounter));
+ }
}
else if(macState == SW_RX_ACK) {
storeOldState(22);
macState = RX_ACK;
signalMacState();
- call Timer.start(ACK_TIMEOUT);
- }
- else if(macState == SW_CCA) {
- storeOldState(23);
}
else if(macState == INIT) {
storeOldState(24);
}
}
}
+ else if(macState == SW_TX_ACK) {
+ macState = TX_ACK;
+ signalMacState();
+ if(call PacketSend.send(&ackMsg, 0) == SUCCESS) {
+ storeOldState(53);
+ } else {
+ storeOldState(54);
+ signalFailure(6);
+ }
+ }
else {
storeOldState(33);
signalFailure(3);
async command error_t MacSend.send(message_t* msg, uint8_t len) {
error_t err = SUCCESS;
atomic {
- if((shortRetryCounter == 0) && (txBufPtr == NULL)) {
- storeOldState(40);
+ if((shortRetryCounter == 0) && (txBufPtr == NULL) && (macState != INIT)) {
+ storeOldState(40);
shortRetryCounter = 1;
+ longRetryCounter = 1;
txBufPtr = msg;
txLen = len;
- if((macState != RX_P) && (macState != RX_ACK)) checkSend();
+ seqNo++;
+ if(seqNo >= TOKEN_ACK_FLAG) seqNo = 1;
+ getHeader(msg)->token = seqNo;
+ if(needsAckTx(msg)) getHeader(msg)->token |= ACK_REQUESTED;
+ if(macState != RX_P) checkSend();
}
else {
storeOldState(41);
/****** PacketSerializer events **********************/
async event void PacketReceive.receiveDetected() {
- if(macState <= RX_ACK) {
+ if(macState <= RX_ACK) {
storeOldState(60);
- rssiValue = 0xFFFF;
- call Timer.stop();
- clearFlag(&flags, CHECK_RX_LIVENESS);
- if(isFlagSet(&flags, BUSY_DETECTED_VIA_RSSI)) call ChannelMonitor.rxSuccess();
- call ChannelMonitorData.getSnr();
+ interruptBackoffTimer();
+ if(macState == CCA) computeBackoff();
}
if(macState <= RX) {
- storeOldState(61);
+ post ReleaseAdcTask();
+ storeOldState(61);
macState = RX_P;
signalMacState();
}
else if(macState <= RX_ACK) {
+ post ReleaseAdcTask();
storeOldState(62);
- macState = RX_ACK;
+ macState = RX_ACK_P;
signalMacState();
}
else if(macState == INIT) {
storeOldState(63);
}
else {
- storeOldState(64);
- signalFailure(4);
+ post ReleaseAdcTask();
+ storeOldState(64);
+ signalFailure(4);
}
}
async event message_t* PacketReceive.receiveDone(message_t* msg, void* payload, uint8_t len, error_t error) {
message_t* m = msg;
+ bool isCnt;
+ macState_t action = RX;
if(macState == RX_P) {
- storeOldState(70);
- if (error == SUCCESS) {
- storeOldState(71);
- (getMetadata(msg))->strength = rssiValue;
- m = signal MacReceive.receiveDone(msg);
+ if(error == SUCCESS) {
+ post ageMsgsTask();
+ storeOldState(82);
+ isCnt = isControl(msg);
+ if(msgIsForMe(msg)) {
+ if(!isCnt) {
+ (getMetadata(m))->strength = 10;
+ if(isNewMsg(m)) {
+ m = signal MacReceive.receiveDone(msg);
+ rememberMsg(m);
+ }
+ if(needsAckRx(msg)) {
+ storeOldState(87);
+ action = CCA_ACK;
+ } else {
+ storeOldState(88);
+ }
+ }
+ else {
+ storeOldState(89);
+ }
+ }
+ else {
+ storeOldState(90);
+ }
+ }
+ else {
+ storeOldState(91);
}
- macState = RX;
- signalMacState();
- call Timer.start(backoff());
}
- else if(macState == RX_ACK) {
- storeOldState(72);
- if(txBufPtr == NULL) signalFailure(5);
- if((error == SUCCESS) &&
- getFooter(msg)->crc &&
- (getHeader(msg)->type == CSMA_ACK) &&
- (*((uint16_t*)(msg->data)) == TOS_NODE_ID))
- {
- storeOldState(73);
- getMetadata(txBufPtr)->ack = 1;
- signalSendDone(SUCCESS);
+ else if(macState == RX_ACK_P) {
+ if(error == SUCCESS) {
+ if(ackIsForMe(msg)) {
+ storeOldState(92);
+ (getMetadata(txBufPtr))->strength = 10;
+ (getMetadata(txBufPtr))->ack = WAS_ACKED;
+ signalSendDone(SUCCESS);
+ }
+ else {
+ storeOldState(93);
+ updateLongRetryCounters();
+ }
}
else {
- storeOldState(74);
- updateRetryCounters();
+ if(call Timer.isRunning()) {
+ storeOldState(94);
+ action = RX_ACK;
+ }
+ else {
+ storeOldState(95);
+ if(needsAckTx(txBufPtr)) {
+ updateLongRetryCounters();
+ }
+ else {
+ signalSendDone(SUCCESS);
+ }
+ }
}
+ }
+ else if(macState == INIT) {
+ action = INIT;
+ }
+ if(action == CCA_ACK) {
+ prepareAck(msg);
+ macState = CCA_ACK;
+ signalMacState();
+ call Timer.start(RX_SETUP_TIME - TX_SETUP_TIME + ADDED_DELAY);
+ }
+ else if(action == RX_ACK) {
+ macState = RX_ACK;
+ signalMacState();
+ }
+ else if(action == RX) {
macState = RX;
signalMacState();
- call Timer.start(backoff());
- } else {
- storeOldState(76);
+ if(isFlagSet(&flags, RESUME_BACKOFF)) {
+ clearFlag(&flags, RESUME_BACKOFF);
+ call Timer.start(restLaufzeit);
+ }
+ else {
+ call Timer.start(backoff(longRetryCounter));
+ }
+ }
+ else if(action == TX) {
+ macState = SW_TX;
+ signalMacState();
+ setTxMode();
}
- return m;
+ else if(action == INIT) {
+
+ }
+ else {
+ storeOldState(94);
+ signalFailure(11);
+ }
+ return m;
}
async event void PacketSend.sendDone(message_t* msg, error_t error) {
if(macState == TX) {
- if(msg != txBufPtr) signalFailure(7);
- if(needsAck(msg)) {
- if(error == SUCCESS) {
- storeOldState(80);
- macState = SW_RX_ACK;
- signalMacState();
- } else {
- storeOldState(81);
- macState = SW_RX;
- signalMacState();
- }
+ if(msg != txBufPtr) signalFailure(12);
+ if(needsAckTx(msg)) {
+ storeOldState(97);
+ macState = SW_RX_ACK;
+ signalMacState();
+ call Timer.start(RX_ACK_TIMEOUT);
} else {
+ storeOldState(99);
+ signalSendDone(error);
macState = SW_RX;
signalMacState();
- signalSendDone(error);
}
+ setRxMode();
}
else if(macState == TX_ACK) {
- storeOldState(83);
- if(msg != &ackMsg) signalFailure(8);
macState = SW_RX;
signalMacState();
+ setRxMode();
}
else {
- storeOldState(84);
- signalFailure(9);
+ signalFailure(13);
}
- setRxMode();
}
/****** Timer ******************************/
+ void checkOnBusy() {
+ if(macState == CCA) {
+ computeBackoff();
+ macState = RX;
+ requestAdc();
+ storeOldState(150);
+ signalMacState();
+ if(!call Timer.isRunning()) call Timer.start(TX_GAP_TIME >> 1);
+ } else if(macState == RX) {
+ if(!call Timer.isRunning()) call Timer.start(TX_GAP_TIME + backoff(0));
+ }
+ }
+
+ void checkOnIdle() {
+ if(macState == RX) {
+ checkSend();
+ }
+ else if(macState == CCA) {
+ checkCounter++;
+ if(checkCounter < 3) {
+ storeOldState(158);
+ call Timer.start((TX_GAP_TIME + backoff(0))>>1);
+ requestAdc();
+ }
+ else {
+ call Timer.stop();
+ storeOldState(159);
+ macState = SW_TX;
+ signalMacState();
+ setTxMode();
+ }
+ }
+ }
async event void Timer.fired() {
- if(macState == RX) {
- storeOldState(90);
- if(isFlagSet(&flags, CHECK_RX_LIVENESS)) {
- /* if(call UartPhyControl.isBusy()) {
- call Timer.start(CHECK_RX_LIVENESS_INTERVALL);
+ storeOldState(100);
+ if(macState == CCA) {
+ if((!call RssiAdcResource.isOwner()) || (call ChannelMonitor.start() != SUCCESS)) {
+ if(call UartPhyControl.isBusy()) {
+ storeOldState(101);
+ checkOnBusy();
}
else {
- */
- call ChannelMonitor.start();
- /*} */
+ storeOldState(102);
+ checkOnIdle();
+ }
} else {
- checkSend();
+ setFlag(&flags, CCA_PENDING);
}
}
else if(macState == RX_ACK) {
- storeOldState(91);
- updateRetryCounters();
- macState = RX;
+ if(needsAckTx(txBufPtr)) {
+ storeOldState(103);
+ updateLongRetryCounters();
+ macState = RX;
+ call Timer.start(backoff(longRetryCounter));
+ }
+ else {
+ storeOldState(104);
+ signalFailure(7);
+ }
+ }
+ else if(macState == CCA_ACK) {
+ storeOldState(160);
+ macState = SW_TX_ACK;
signalMacState();
- call Timer.start(backoff());
+ setTxMode();
}
- else if(macState == CCA) {
- storeOldState(92);
- setFlag(&flags, DIFS_TIMER_FIRED);
- call ChannelMonitor.start();
+ else if((macState == RX_ACK_P) || (macState == RX_P)) {
+ storeOldState(108);
+ }
+ else if(macState == INIT) {
+ storeOldState(109);
+ post StartDoneTask();
}
else {
- storeOldState(93);
- signalFailure(10);
+ storeOldState(110);
+ checkSend();
}
}
/****** ChannelMonitor events *********************/
async event void ChannelMonitor.channelBusy() {
- atomic {
- if(macState == CCA) {
- storeOldState(100);
- macState = RX;
- signalMacState();
- setFlag(&flags, BUSY_DETECTED_VIA_RSSI);
- updateRetryCounters();
- call Timer.start(backoff());
- }
- else if(macState == RX_P) {
- storeOldState(101);
- setFlag(&flags, BUSY_DETECTED_VIA_RSSI);
- }
- else if((macState == RX) && (isFlagSet(&flags, CHECK_RX_LIVENESS))) {
- storeOldState(102);
- call Timer.start(CHECK_RX_LIVENESS_INTERVALL);
- }
- }
+ clearFlag(&flags, CCA_PENDING);
+ storeOldState(120);
+ checkOnBusy();
}
async event void ChannelMonitor.channelIdle() {
- storeOldState(110);
- if((macState == RX) && (isFlagSet(&flags, CHECK_RX_LIVENESS))) {
- storeOldState(111);
- clearFlag(&flags, CHECK_RX_LIVENESS);
- call Timer.start(backoff());
- }
- else if(macState == CCA) {
- if(isFlagSet(&flags, DIFS_TIMER_FIRED)) {
- clearFlag(&flags, DIFS_TIMER_FIRED);
- storeOldState(112);
- macState = SW_TX;
- signalMacState();
- setTxMode();
- }
- }
+ clearFlag(&flags, CCA_PENDING);
+ storeOldState(121);
+ checkOnIdle();
}
event void ChannelMonitorControl.updateNoiseFloorDone() {
if(macState == INIT) {
- storeOldState(120);
- macState = RX;
- signalMacState();
+ storeOldState(122);
post StartDoneTask();
} else {
- storeOldState(121);
+ storeOldState(124);
signalFailure(11);
}
}
/***** ChannelMonitorData events ******************/
async event void ChannelMonitorData.getSnrDone(int16_t data) {
- atomic if(macState == RX_P) rssiValue = data;
}
async event void RadioModes.SleepModeDone() {}
async event void RadioModes.SelfPollingModeDone() {}
async event void RadioModes.PWDDDInterrupt() {}
+
+ /***** abused TimeStamping events **************************/
+ async event void RadioTimeStamping.receivedSFD( uint16_t time ) {
+ if(macState == RX_P) call ChannelMonitor.rxSuccess();
+ }
+
+ async event void RadioTimeStamping.transmittedSFD( uint16_t time, message_t* p_msg ) {}
+
+ /***** Rssi Resource events ******************/
+ event void RssiAdcResource.granted() {
+ macState_t ms;
+ atomic ms = macState;
+ if((ms == INIT) && isFlagSet(&flags, RSSI_STABLE)) {
+ storeOldState(145);
+ call ChannelMonitorControl.updateNoiseFloor();
+ }
+ else {
+ storeOldState(146);
+ call RssiAdcResource.release();
+ }
+ }
+
+ /***** RadioData Resource events **************/
+ async event void RadioResourceRequested.requested() {
+ atomic {
+ /* This gives other devices the chance to get the Resource
+ because RxMode implies a new arbitration round. */
+ if (macState == RX) setRxMode();
+ }
+ }
+
+ // we don't care about urgent Resource requestes
+ async event void RadioResourceRequested.immediateRequested() {}
}
+
#define TDA5250_MESSAGE_H
#include "AM.h"
+#include "PacketAck.h"
typedef nx_struct tda5250_header_t {
- nx_am_addr_t addr;
- nx_uint8_t length;
- nx_am_group_t group;
- nx_am_id_t type;
+ nx_uint8_t length;
+ nx_am_addr_t src;
+ nx_am_addr_t dest;
+ nx_am_id_t type;
+ nx_uint8_t token;
} tda5250_header_t;
typedef nx_struct tda5250_footer_t {
typedef nx_struct tda5250_metadata_t {
nx_uint16_t strength;
nx_uint8_t ack;
- nx_uint16_t time;
+ /* local time when message was generated */
+ nx_uint32_t time;
nx_uint8_t sendSecurityMode;
nx_uint8_t receiveSecurityMode;
} tda5250_metadata_t;
uint8_t mConfigRegVal = 0;
error_t mHplError;
+ task void complete_Alert() {
+ signal HalTMP175Advanced.alertThreshold();
+ }
static error_t setCfg(uint8_t nextState, uint32_t val) {
error_t error;
-
mState = nextState;
error = call HplTMP175.setConfigReg(val);
}
return error;
-
}
static error_t setThresh(uint8_t nextState, uint32_t val) {
error_t error;
-
mState = nextState;
if(mState == STATE_SET_TLOW)
if (error) {
call TMP175Resource.release();
}
- else {
- mConfigRegVal = val;
- }
return error;
-
}
command error_t HalTMP175Advanced.setThermostatMode(bool useInt) {
}
newRegVal = (polarity) ? (mConfigRegVal | TMP175_CFG_POL) : (mConfigRegVal & ~TMP175_CFG_POL);
- error = setCfg(STATE_SET_MODE, newRegVal);
+ error = setCfg(STATE_SET_POLARITY, newRegVal);
return error;
}
if (error) {
return error;
}
-
- //error = call HplTMP175.setTLowReg(val << 4);
+
error = setThresh(STATE_SET_TLOW, val);
if (error) {
return error;
}
- //error = call HplTMP175.setTHighReg(val << 4);
error = setThresh(STATE_SET_THIGH, val);
if (error) {
call TMP175Resource.release();
switch (mState) {
case STATE_SET_MODE:
+ mState = STATE_NONE;
signal HalTMP175Advanced.setThermostatModeDone(lasterror);
break;
case STATE_SET_POLARITY:
+ mState = STATE_NONE;
signal HalTMP175Advanced.setPolarityDone(lasterror);
break;
case STATE_SET_FQ:
+ mState = STATE_NONE;
signal HalTMP175Advanced.setFaultQueueDone(lasterror);
break;
case STATE_SET_RES:
+ mState = STATE_NONE;
signal HalTMP175Advanced.setResolutionDone(lasterror);
break;
default:
break;
}
- mState = STATE_NONE;
+ //mState = STATE_NONE;
return;
}
call TMP175Resource.release();
switch (mState) {
case STATE_SET_TLOW:
+ mState = STATE_NONE;
signal HalTMP175Advanced.setTLowDone(lasterror);
break;
case STATE_SET_THIGH:
+ mState = STATE_NONE;
signal HalTMP175Advanced.setTHighDone(lasterror);
break;
default:
+ mState = STATE_NONE;
break;
}
- mState = STATE_NONE;
+ //mState = STATE_NONE;
}
event void TMP175Resource.granted() {
}
async event void HplTMP175.alertThreshold() {
- // if in interrupt mode, need to clear interrupt, otherwise, just signal
- if(mConfigRegVal & TMP175_CFG_POL) {
- // this will clear the interrupt, just ignore the result
- call HplTMP175.measureTemperature();
- }
+ post complete_Alert();
}
async event void HplTMP175.measureTemperatureDone(error_t error, uint16_t val) {
async event void HplTMP175.measureTemperatureDone(error_t tmp175_error, uint16_t val) {
call TMP175Resource.release();
- signal Temperature.readDone(tmp175_error,val);
+ signal Temperature.readDone(tmp175_error,(val >> 4));
return;
}
uint8_t mConfigRegVal;
norace error_t mSSError;
- static error_t doSetReg(uint8_t nextState, uint8_t reg, uint16_t val) {
+ static error_t doSetReg(uint8_t nextState, uint8_t reg, uint8_t val) {
error_t error = SUCCESS;
atomic {
command error_t Init.init() {
// careful! this can be changed via polarity I believe
call InterruptPin.makeInput();
- call AlertInterrupt.enableFallingEdge();
+ call AlertInterrupt.enableRisingEdge();
mfPtrReset = FALSE;
mConfigRegVal = 0;
mState = STATE_STOPPED;
if(status != SUCCESS)
return status;
state = S_PERSIST;
+ iControlRegisterShadow &= ~TSL256X_INTERRUPT_PERSIST(0xF);
iControlRegisterShadow |= TSL256X_INTERRUPT_PERSIST(val);
call HplTSL256x.setINTERRUPT(iControlRegisterShadow);
error_t status;
if(state != S_IDLE)
return FAIL;
- status = call Resource.immediateRequest();
- if(status != SUCCESS)
- return status;
+
state = S_ENALERT;
iControlRegisterShadow &= ~TSL256X_INTERRUPT_INTR(3); // strip off interrupt select
if(enable)
iControlRegisterShadow |= TSL256X_INTERRUPT_INTR(1);
-
- call HplTSL256x.setINTERRUPT(iControlRegisterShadow);
+
+ status = call Resource.immediateRequest();
+ if(status != SUCCESS) {
+ status = call Resource.request();
+ return status;
+ }
+ else {
+ call HplTSL256x.setINTERRUPT(iControlRegisterShadow);
+ }
return SUCCESS;
}
event void Resource.granted() {
- // using immediate requests only
+ // Only use Queued requests for alertEnable
+ if (state == S_ENALERT) {
+ call HplTSL256x.setINTERRUPT(iControlRegisterShadow);
+ }
+ return;
}
async event void HplTSL256x.setTIMINGDone(error_t error) {
uses interface I2CPacket<TI2CBasicAddr>;
uses interface GpioInterrupt as InterruptAlert;
+ uses interface Leds;
uses interface GeneralIO as InterruptPin;
}
uint8_t mState;
norace error_t mSSError;
- static error_t doWriteReg(uint8_t nextState, uint8_t reg, uint8_t val) {
+ static error_t doWriteReg(uint8_t nextState, uint8_t reg, uint16_t val, uint8_t size) {
error_t error = SUCCESS;
atomic {
- if (mState == STATE_IDLE) {
+ if ((mState == STATE_IDLE) || (mState == STATE_STARTING)) {
mState = nextState;
}
else {
if (error)
return error;
- mI2CBuffer[0] = (TSL256X_COMMAND_CMD | TSL256X_COMMAND_ADDRESS(reg));
- mI2CBuffer[1] = val;
+ mI2CBuffer[0] = (TSL256X_COMMAND_CMD | reg);
+ mI2CBuffer[1] = (uint8_t)(val & 0xFF);
+ mI2CBuffer[2] = (uint8_t)((val >> 8) & 0xFF);
- error = call I2CPacket.write(I2C_START | I2C_STOP,devAddr,2,mI2CBuffer);
+ error = call I2CPacket.write(I2C_START | I2C_STOP,devAddr,(size + 1),mI2CBuffer);
if (error)
atomic mState = STATE_IDLE;
if (error)
return error;
- mI2CBuffer[0] = (TSL256X_COMMAND_CMD | TSL256X_COMMAND_ADDRESS(reg));
+ mI2CBuffer[0] = (TSL256X_COMMAND_CMD | reg );
error = call I2CPacket.write(I2C_START,devAddr,1,mI2CBuffer);
}
task void StartDone() {
- atomic mState = STATE_IDLE;
signal SplitControl.startDone(mSSError);
return;
}
task void StopDone() {
- atomic mState = STATE_STOPPED;
signal SplitControl.stopDone(mSSError);
return;
}
error_t error = SUCCESS;
atomic {
if (mState == STATE_STOPPED) {
- mState = STATE_IDLE;
+ mState = STATE_STARTING;
}
else {
error = EBUSY;
if (error)
return error;
- return doWriteReg(STATE_STARTING,TSL256X_PTR_CONTROL,(TSL256X_CONTROL_POWER_ON));
+ return doWriteReg(STATE_STARTING,(TSL256X_COMMAND_CLEAR | TSL256X_PTR_CONTROL),
+ (TSL256X_CONTROL_POWER_ON),1);
}
command error_t SplitControl.stop() {
- return doWriteReg(STATE_STOPPING,TSL256X_PTR_CONTROL,(TSL256X_CONTROL_POWER_OFF));
+ return doWriteReg(STATE_STOPPING,(TSL256X_COMMAND_CLEAR | TSL256X_PTR_CONTROL),
+ (TSL256X_CONTROL_POWER_OFF),1);
}
-
command error_t HplTSL256x.measureCh0() {
return doReadPrep(STATE_READCH0,TSL256X_PTR_DATA0LOW);
}
command error_t HplTSL256x.setCONTROL(uint8_t val) {
- return doWriteReg(STATE_SETCONTROL,TSL256X_PTR_CONTROL,val);
+ return doWriteReg(STATE_SETCONTROL,TSL256X_PTR_CONTROL,val,1);
}
command error_t HplTSL256x.setTIMING(uint8_t val) {
- return doWriteReg(STATE_SETTIMING,TSL256X_PTR_TIMING,val);
+ return doWriteReg(STATE_SETTIMING,TSL256X_PTR_TIMING,val,1);
}
command error_t HplTSL256x.setTHRESHLOW(uint16_t val) {
- return doWriteReg(STATE_SETLOW,TSL256X_PTR_THRESHLOWLOW,val);
+ // As it turns out, you have to use the SMB Write Word flag to use this command
+ return doWriteReg(STATE_SETLOW,(TSL256X_COMMAND_WORD | TSL256X_PTR_THRESHLOWLOW),val,2);
}
command error_t HplTSL256x.setTHRESHHIGH(uint16_t val) {
- return doWriteReg(STATE_SETHIGH,TSL256X_PTR_THRESHHIGHLOW,val);
+ // As it turns out, you have to use the SMB Write Word flag to use this command
+ return doWriteReg(STATE_SETHIGH,(TSL256X_COMMAND_WORD | TSL256X_PTR_THRESHHIGHLOW),val,2);
}
command error_t HplTSL256x.setINTERRUPT(uint8_t val) {
- return doWriteReg(STATE_SETINTERRUPT,TSL256X_PTR_INTERRUPT,val);
+ return doWriteReg(STATE_SETINTERRUPT,(TSL256X_COMMAND_CLEAR | TSL256X_PTR_INTERRUPT),val,1);
}
command error_t HplTSL256x.getID() {
async event void I2CPacket.writeDone(error_t i2c_error, uint16_t chipAddr, uint8_t len, uint8_t *buf) {
error_t error = i2c_error;
- /*
- if(interruptBit) {
- interruptBit = FALSE;
- return;
- }
- */
+
switch (mState) {
case STATE_STARTING:
mSSError = error;
- //---
- /*
- mState = STATE_CLRINTERRUPTS;
- interruptBit = TRUE;
- clearInterrupt();
- break;
- case STATE_CLRINTERRUPTS:
- mSSError = error;
- */
- //---
mState = STATE_IDLE;
post StartDone();
break;
async event void InterruptAlert.fired() {
// This alert is decoupled from whatever state the TSL2561 is in.
// Upper layers must handle dealing with this alert appropriately.
-
signal HplTSL256x.alertThreshold();
// need to clear interrupt, this is dangerous...
// if you get interrupted while someone is reading...
// ... the I2C bus may become inconsistent?
- clearInterrupt();
+ //clearInterrupt();
return;
}
#include "AM.h"
typedef nx_struct xe1205_header_t {
- nx_am_addr_t addr;
+ nx_am_addr_t dest;
+ nx_am_addr_t source;
nx_am_id_t type;
nx_am_group_t group;
} xe1205_header_t;
command am_addr_t AMPacket.destination(message_t* msg) {
xe1205_header_t* header = getHeader(msg);
- return header->addr;
+ return header->dest;
}
command void AMPacket.setDestination(message_t* msg, am_addr_t addr) {
xe1205_header_t* header = getHeader(msg);
- header->addr = addr;
+ header->dest = addr;
+ }
+
+ command am_addr_t AMPacket.source(message_t* msg) {
+ xe1205_header_t* header = getHeader(msg);
+ return header->source;
+ }
+
+ command void AMPacket.setSource(message_t* msg, am_addr_t addr) {
+ xe1205_header_t* header = getHeader(msg);
+ header->source = addr;
}
command bool AMPacket.isForMe(message_t* msg) {
uint8_t len) {
xe1205_header_t* header = getHeader(msg);
header->type = id;
- header->addr = addr;
+ header->dest = addr;
+ header->source = call AMPacket.address();
header->group = TOS_AM_GROUP;
return call SubSend.send(msg, len);
}
provides interface Send;
provides interface Packet;
provides interface PacketAcknowledgements;
- provides interface SplitControl;
+ provides interface SplitControl @atleastonce();
provides interface Receive;
}
implementation {
Receive = XE1205SendReceiveP;
Packet = XE1205SendReceiveP;
PacketAcknowledgements = XE1205SendReceiveP;
+ SplitControl = XE1205SendReceiveP;
components XE1205PhyC;
XE1205SendReceiveP.XE1205PhyRxTx -> XE1205PhyC;
- SplitControl = XE1205PhyC;
+ XE1205SendReceiveP.PhySplitControl -> XE1205PhyC;
}
provides interface Packet;
provides interface PacketAcknowledgements;
provides interface Receive;
+ provides interface SplitControl @atleastonce();;
+
uses interface XE1205PhyRxTx;
+ uses interface SplitControl as PhySplitControl;
}
implementation {
norace uint8_t txWhiteByte;
-
-
-
uint8_t const pktPreamble[] = {
0x55, 0x55, 0x55,
(data_pattern >> 16) & 0xff, (data_pattern >> 8) & 0xff, data_pattern & 0xff
return call Packet.payloadLength(m);
}
+
+ command error_t SplitControl.start() {
+ error_t err;
+ err = call PhySplitControl.start();
+
+ return err;
+ }
+
+ command error_t SplitControl.stop() {
+ error_t err;
+
+ // One could also argue that this is split phase so should cope and do the right thing.
+ // Or one could argue that whatever the phy is doing underneath just gets interrupted.
+ if (call XE1205PhyRxTx.busy()) return EBUSY;
+
+ err = call PhySplitControl.stop();
+
+ return err;
+
+ }
+
+ event void PhySplitControl.startDone(error_t error) {
+ signal SplitControl.startDone(error);
+ }
+
+ event void PhySplitControl.stopDone(error_t error) {
+ signal SplitControl.stopDone(error);
+ }
+
+
+
command error_t Send.cancel(message_t* msg) {
/* Cancel is unsupported for now. */
return FAIL;
error_t err;
if (txMsgPtr) return EBUSY;
+
if (call XE1205PhyRxTx.busy()) return EBUSY;
+ if (call XE1205PhyRxTx.off()) return EOFF;
+
txWhiteByte++;
txPhyHdr.whitening = txWhiteByte;
return error;
}
- async command void Resource.release[ uint8_t id ]() {
+ async command error_t Resource.release[ uint8_t id ]() {
uint8_t i;
atomic {
if ( m_holder != id ) {
xe1205check(11, 1);
- return;
+ return FAIL;
}
m_holder = NO_HOLDER;
m_holder = i;
m_requests &= ~( 1 << i );
call SpiResource.request();
- return;
+ return SUCCESS;
}
}
}
+ return SUCCESS;
}
}
async command void Reg.read[uint8_t addr](uint8_t* data)
{
- error_t status;
-
#if 1
if (call NssDataPin.get() != TRUE || call NssConfigPin.get() != TRUE)
xe1205check(6, 1);
call NssDataPin.set();
call NssConfigPin.clr();
- call SpiByte.write(XE1205_READ(addr), &status);
- call SpiByte.write(0, data);
+ call SpiByte.write(XE1205_READ(addr));
+ *data = call SpiByte.write(0);
call NssConfigPin.set();
}
async command void Reg.write[uint8_t addr](uint8_t data)
{
- error_t status;
-
#if 1
if (call NssDataPin.get() != TRUE || call NssConfigPin.get() != TRUE)
xe1205check(7, 1);
call NssDataPin.set();
call NssConfigPin.clr();
- call SpiByte.write(XE1205_WRITE(addr), &status);
- call SpiByte.write(data, &status);
+ call SpiByte.write(XE1205_WRITE(addr));
+ call SpiByte.write(data);
call NssConfigPin.set();
}
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
+#ifndef CRC_H
+#define CRC_H
uint16_t const ccitt_crc16_table[256] = {
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
fcs = ccitt_crc16_table[(fcs >> 8 ^ c) & 0xffU] ^ (fcs << 8);
return fcs;
}
+#endif
components XE1205IrqConfC;
XE1205PhyP.XE1205IrqConf -> XE1205IrqConfC;
- components new Alarm32khzC();
- XE1205PhyP.Alarm32khz16 -> Alarm32khzC.Alarm32khz16;
+ components new Alarm32khz16C();
+ XE1205PhyP.Alarm32khz16 -> Alarm32khz16C.Alarm;
#if 0
components new Msp430GpioC() as DpinM, HplMsp430GeneralIOC;
DpinM -> HplMsp430GeneralIOC.Port41;
uint16_t stats_rxOverruns;
- typedef enum {
+ typedef enum { // remember to update busy() and off(), start(), stop() if states are added
RADIO_LISTEN=0,
RADIO_RX_HEADER=1,
RADIO_RX_PACKET=2,
RADIO_RX_PACKET_LAST=3,
RADIO_TX=4,
RADIO_SLEEP=5,
- RADIO_STARTING=6
+ RADIO_STARTING=6
} phy_state_t;
phy_state_t state = RADIO_SLEEP;
void armPatternDetect();
+ ////////////////////////////////////////////////////////////////////////////////////
+ //
+ // jiffy/microseconds/bytetime conversion functions.
+ //
+ ////////////////////////////////////////////////////////////////////////////////////
+
+ // 1 jiffie = 1/32768 = 30.52us;
+ // we approximate to 32us for quicker computation and also to account for interrupt/processing overhead.
+ inline uint32_t usecs_to_jiffies(uint32_t usecs) {
+ return usecs >> 5;
+ }
+
command error_t Init.init()
{
#if 0
return SUCCESS;
}
+ task void startDone() {
+ signal SplitControl.startDone(SUCCESS);
+ }
+
event void SpiResourceTX.granted() { }
event void SpiResourceRX.granted() { }
event void SpiResourceConfig.granted() {
armPatternDetect();
call SpiResourceConfig.release();
+
atomic {
+ if (state == RADIO_STARTING) post startDone();
call Interrupt0.enableRisingEdge();
state = RADIO_LISTEN;
}
}
- task void startDone() {
- signal SplitControl.startDone(SUCCESS);
- }
-
task void stopDone() {
signal SplitControl.stopDone(SUCCESS);
}
command error_t SplitControl.start()
{
- atomic state = RADIO_STARTING;
+ atomic {
+ if (state != RADIO_SLEEP) return EBUSY;
+ state = RADIO_STARTING;
+ }
+
call XE1205PhySwitch.rxMode();
call XE1205PhySwitch.antennaRx();
- call SpiResourceConfig.request();
- post startDone();
+
+ call Alarm32khz16.start(usecs_to_jiffies(XE1205_Sleep_to_RX_Time));
return SUCCESS;
}
command error_t SplitControl.stop()
{
- call XE1205PhySwitch.sleepMode();
- call XE1205PhySwitch.antennaOff();
- atomic state = RADIO_SLEEP;
+ atomic {
+ call XE1205PhySwitch.sleepMode();
+ call XE1205PhySwitch.antennaOff();
+ state = RADIO_SLEEP;
+ call Interrupt0.disable();
+ call Interrupt1.disable();
+ }
post stopDone();
return SUCCESS;
}
default event void SplitControl.stopDone(error_t error) { }
async command bool XE1205PhyRxTx.busy() {
- atomic return state != RADIO_LISTEN; // xxx need to deal with sleep state
+ atomic return (state != RADIO_LISTEN &&
+ state != RADIO_SLEEP &&
+ state != RADIO_STARTING);
+ }
+
+ async command bool XE1205PhyRxTx.off() {
+ atomic return (state == RADIO_SLEEP ||
+ state == RADIO_STARTING);
}
void armPatternDetect()
}
}
- bool reading=FALSE;
/**
switch (state) {
case RADIO_RX_PACKET:
- reading = TRUE;
xe1205check(9, call XE1205Fifo.read(&rxFrame[rxFrameIndex], nextRxLen));
call Interrupt1.disable(); // in case it briefly goes back to full just after we read first byte
rxFrameIndex += nextRxLen;
return;
case RADIO_RX_PACKET:
- reading = FALSE;
call Interrupt1.enableRisingEdge();
return;
}
async event void Alarm32khz16.fired() {
- stats_rxOverruns++;
- signal XE1205PhyRxTx.rxFrameEnd(NULL, 0, FAIL);
- armPatternDetect();
- call SpiResourceRX.release();
- atomic {
- call Interrupt0.enableRisingEdge();
- state = RADIO_LISTEN;
+
+ switch(state) {
+
+ case RADIO_STARTING:
+ call SpiResourceConfig.request();
+ return;
+
+ case RADIO_RX_HEADER:
+ case RADIO_RX_PACKET:
+ stats_rxOverruns++;
+ signal XE1205PhyRxTx.rxFrameEnd(NULL, 0, FAIL);
+ armPatternDetect();
+ call SpiResourceRX.release();
+ atomic {
+ call Interrupt0.enableRisingEdge();
+ state = RADIO_LISTEN;
+ }
+ return;
+ default:
}
+
}
+
}
*/
async command bool busy();
+ /**
+ * Check on/off state of phy.
+ *
+ * @return TRUE if phy is idle, standby, starting, or stopping, FALSE otherwise.
+ *
+ */
+ async command bool off();
/**
* The Active Message accessors, which provide the AM local address and
- * functionality for querying packets. Also see the Packet interface.
+ * functionality for querying packets. Active Messages are a single-hop
+ * communication protocol. Therefore, fields such as source and destination
+ * represent the single-hop source and destination. Multihop sources and
+ * destinations are defined by the corresponding multihop protocol (if any).
+ * Also see the Packet interface.
*
* @author Philip Levis
* @date January 18 2005
command am_addr_t address();
/**
- * Return the AM address of the destination field of an AM packet.
+ * Return the AM address of the destination of the AM packet.
* If <tt>amsg</tt> is not an AM packet, the results of this command
* are undefined.
* @param amsg the packet
command am_addr_t destination(message_t* amsg);
+ /**
+ * Return the AM address of the source of the AM packet.
+ * If <tt>amsg</tt> is not an AM packet, the results of this command
+ * are undefined.
+ * @param amsg the packet
+ * @return the source address of the packet.
+ */
+
+ command am_addr_t source(message_t* amsg);
+
/**
* Set the AM address of the destination field of the AM packet. As
* the AM address is set as part of sending with the AMSend
command void setDestination(message_t* amsg, am_addr_t addr);
+ /**
+ * Set the AM address of the source field of the AM packet. As
+ * the AM address is set as part of sending with the AMSend
+ * interface, this command is not used for sending packets. Rather,
+ * it is used when a component, such as a queue, needs to buffer a
+ * request to send. The component can save the source address
+ * and then recover it when actually sending. As an AM layer generally
+ * sets the source address to be the local address, this interface
+ * is not commonly used except when a system is bypassing the AM
+ * layer (e.g., a protocol bridge). If <tt>amsg</tt> is
+ * not an AM packet, the results of this command are undefined.
+ *
+ * @param amsg the packet
+ * @param addr the address
+ */
+
+ command void setSource(message_t* amsg, am_addr_t addr);
+
/**
* Return whether <tt>amsg</tt> is destined for this mote. This is
* partially a shortcut for testing whether the return value of
event void readDone(storage_addr_t addr, void* buf, storage_len_t len,
error_t error);
- /**
- * Initiate a verify operation to verify the integrity of the
- * data. This operation is only valid after a commit operation from
- * <code>BlockWrite</code> has been completed. On SUCCESS, the
- * <code>verifyDone</code> event will signal completion of the
- * operation.
- *
- * @return
- * <li>SUCCESS if the request was accepted,
- * <li>EBUSY if a request is already being processed.
- */
- command error_t verify();
-
- /**
- * Signals the completion of a verify operation.
- *
- * @param error SUCCESS if the operation was successful, FAIL if
- * it failed
- */
- event void verifyDone(error_t error);
-
/**
* Initiate a crc computation. On SUCCESS, the
* <code>computeCrcDone</code> event will signal completion of the
* Initiate a write operation within a given volume. On SUCCESS, the
* <code>writeDone</code> event will signal completion of the
* operation.
+ * <p>
+ * Between two erases, no byte may be written more than once.
*
* @param addr starting address to begin write.
* @param buf buffer to write data from.
/**
* Signals the completion of a write operation. However, data is not
- * guaranteed to survive a power-cycle unless a commit operation has
+ * guaranteed to survive a power-cycle unless a sync operation has
* been completed.
*
* @param addr starting address of write.
event void eraseDone(error_t error);
/**
- * Initiate a commit operation and finialize any additional writes
- * to the volume. A verify operation from <code>BlockRead</code> can
- * be done to check if the data has been modified since. A commit
- * operation must be issued to ensure that data is stored in
- * non-volatile storage. On SUCCES, the <code>commitDone</code>
- * event will signal completion of the operation.
+ * Initiate a sync operation and finialize any additional writes to
+ * the volume. A sync operation must be issued to ensure that data is
+ * stored in non-volatile storage. On SUCCES, the
+ * <code>syncDone</code> event will signal completion of the
+ * operation.
*
* @return
* <li>SUCCESS if the request was accepted,
* <li>EBUSY if a request is already being processed.
*/
- command error_t commit();
+ command error_t sync();
/**
- * Signals the completion of a commit operation. All written data is
+ * Signals the completion of a sync operation. All written data is
* flushed to non-volatile storage after this event.
*
* @param error SUCCESS if the operation was successful, FAIL if
* it failed
*/
- event void commitDone(error_t error);
+ event void syncDone(error_t error);
}
async command void toggle();
async command bool get();
async command void makeInput();
+ async command bool isInput();
async command void makeOutput();
+ async command bool isOutput();
}
-
*
* @param buf buffer that written data was read from.
* @param len number of bytes actually written (valid even in case of error)
+ * @param records_lost TRUE if this append destroyed some old records from
+ * the beginning of the log (only possible for circular logs).
* @param error SUCCESS if append was possible, ESIZE if the (linear) log
* is full and FAIL for other errors.
*/
- event void appendDone(void* buf, storage_len_t len, error_t error);
+ event void appendDone(void* buf, storage_len_t len, bool recordsLost,
+ error_t error);
/**
* Return a "cookie" representing the current append offset within the
*
*/
-/*
- * - Revision -------------------------------------------------------------
- * $Revision$
- * $Date$
- * ========================================================================
- */
-
/**
* Please refer to TEP 108 for more information about this interface and its
* intended use.<br><br>
* predefined arbitration policy.
*
* @author Kevin Klues (klueska@cs.wustl.edu)
+ * @version $Revision$
+ * @date $Date$
*/
interface Resource {
* granted event is pending
*/
async command error_t request();
-
+
/**
- * Request immediate access to a shared resource. You must call
- * release() when you are done with it.
- *
- * @return SUCCESS You now have cotnrol of the resource.<br>
- * EBUSY The resource is busy. You must try again later
- */
+ * Request immediate access to a shared resource. You must call release()
+ * when you are done with it.
+ *
+ * @return SUCCESS When a request has been accepted. <br>
+ * FAIL The request cannot be fulfilled
+ */
async command error_t immediateRequest();
/**
- * You are now in control of the resource. Note that this event
- * is NOT signaled when immediateRequest() succeeds.
+ * You are now in control of the resource.
*/
event void granted();
/**
- * Release a shared resource you previously acquired.
- */
- async command void release();
+ * Release a shared resource you previously acquired.
+ *
+ * @return SUCCESS The resource has been released <br>
+ * FAIL You tried to release but you are not the
+ * owner of the resource
+ */
+ async command error_t release();
/**
* Check if the user of this interface is the current
* owner of the Resource
* @return TRUE It is the owner <br>
- * FALSE It is not the owner
+ * FALSE It is not the owner
*/
async command bool isOwner();
}
/*
- * "Copyright (c) 2005 Washington University in St. Louis.
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose, without fee, and without written agreement is
- * hereby granted, provided that the above copyright notice, the following
- * two paragraphs and the author appear in all copies of this software.
- *
- * IN NO EVENT SHALL WASHINGTON UNIVERSITY IN ST. LOUIS BE LIABLE TO ANY PARTY
- * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
- * OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF WASHINGTON
- * UNIVERSITY IN ST. LOUIS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * WASHINGTON UNIVERSITY IN ST. LOUIS SPECIFICALLY DISCLAIMS ANY WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND WASHINGTON UNIVERSITY IN ST. LOUIS HAS NO
- * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
- * MODIFICATIONS."
- */
-
-/*
- * Copyright (c) 2004, Technische Universitat Berlin
+ * Copyright (c) 2005, Technische Universitaet Berlin
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
*
*/
-/*
- * - Revision -------------------------------------------------------------
- * $Revision$
- * $Date$
- * ========================================================================
- */
-
/**
* Please refer to TEP 108 for more information about this interface and its
* intended use.<br><br>
*
- * This interface is an extension of the Resource interface. It has all of the
- * commands and events present in the Resource interface, along with two additional
- * events. These events allow the user of this interface to be notified whenever
- * someone requests the use of a resource or whenever the resource becomes idle.
- * One could use this interface to control access to a resource by always
- * taking control of a resource whenever it has gone idle and deciding when to
- * release it based on requests from other users.
- *
- * @author Kevin Klues (klues@tkn.tu-berlin.de)
+ * @author Kevin Klues (klues@tkn.tu-berlin.edu)
+ * @version $Revision$
+ * @date $Date$
*/
interface ResourceController {
/**
- * Request access to a shared resource. You must call release()
- * when you are done with it.
- *
- * @return SUCCESS When a request has been accepted. The granted()
- * event will be signaled once you have control of the
- * resource.<br>
- * EBUSY You have already requested this resource and a
- * granted event is pending
+ * Event sent to the resource controller giving it control whenever a resource
+ * goes idle. That is to say, whenever no one currently owns the resource,
+ * and there are no more pending requests
*/
- async command error_t request();
-
- /**
- * Request immediate access to a shared resource. You must call
- * release() when you are done with it.
- *
- * @return SUCCESS You now have cotnrol of the resource.<br>
- * EBUSY The resource is busy. You must try again later
- */
- async command error_t immediateRequest();
+ async event void granted();
/**
- * You are now in control of the resource. Note that this event
- * is NOT signaled when immediateRequest() succeeds.
- */
- event void granted();
-
- /**
- * Release a shared resource you previously acquired.
+ * Release control of the resource
+ *
+ * @return SUCCESS The resource has been released and pending requests
+ * can resume. <br>
+ * FAIL You tried to release but you are not the
+ * owner of the resource
*/
- async command void release();
+ async command error_t release();
/**
* Check if the user of this interface is the current
* owner of the Resource
+ *
* @return TRUE It is the owner <br>
* FALSE It is not the owner
*/
/**
* This event is signalled whenever the user of this interface
* currently has control of the resource, and another user requests
- * it. You may want to consider releasing a resource based on this
- * event
+ * it through the Resource.request() command. You may want to
+ * consider releasing a resource based on this event
*/
async event void requested();
/**
- * Event sent to the resource controller whenever a resource goes idle.
- * That is to say, whenever no one currently owns the resource, and there
- * are no more pending requests
- */
- async event void idle();
+ * This event is signalled whenever the user of this interface
+ * currently has control of the resource, and another user requests
+ * it through the Resource.immediateRequest() command. You may
+ * want to consider releasing a resource based on this event
+ */
+ async event void immediateRequested();
}
* @param tx Byte to transmit
* @param rx Received byte is stored here.
*/
- async command void write( uint8_t tx, uint8_t* rx );
+ async command uint8_t write( uint8_t tx );
}
*/
async event void getSnrDone(int16_t snr);
+ /**
+ * try to be lucky: read anything stored as the rssi and
+ * make a crude and fast conversion to an snr value
+ */
+ async command uint16_t readSnr();
+
/**
* Get the noisefloor in mV.
*
#include "radiopacketfunctions.h"
#include "message.h"
+#include "PacketAck.h"
/**
* This is the implementation of a really simple link layer.
async event void SendDown.sendDone(message_t* msg, error_t error) {
atomic {
txBufPtr = msg;
- getMetadata(msg)->ack = 1; // this is rather stupid
}
if (error == SUCCESS) {
post SendDoneSuccessTask();
/* PacketAcknowledgements interface */
async command error_t PacketAcknowledgements.requestAck(message_t* msg) {
- return FAIL;
+ getMetadata(msg)->ack = ACK_REQUESTED;
+ return SUCCESS;
}
async command error_t PacketAcknowledgements.noAck(message_t* msg) {
- return SUCCESS;
+ getMetadata(msg)->ack = NO_ACK_REQUESTED;
+ return SUCCESS;
}
async command bool PacketAcknowledgements.wasAcked(message_t* msg) {
- return FALSE;
+ bool rVal = FALSE;
+ if(getMetadata(msg)->ack == WAS_ACKED) rVal = TRUE;
+ return rVal;
}
}
}
async event void PhyPacketTx.sendHeaderDone() {
- signal RadioTimeStamping.transmittedSFD(0, (message_t*)txBufPtr);
TransmitNextByte();
}
void TransmitNextByte() {
message_radio_header_t* header = getHeader((message_t*) txBufPtr);
if (byteCnt < header->length + sizeof(message_header_t) ) { // send (data + header), compute crc
+ if(byteCnt == sizeof(message_header_t)) signal RadioTimeStamping.transmittedSFD(0, (message_t*)txBufPtr);
crc = crcByte(crc, ((uint8_t *)(txBufPtr))[byteCnt]);
call RadioByteComm.txByte(((uint8_t *)(txBufPtr))[byteCnt++]);
} else if (byteCnt == (header->length + sizeof(message_header_t))) {
crc = 0;
getHeader(rxBufPtr)->length = sizeof(message_radio_header_t);
signal PhyReceive.receiveDetected();
- signal RadioTimeStamping.receivedSFD(0);
}
}
message_radio_footer_t* footer = getFooter((message_t*)rxBufPtr);
((uint8_t *)(rxBufPtr))[byteCnt++] = data;
if ( byteCnt < getHeader(rxBufPtr)->length + sizeof(message_radio_header_t) ) {
+ if(byteCnt == sizeof(message_radio_header_t)) signal RadioTimeStamping.receivedSFD(0);
crc = crcByte(crc, data);
if (getHeader(rxBufPtr)->length > TOSH_DATA_LENGTH) {
// this packet is surely corrupt, so whatever...
* @return SUCCESS if it could be set (no current receiving/transmitting)
FALSE otherwise.
*/
- command error_t setNumPreambles(uint16_t numPreambleBytes);
+ async command error_t setNumPreambles(uint16_t numPreambleBytes);
/**
* Sets the timeout after the byte-stream is considered dead if no more
if ( dMsg->seqno != DISSEMINATION_SEQNO_UNKNOWN ) {
object = call DisseminationCache.requestData[ key ]( &objectSize );
- objectSize =
- objectSize < call AMSend.maxPayloadLength() ?
- objectSize : call AMSend.maxPayloadLength();
-
+ if ((objectSize + sizeof(dissemination_message_t)) >
+ call AMSend.maxPayloadLength()) {
+ objectSize = call AMSend.maxPayloadLength() - sizeof(dissemination_message_t);
+ }
memcpy( dMsg->data, object, objectSize );
}
call AMSend.send( AM_BROADCAST_ADDR,
AM_COLLECTION_DATA = 20,
AM_COLLECTION_CONTROL = 21,
AM_COLLECTION_DEBUG = 22,
- AM_LINKEST = 0,
};
typedef uint8_t collection_id_t;
ForwardingEngineP.BasicRouting -> TreeRoutingEngineP;
TreeRoutingEngineP.LinkEstimator -> LinkEstimatorC;
+ ForwardingEngineP.LinkEstimator -> LinkEstimatorC;
components new LinkEstimatorAMSenderC(AM_COLLECTION_DATA)
as DataAMSender;
interface CollectionId[uint8_t client];
interface AMPacket;
interface CollectionDebug;
+ interface LinkEstimator;
+ interface Leds;
}
}
implementation {
startRetxmitTimer(SENDDONE_FAIL_WINDOW, SENDDONE_FAIL_OFFSET);
}
else if (ackPending && !call PacketAcknowledgements.wasAcked(msg)) {
+
+ call LinkEstimator.txNoAck(AMPacket.destination(msg));
+
// AckPending is for case when DL cannot support acks.
if (--qe->retries) {
dbg("Forwarder", "%s: not acked\n", __FUNCTION__);
call CollectionPacket.getSequenceNumber(msg),
call CollectionPacket.getOrigin(msg),
call AMPacket.destination(msg));
+ call LinkEstimator.txAck(AMPacket.destination(msg));
clientPtrs[client] = qe;
hdr = getHeader(qe->msg);
call SendQueue.dequeue();
else if (call MessagePool.size() < call MessagePool.maxSize()) {
// A successfully forwarded packet.
dbg("Forwarder,Route", "%s: successfully forwarded packet (client: %hhu), message pool is %hhu/%hhu.\n", __FUNCTION__, qe->client, call MessagePool.size(), call MessagePool.maxSize());
+
+ call LinkEstimator.txAck(AMPacket.destination(msg));
+
call CollectionDebug.logEventMsg(NET_C_FE_FWD_MSG,
call CollectionPacket.getSequenceNumber(msg),
call CollectionPacket.getOrigin(msg),
call CollectionDebug.logEvent(NET_C_FE_PUT_QEPOOL_ERR);
sending = FALSE;
startRetxmitTimer(SENDDONE_OK_WINDOW, SENDDONE_OK_OFFSET);
+ call Leds.led2Toggle();
}
else {
dbg("Forwarder", "%s: BUG: we have a pool entry, but the pool is full, client is %hhu.\n", __FUNCTION__, qe->client);
return msg;
}
//... and in the queue for duplicates
- atomic {
- for (i = call SendQueue.size(); --i ;) {
- qe = call SendQueue.element(i);
- if (call CollectionPacket.getPacketID(qe->msg) == msg_uid) {
- duplicate = TRUE;
- break;
- }
- }
+ if (call SendQueue.size() > 0) {
+ for (i = call SendQueue.size(); --i;) {
+ qe = call SendQueue.element(i);
+ if (call CollectionPacket.getPacketID(qe->msg) == msg_uid) {
+ duplicate = TRUE;
+ break;
+ }
+ }
}
+
if (duplicate) {
call CollectionDebug.logEvent(NET_C_FE_DUPLICATE_QUEUE);
return msg;
dbg("Forwarder", "started rexmit timer in %hu ms\n", r);
}
+ event void LinkEstimator.evicted(am_addr_t neighbor) {
+ }
+
/* Default implementations for CollectionDebug calls.
* These allow CollectionDebug not to be wired to anything if debugging
* is not desired. */
components ActiveMessageC;
components new ForwardingEngineP() as Forwarder;
- components MainC;
+ components MainC, LedsC;
Send = Forwarder;
StdControl = Forwarder;
Forwarder.RadioControl -> ActiveMessageC;
Forwarder.PacketAcknowledgements -> AMSenderC.Acks;
Forwarder.AMPacket -> AMSenderC;
-
+ Forwarder.Leds -> LedsC;
+
components new AMSenderC(AM_COLLECTION_CONTROL) as SendControl;
components new AMReceiverC(AM_COLLECTION_CONTROL) as ReceiveControl;
components new AMSenderC(AM_LINKEST) as SendLinkEst;
i, entry->neighbor, entry->info.parent, entry->info.hopcount);
continue;
}
-
+ if (TOS_NODE_ID > 10 && entry->neighbor == 0) {
+ continue;
+ }
/* Compute this neighbor's path metric */
linkMetric = evaluateMetric(call LinkEstimator.getLinkQuality(entry->neighbor));
dbg("TreeRouting",
call CollectionDebug.logEventRoute(NET_C_TREE_NEW_PARENT, best->neighbor, best->info.hopcount + 1, best->info.metric);
call LinkEstimator.unpinNeighbor(routeInfo.parent);
call LinkEstimator.pinNeighbor(best->neighbor);
+ call LinkEstimator.clearDLQ(best->neighbor);
atomic {
routeInfo.parent = best->neighbor;
routeInfo.metric = best->info.metric;
*/
/**
+ * Please refer to TEP 115 for more information about this component and its
+ * intended use.<br><br>
*
* This is the internal implementation of the deffered power management
* policy for managing the power states of non-virtualized devices.
* before shutting down the device once it is free.
*
* @author Kevin Klues (klueska@cs.wustl.edu)
- * @see Please refer to TEP 115 for more information about this component and its
- * intended use.
*/
generic module AsyncDeferredPowerManagerP(uint32_t delay) {
- provides {
- interface Init;
- }
uses {
interface AsyncStdControl;
interface PowerDownCleanup;
- interface Init as ArbiterInit;
interface ResourceController;
interface ArbiterInfo;
interface Timer<TMilli> as TimerMilli;
}
implementation {
- norace struct {
- uint8_t stopping :1;
- uint8_t requested :1;
- } f; //for flags
+ norace bool stopTimer = FALSE;
- task void timerTask() {
- call TimerMilli.startOneShot(delay);
+ task void stopTimerTask() {
+ call TimerMilli.stop();
+ stopTimer = FALSE;
}
- command error_t Init.init() {
- f.stopping = FALSE;
- f.requested = FALSE;
- call ArbiterInit.init();
- call ResourceController.immediateRequest();
- return SUCCESS;
+ task void timerTask() {
+ if(stopTimer == FALSE)
+ call TimerMilli.startOneShot(delay);
}
async event void ResourceController.requested() {
- if(f.stopping == FALSE) {
- call AsyncStdControl.start();
- call ResourceController.release();
- }
- else atomic f.requested = TRUE;
+ stopTimer = TRUE;
+ post stopTimerTask();
+ call AsyncStdControl.start();
+ call ResourceController.release();
+ }
+
+ async event void ResourceController.immediateRequested() {
+ stopTimer = TRUE;
+ post stopTimerTask();
+ call AsyncStdControl.start();
+ call ResourceController.release();
}
- async event void ResourceController.idle() {
- if(!(call ArbiterInfo.inUse()))
+ async event void ResourceController.granted() {
post timerTask();
}
event void TimerMilli.fired() {
- if(call ResourceController.immediateRequest() == SUCCESS) {
- f.stopping = TRUE;
+ if(stopTimer == FALSE) {
call PowerDownCleanup.cleanup();
call AsyncStdControl.stop();
}
- if(f.requested == TRUE) {
- call AsyncStdControl.start();
- call ResourceController.release();
- }
- atomic {
- f.stopping = FALSE;
- f.requested = FALSE;
- }
- }
-
- event void ResourceController.granted() {
}
default async command void PowerDownCleanup.cleanup() {
*/
/**
+ * Please refer to TEP 115 for more information about this component and its
+ * intended use.<br><br>
*
* This is the internal implementation of the standard power management
* policy for managing the power states of non-virtualized devices.
* power up, so it can be powered on and off as often as possible.
*
* @author Kevin Klues (klueska@cs.wustl.edu)
- * @see Please refer to TEP 115 for more information about this component and its
- * intended use.
*/
generic module AsyncPowerManagerP() {
- provides {
- interface Init;
- }
uses {
interface AsyncStdControl;
interface PowerDownCleanup;
- interface Init as ArbiterInit;
interface ResourceController;
+ interface ArbiterInfo;
}
}
implementation {
- norace struct {
- uint8_t stopping :1;
- uint8_t requested :1;
- } f; //for flags
-
- command error_t Init.init() {
- call ArbiterInit.init();
- call ResourceController.immediateRequest();
- return SUCCESS;
- }
-
async event void ResourceController.requested() {
- if(f.stopping == FALSE) {
- call AsyncStdControl.start();
- call ResourceController.release();
- }
- else atomic f.requested = TRUE;
+ call AsyncStdControl.start();
+ call ResourceController.release();
}
- async event void ResourceController.idle() {
- if(call ResourceController.immediateRequest() == SUCCESS) {
- atomic f.stopping = TRUE;
- call PowerDownCleanup.cleanup();
- call AsyncStdControl.stop();
- }
- if(f.requested == TRUE) {
- call AsyncStdControl.start();
- call ResourceController.release();
- }
- atomic {
- f.stopping = FALSE;
- f.requested = FALSE;
- }
- }
+ async event void ResourceController.immediateRequested() {
+ call AsyncStdControl.start();
+ call ResourceController.release();
+ }
- event void ResourceController.granted() {
+ async event void ResourceController.granted() {
+ call PowerDownCleanup.cleanup();
+ call AsyncStdControl.stop();
}
default async command void PowerDownCleanup.cleanup() {
*/
/**
+ * Please refer to TEP 115 for more information about this component and its
+ * intended use.<br><br>
*
* This component povides a power management policy for managing the power
* states of non-virtualized devices. Non-virtualized devices are shared
* before shutting down the device once it is free.
*
* @author Kevin Klues (klueska@cs.wustl.edu)
- * @see Please refer to TEP 115 for more information about this component and its
- * intended use.
*/
generic configuration AsyncStdControlDeferredPowerManagerC(uint32_t delay)
{
- provides {
- interface Init;
- }
uses {
interface AsyncStdControl;
interface PowerDownCleanup;
- interface Init as ArbiterInit;
interface ResourceController;
interface ArbiterInfo;
}
implementation {
components new TimerMilliC(),
new AsyncDeferredPowerManagerP(delay) as PowerManager;
-
- Init = PowerManager;
PowerManager.AsyncStdControl = AsyncStdControl;
-
PowerManager.PowerDownCleanup = PowerDownCleanup;
- PowerManager.ArbiterInit = ArbiterInit;
PowerManager.ResourceController = ResourceController;
PowerManager.ArbiterInfo = ArbiterInfo;
*/
/**
+ * Please refer to TEP 115 for more information about this component and its
+ * intended use.<br><br>
*
* This is the internal implementation of the standard power management
* policy for managing the power states of non-virtualized devices.
* <code>SplitControlPowerManagerC</code> component respectively.
*
* @author Kevin Klues (klueska@cs.wustl.edu)
- * @see Please refer to TEP 115 for more information about this component and its
- * intended use.
*/
generic configuration AsyncStdControlPowerManagerC()
{
- provides {
- interface Init;
- }
uses {
interface AsyncStdControl;
interface PowerDownCleanup;
- interface Init as ArbiterInit;
interface ResourceController;
+ interface ArbiterInfo;
}
}
implementation {
components new AsyncPowerManagerP() as PowerManager;
-
- Init = PowerManager;
PowerManager.AsyncStdControl = AsyncStdControl;
PowerManager.PowerDownCleanup = PowerDownCleanup;
- PowerManager.ArbiterInit = ArbiterInit;
PowerManager.ResourceController = ResourceController;
+ PowerManager.ArbiterInfo = ArbiterInfo;
}
*/
/**
+ * Please refer to TEP 115 for more information about this component and its
+ * intended use.<br><br>
*
* This is the internal implementation of the deffered power management
* policy for managing the power states of non-virtualized devices.
* before shutting down the device once it is free.
*
* @author Kevin Klues (klueska@cs.wustl.edu)
- * @see Please refer to TEP 115 for more information about this component and its
- * intended use.
*/
generic module DeferredPowerManagerP(uint32_t delay) {
- provides {
- interface Init;
- }
uses {
interface StdControl;
interface SplitControl;
interface PowerDownCleanup;
- interface Init as ArbiterInit;
interface ResourceController;
interface ArbiterInfo;
interface Timer<TMilli> as TimerMilli;
}
implementation {
- norace struct {
- uint8_t stopping :1;
- uint8_t requested :1;
- } f; //for flags
+ norace bool stopping = FALSE;
+ norace bool requested = FALSE;
+ norace bool stopTimer = FALSE;
- task void startTask() {
+ task void startTask() {
+ call TimerMilli.stop();
+ stopTimer = FALSE;
call StdControl.start();
call SplitControl.start();
}
+
task void timerTask() {
call TimerMilli.startOneShot(delay);
}
- command error_t Init.init() {
- f.stopping = FALSE;
- f.requested = FALSE;
- call ArbiterInit.init();
- call ResourceController.immediateRequest();
- return SUCCESS;
- }
-
async event void ResourceController.requested() {
- if(f.stopping == FALSE)
+ if(stopping == FALSE) {
+ stopTimer = TRUE;
post startTask();
- else atomic f.requested = TRUE;
+ }
+ else atomic requested = TRUE;
+ }
+
+ async event void ResourceController.immediateRequested() {
}
default command error_t StdControl.start() {
call ResourceController.release();
}
- async event void ResourceController.idle() {
- if(!(call ArbiterInfo.inUse()))
- post timerTask();
+ async event void ResourceController.granted() {
+ post timerTask();
}
event void TimerMilli.fired() {
- if(call ResourceController.immediateRequest() == SUCCESS) {
- f.stopping = TRUE;
+ if(stopTimer == FALSE) {
+ stopping = TRUE;
call PowerDownCleanup.cleanup();
call StdControl.stop();
call SplitControl.stop();
}
event void SplitControl.stopDone(error_t error) {
- if(f.requested == TRUE) {
+ if(requested == TRUE) {
call StdControl.start();
call SplitControl.start();
}
atomic {
- f.requested = FALSE;
- f.stopping = FALSE;
+ requested = FALSE;
+ stopping = FALSE;
}
}
- event void ResourceController.granted() {
- }
-
default command error_t StdControl.stop() {
return SUCCESS;
}
*/
/**
+ * Please refer to TEP 115 for more information about this interface and its
+ * intended use.<br><br>
*
* This interface exists to allow a Resource user to cleanup any state
* information before a shared Resource is shutdown. It should be provided
* the shared resource.
*
* @author Kevin Klues (klueska@cs.wustl.edu)
- * @see Please refer to TEP 115 for more information about this component and its
- * intended use.
*/
interface PowerDownCleanup {
*/
/**
+ * Please refer to TEP 115 for more information about this component and its
+ * intended use.<br><br>
*
* This is the internal implementation of the standard power management
* policy for managing the power states of non-virtualized devices.
* power up, so it can be powered on and off as often as possible.
*
* @author Kevin Klues (klueska@cs.wustl.edu)
- * @see Please refer to TEP 115 for more information about this component and its
- * intended use.
*/
generic module PowerManagerP() {
- provides {
- interface Init;
- }
uses {
interface StdControl;
interface SplitControl;
interface PowerDownCleanup;
- interface Init as ArbiterInit;
interface ResourceController;
+ interface ArbiterInfo;
}
}
implementation {
- norace struct {
- uint8_t stopping :1;
- uint8_t requested :1;
- } f; //for flags
+ norace bool stopping = FALSE;
+ norace bool requested = FALSE;
- task void startTask() {
+ task void startTask() {
call StdControl.start();
call SplitControl.start();
}
- task void stopTask() {
- call StdControl.stop();
- call SplitControl.stop();
- }
- command error_t Init.init() {
- f.stopping = FALSE;
- f.requested = FALSE;
- call ArbiterInit.init();
- call ResourceController.immediateRequest();
- return SUCCESS;
+ task void stopTask() {
+ call PowerDownCleanup.cleanup();
+ call StdControl.stop();
+ call SplitControl.stop();
}
async event void ResourceController.requested() {
- if(f.stopping == FALSE)
+ if(stopping == FALSE) {
post startTask();
- else atomic f.requested = TRUE;
+ }
+ else requested = TRUE;
+ }
+
+ async event void ResourceController.immediateRequested() {
}
default command error_t StdControl.start() {
call ResourceController.release();
}
- async event void ResourceController.idle() {
- if(call ResourceController.immediateRequest() == SUCCESS) {
- f.stopping = TRUE;
- call PowerDownCleanup.cleanup();
- post stopTask();
- }
+ async event void ResourceController.granted() {
+ atomic stopping = TRUE;
+ post stopTask();
}
event void SplitControl.stopDone(error_t error) {
- if(f.requested == TRUE) {
+ if(requested == TRUE) {
call StdControl.start();
call SplitControl.start();
}
atomic {
- f.requested = FALSE;
- f.stopping = FALSE;
+ requested = FALSE;
+ stopping = FALSE;
}
}
- event void ResourceController.granted() {
- }
-
default command error_t StdControl.stop() {
return SUCCESS;
}
*/
/**
+ * Please refer to TEP 115 for more information about this component and its
+ * intended use.<br><br>
*
* This component povides a power management policy for managing the power
* states of non-virtualized devices. Non-virtualized devices are shared
* before shutting down the device once it is free.
*
* @author Kevin Klues (klueska@cs.wustl.edu)
- * @see Please refer to TEP 115 for more information about this component and its
- * intended use.
*/
generic configuration SplitControlDeferredPowerManagerC(uint32_t delay) {
- provides {
- interface Init;
- }
uses {
interface SplitControl;
interface PowerDownCleanup;
- interface Init as ArbiterInit;
interface ResourceController;
interface ArbiterInfo;
}
implementation {
components new TimerMilliC(),
new DeferredPowerManagerP(delay) as PowerManager;
-
- Init = PowerManager;
PowerManager.SplitControl = SplitControl;
PowerManager.PowerDownCleanup = PowerDownCleanup;
- PowerManager.ArbiterInit = ArbiterInit;
PowerManager.ResourceController = ResourceController;
PowerManager.ArbiterInfo = ArbiterInfo;
*/
/**
+ * Please refer to TEP 115 for more information about this component and its
+ * intended use.<br><br>
*
* This component povides a power management policy for managing the power
* states of non-virtualized devices. Non-virtualized devices are shared
* <code>StdControlPowerManagerC</code> component respectively.
*
* @author Kevin Klues (klueska@cs.wustl.edu)
- * @see Please refer to TEP 115 for more information about this component and its
- * intended use.
*/
generic configuration SplitControlPowerManagerC() {
- provides {
- interface Init;
- }
uses {
interface SplitControl;
interface PowerDownCleanup;
- interface Init as ArbiterInit;
interface ResourceController;
+ interface ArbiterInfo;
}
}
implementation {
components new PowerManagerP() as PowerManager;
-
- Init = PowerManager;
PowerManager.SplitControl = SplitControl;
PowerManager.PowerDownCleanup = PowerDownCleanup;
- PowerManager.ArbiterInit = ArbiterInit;
PowerManager.ResourceController = ResourceController;
+ PowerManager.ArbiterInfo = ArbiterInfo;
}
*/
/**
+ * Please refer to TEP 115 for more information about this component and its
+ * intended use.<br><br>
*
* This component povides a power management policy for managing the power
* states of non-virtualized devices. Non-virtualized devices are shared
* before shutting down the device once it is free.
*
* @author Kevin Klues (klueska@cs.wustl.edu)
- * @see Please refer to TEP 115 for more information about this component and its
- * intended use.
*/
generic configuration StdControlDeferredPowerManagerC(uint32_t delay)
{
- provides {
- interface Init;
- }
uses {
interface StdControl;
interface PowerDownCleanup;
- interface Init as ArbiterInit;
interface ResourceController;
interface ArbiterInfo;
}
implementation {
components new TimerMilliC(),
new DeferredPowerManagerP(delay) as PowerManager;
-
- Init = PowerManager;
PowerManager.StdControl = StdControl;
PowerManager.PowerDownCleanup = PowerDownCleanup;
- PowerManager.ArbiterInit = ArbiterInit;
PowerManager.ResourceController = ResourceController;
PowerManager.ArbiterInfo = ArbiterInfo;
*/
/**
+ * Please refer to TEP 115 for more information about this component and its
+ * intended use.<br><br>
*
* This component povides a power management policy for managing the power
* states of non-virtualized devices. Non-virtualized devices are shared
* <code>SplitControlPowerManagerC</code> component respectively.
*
* @author Kevin Klues (klueska@cs.wustl.edu)
- * @see Please refer to TEP 115 for more information about this component and its
- * intended use.
*/
generic configuration StdControlPowerManagerC()
{
- provides {
- interface Init;
- }
uses {
interface StdControl;
interface PowerDownCleanup;
- interface Init as ArbiterInit;
interface ResourceController;
+ interface ArbiterInfo;
}
}
implementation {
components new PowerManagerP() as PowerManager;
-
- Init = PowerManager;
PowerManager.StdControl = StdControl;
PowerManager.PowerDownCleanup = PowerDownCleanup;
- PowerManager.ArbiterInit = ArbiterInit;
PowerManager.ResourceController = ResourceController;
+ PowerManager.ArbiterInfo = ArbiterInfo;
}
module HdlcTranslateC {
provides interface SerialFrameComm;
uses {
- interface SerialByteComm;
+ interface UartStream;
interface Leds;
}
}
//norace uint8_t debugCnt = 0;
norace HdlcState state = {0,0};
norace uint8_t txTemp;
-
+ norace uint8_t m_data;
// TODO: add reset for when SerialM goes no-sync.
async command void SerialFrameComm.resetReceive(){
async command void SerialFrameComm.resetSend(){
state.sendEscape = 0;
}
- async event void SerialByteComm.get(uint8_t data) {
+ async event void UartStream.receivedByte(uint8_t data) {
//debugCnt++;
// 7E 41 0E 05 04 03 02 01 00 01 8F 7E
/* if (debugCnt == 1 && data == 0x7E) call Leds.led0On(); */
async command error_t SerialFrameComm.putDelimiter() {
state.sendEscape = 0;
- return call SerialByteComm.put(HDLC_FLAG_BYTE);
+ m_data = HDLC_FLAG_BYTE;
+ return call UartStream.send(&m_data, 1);
}
async command error_t SerialFrameComm.putData(uint8_t data) {
if (data == HDLC_CTLESC_BYTE || data == HDLC_FLAG_BYTE) {
state.sendEscape = 1;
txTemp = data ^ 0x20;
- return call SerialByteComm.put(HDLC_CTLESC_BYTE);
+ m_data = HDLC_CTLESC_BYTE;
}
else {
- return call SerialByteComm.put(data);
+ m_data = data;
}
+ return call UartStream.send(&m_data, 1);
}
- async event void SerialByteComm.putDone() {
+ async event void UartStream.sendDone( uint8_t* buf, uint16_t len,
+ error_t error ) {
if (state.sendEscape) {
state.sendEscape = 0;
- call SerialByteComm.put(txTemp);
+ m_data = txTemp;
+ call UartStream.send(&m_data, 1);
}
else {
signal SerialFrameComm.putDone();
}
}
+
+ async event void UartStream.receiveDone( uint8_t* buf, uint16_t len, error_t error ) {}
}
} radio_stats_t;
typedef nx_struct serial_header {
- nx_am_addr_t addr;
+ nx_am_addr_t dest;
+ nx_am_addr_t src;
nx_uint8_t length;
nx_am_group_t group;
nx_am_id_t type;
message_t* msg,
uint8_t len) {
serial_header_t* header = getHeader(msg);
- header->addr = dest;
+ header->dest = dest;
+ // Do not set the source address or group, as doing so
+ // prevents transparent bridging. Need a better long-term
+ // solution for this.
+ //header->src = call AMPacket.address();
+ //header->group = TOS_AM_GROUP;
header->type = id;
header->length = len;
- header->group = TOS_AM_GROUP;
+
return call SubSend.send(msg, len);
}
command am_addr_t AMPacket.destination(message_t* amsg) {
serial_header_t* header = getHeader(amsg);
- return header->addr;
+ return header->dest;
+ }
+
+ command am_addr_t AMPacket.source(message_t* amsg) {
+ serial_header_t* header = getHeader(amsg);
+ return header->src;
}
command void AMPacket.setDestination(message_t* amsg, am_addr_t addr) {
serial_header_t* header = getHeader(amsg);
- header->addr = addr;
+ header->dest = addr;
+ }
+
+ command void AMPacket.setSource(message_t* amsg, am_addr_t addr) {
+ serial_header_t* header = getHeader(amsg);
+ header->src = addr;
}
command bool AMPacket.isForMe(message_t* amsg) {
//$Id$
-/* "Copyright (c) 2005 The Regents of the University of California.
+/* "Copyright (c) 2005 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement
* is hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
- *
+ *
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY
* OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
}
}
implementation {
- components SerialP, new SerialDispatcherP(),
- HdlcTranslateC,
+ components SerialP, new SerialDispatcherP(),
+ HdlcTranslateC,
PlatformSerialC;
-
+
Send = SerialDispatcherP;
Receive = SerialDispatcherP;
SerialPacketInfo = SerialDispatcherP.PacketInfo;
SplitControl = SerialP;
-
+
Init = SerialP;
- Init = PlatformSerialC;
Leds = SerialP;
Leds = SerialDispatcherP;
Leds = HdlcTranslateC;
SerialDispatcherP.ReceiveBytePacket -> SerialP;
SerialDispatcherP.SendBytePacket -> SerialP;
-
+
SerialP.SerialFrameComm -> HdlcTranslateC;
SerialP.SerialControl -> PlatformSerialC;
-
- HdlcTranslateC.SerialByteComm -> PlatformSerialC;
-
+
+ HdlcTranslateC.UartStream -> PlatformSerialC;
+
}
-// $Id$
/*
* IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. By
* downloading, copying, installing or using the software you agree to
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * Author: Phil Buonadonna
* Revision: $Revision$
*
*/
/* Ack Queue */
ack_queue_t ackQ;
- /* stats */
- radio_stats_t stats;
-
bool offPending = FALSE;
// Prototypes
inline void txInit();
inline void rxInit();
inline void ackInit();
- inline void statsInit();
inline bool ack_queue_is_full();
inline bool ack_queue_is_empty();
ackQ.writePtr = ackQ.readPtr = 0;
}
- inline void statsInit(){
- memset(&stats, 0, sizeof(stats));
- stats.platform = 0; // TODO: set platform
- stats.MTU = SERIAL_MTU;
- stats.version = SERIAL_VERSION;
- }
-
command error_t Init.init() {
txInit();
rxInit();
ackInit();
- statsInit();
return SUCCESS;
}
case RXSTATE_TOKEN:
if (isDelimeter) {
- stats.serial_short_packets++;
goto nosync;
}
else {
goto nosync;
}
else {
- stats.serial_crc_fail++;
goto nosync;
}
}
else {
- stats.serial_short_packets++;
goto nosync;
}
}
/* no valid message.. */
else {
- stats.serial_proto_drops++;
goto nosync;
}
break;
/* if done, call the send done */
if (done || fail) {
- if (fail) atomic stats.serial_tx_fail++;
txSeqno++;
if (txProto == SERIAL_PROTO_ACK){
ack_queue_pop();
command am_addr_t AMPacket.destination(message_t* amsg) {
serial_header_t* header = getHeader(amsg);
- return header->addr;
+ return header->dest;
}
command void AMPacket.setDestination(message_t* amsg, am_addr_t addr) {
serial_header_t* header = getHeader(amsg);
- header->addr = addr;
+ header->dest = addr;
+ }
+
+ command am_addr_t AMPacket.source(message_t* amsg) {
+ serial_header_t* header = getHeader(amsg);
+ return header->src;
+ }
+
+ command void AMPacket.setSource(message_t* amsg, am_addr_t addr) {
+ serial_header_t* header = getHeader(amsg);
+ header->src = addr;
}
command bool AMPacket.isForMe(message_t* amsg) {
-# This file was created automatically by SWIG.
+# This file was created automatically by SWIG 1.3.29.
# Don't modify this file, modify the SWIG interface instead.
# This file is compatible with both classic and new-style classes.
import _TOSSIM
-
-def _swig_setattr(self,class_type,name,value):
+import new
+new_instancemethod = new.instancemethod
+def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
+ if (name == "thisown"): return self.this.own(value)
if (name == "this"):
- if isinstance(value, class_type):
- self.__dict__[name] = value.this
- if hasattr(value,"thisown"): self.__dict__["thisown"] = value.thisown
- del value.thisown
+ if type(value).__name__ == 'PySwigObject':
+ self.__dict__[name] = value
return
method = class_type.__swig_setmethods__.get(name,None)
if method: return method(self,value)
- self.__dict__[name] = value
+ if (not static) or hasattr(self,name):
+ self.__dict__[name] = value
+ else:
+ raise AttributeError("You cannot add attributes to %s" % self)
+
+def _swig_setattr(self,class_type,name,value):
+ return _swig_setattr_nondynamic(self,class_type,name,value,0)
def _swig_getattr(self,class_type,name):
+ if (name == "thisown"): return self.this.own()
method = class_type.__swig_getmethods__.get(name,None)
if method: return method(self)
raise AttributeError,name
+def _swig_repr(self):
+ try: strthis = "proxy of " + self.this.__repr__()
+ except: strthis = ""
+ return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
+
import types
try:
_object = types.ObjectType
__setattr__ = lambda self, name, value: _swig_setattr(self, MAC, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, MAC, name)
- def __repr__(self):
- return "<C MAC instance at %s>" % (self.this,)
- def __init__(self, *args):
- _swig_setattr(self, MAC, 'this', _TOSSIM.new_MAC(*args))
- _swig_setattr(self, MAC, 'thisown', 1)
- def __del__(self, destroy=_TOSSIM.delete_MAC):
- try:
- if self.thisown: destroy(self)
- except: pass
+ __repr__ = _swig_repr
+ def __init__(self, *args):
+ this = _TOSSIM.new_MAC(*args)
+ try: self.this.append(this)
+ except: self.this = this
+ __swig_destroy__ = _TOSSIM.delete_MAC
+ __del__ = lambda self : None;
def initHigh(*args): return _TOSSIM.MAC_initHigh(*args)
def initLow(*args): return _TOSSIM.MAC_initLow(*args)
def high(*args): return _TOSSIM.MAC_high(*args)
def setMinFreeSamples(*args): return _TOSSIM.MAC_setMinFreeSamples(*args)
def setRxtxDelay(*args): return _TOSSIM.MAC_setRxtxDelay(*args)
def setAckTime(*args): return _TOSSIM.MAC_setAckTime(*args)
-
-class MACPtr(MAC):
- def __init__(self, this):
- _swig_setattr(self, MAC, 'this', this)
- if not hasattr(self,"thisown"): _swig_setattr(self, MAC, 'thisown', 0)
- _swig_setattr(self, MAC,self.__class__,MAC)
-_TOSSIM.MAC_swigregister(MACPtr)
+MAC_swigregister = _TOSSIM.MAC_swigregister
+MAC_swigregister(MAC)
class Radio(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, Radio, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, Radio, name)
- def __repr__(self):
- return "<C Radio instance at %s>" % (self.this,)
- def __init__(self, *args):
- _swig_setattr(self, Radio, 'this', _TOSSIM.new_Radio(*args))
- _swig_setattr(self, Radio, 'thisown', 1)
- def __del__(self, destroy=_TOSSIM.delete_Radio):
- try:
- if self.thisown: destroy(self)
- except: pass
+ __repr__ = _swig_repr
+ def __init__(self, *args):
+ this = _TOSSIM.new_Radio(*args)
+ try: self.this.append(this)
+ except: self.this = this
+ __swig_destroy__ = _TOSSIM.delete_Radio
+ __del__ = lambda self : None;
def add(*args): return _TOSSIM.Radio_add(*args)
def gain(*args): return _TOSSIM.Radio_gain(*args)
def connected(*args): return _TOSSIM.Radio_connected(*args)
def remove(*args): return _TOSSIM.Radio_remove(*args)
def setNoise(*args): return _TOSSIM.Radio_setNoise(*args)
def setSensitivity(*args): return _TOSSIM.Radio_setSensitivity(*args)
-
-class RadioPtr(Radio):
- def __init__(self, this):
- _swig_setattr(self, Radio, 'this', this)
- if not hasattr(self,"thisown"): _swig_setattr(self, Radio, 'thisown', 0)
- _swig_setattr(self, Radio,self.__class__,Radio)
-_TOSSIM.Radio_swigregister(RadioPtr)
+Radio_swigregister = _TOSSIM.Radio_swigregister
+Radio_swigregister(Radio)
class Packet(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, Packet, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, Packet, name)
- def __repr__(self):
- return "<C Packet instance at %s>" % (self.this,)
- def __init__(self, *args):
- _swig_setattr(self, Packet, 'this', _TOSSIM.new_Packet(*args))
- _swig_setattr(self, Packet, 'thisown', 1)
- def __del__(self, destroy=_TOSSIM.delete_Packet):
- try:
- if self.thisown: destroy(self)
- except: pass
+ __repr__ = _swig_repr
+ def __init__(self, *args):
+ this = _TOSSIM.new_Packet(*args)
+ try: self.this.append(this)
+ except: self.this = this
+ __swig_destroy__ = _TOSSIM.delete_Packet
+ __del__ = lambda self : None;
def setDestination(*args): return _TOSSIM.Packet_setDestination(*args)
def destination(*args): return _TOSSIM.Packet_destination(*args)
def setLength(*args): return _TOSSIM.Packet_setLength(*args)
def setStrength(*args): return _TOSSIM.Packet_setStrength(*args)
def deliver(*args): return _TOSSIM.Packet_deliver(*args)
def deliverNow(*args): return _TOSSIM.Packet_deliverNow(*args)
-
-class PacketPtr(Packet):
- def __init__(self, this):
- _swig_setattr(self, Packet, 'this', this)
- if not hasattr(self,"thisown"): _swig_setattr(self, Packet, 'thisown', 0)
- _swig_setattr(self, Packet,self.__class__,Packet)
-_TOSSIM.Packet_swigregister(PacketPtr)
+Packet_swigregister = _TOSSIM.Packet_swigregister
+Packet_swigregister(Packet)
class variable_string_t(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, variable_string_t, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, variable_string_t, name)
- def __repr__(self):
- return "<C variable_string_t instance at %s>" % (self.this,)
+ __repr__ = _swig_repr
__swig_setmethods__["type"] = _TOSSIM.variable_string_t_type_set
__swig_getmethods__["type"] = _TOSSIM.variable_string_t_type_get
if _newclass:type = property(_TOSSIM.variable_string_t_type_get, _TOSSIM.variable_string_t_type_set)
__swig_setmethods__["isArray"] = _TOSSIM.variable_string_t_isArray_set
__swig_getmethods__["isArray"] = _TOSSIM.variable_string_t_isArray_get
if _newclass:isArray = property(_TOSSIM.variable_string_t_isArray_get, _TOSSIM.variable_string_t_isArray_set)
- def __init__(self, *args):
- _swig_setattr(self, variable_string_t, 'this', _TOSSIM.new_variable_string_t(*args))
- _swig_setattr(self, variable_string_t, 'thisown', 1)
- def __del__(self, destroy=_TOSSIM.delete_variable_string_t):
- try:
- if self.thisown: destroy(self)
- except: pass
-
-class variable_string_tPtr(variable_string_t):
- def __init__(self, this):
- _swig_setattr(self, variable_string_t, 'this', this)
- if not hasattr(self,"thisown"): _swig_setattr(self, variable_string_t, 'thisown', 0)
- _swig_setattr(self, variable_string_t,self.__class__,variable_string_t)
-_TOSSIM.variable_string_t_swigregister(variable_string_tPtr)
+ def __init__(self, *args):
+ this = _TOSSIM.new_variable_string_t(*args)
+ try: self.this.append(this)
+ except: self.this = this
+ __swig_destroy__ = _TOSSIM.delete_variable_string_t
+ __del__ = lambda self : None;
+variable_string_t_swigregister = _TOSSIM.variable_string_t_swigregister
+variable_string_t_swigregister(variable_string_t)
class nesc_app_t(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, nesc_app_t, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, nesc_app_t, name)
- def __repr__(self):
- return "<C nesc_app_t instance at %s>" % (self.this,)
+ __repr__ = _swig_repr
__swig_setmethods__["numVariables"] = _TOSSIM.nesc_app_t_numVariables_set
__swig_getmethods__["numVariables"] = _TOSSIM.nesc_app_t_numVariables_get
if _newclass:numVariables = property(_TOSSIM.nesc_app_t_numVariables_get, _TOSSIM.nesc_app_t_numVariables_set)
__swig_setmethods__["variableArray"] = _TOSSIM.nesc_app_t_variableArray_set
__swig_getmethods__["variableArray"] = _TOSSIM.nesc_app_t_variableArray_get
if _newclass:variableArray = property(_TOSSIM.nesc_app_t_variableArray_get, _TOSSIM.nesc_app_t_variableArray_set)
- def __init__(self, *args):
- _swig_setattr(self, nesc_app_t, 'this', _TOSSIM.new_nesc_app_t(*args))
- _swig_setattr(self, nesc_app_t, 'thisown', 1)
- def __del__(self, destroy=_TOSSIM.delete_nesc_app_t):
- try:
- if self.thisown: destroy(self)
- except: pass
-
-class nesc_app_tPtr(nesc_app_t):
- def __init__(self, this):
- _swig_setattr(self, nesc_app_t, 'this', this)
- if not hasattr(self,"thisown"): _swig_setattr(self, nesc_app_t, 'thisown', 0)
- _swig_setattr(self, nesc_app_t,self.__class__,nesc_app_t)
-_TOSSIM.nesc_app_t_swigregister(nesc_app_tPtr)
+ def __init__(self, *args):
+ this = _TOSSIM.new_nesc_app_t(*args)
+ try: self.this.append(this)
+ except: self.this = this
+ __swig_destroy__ = _TOSSIM.delete_nesc_app_t
+ __del__ = lambda self : None;
+nesc_app_t_swigregister = _TOSSIM.nesc_app_t_swigregister
+nesc_app_t_swigregister(nesc_app_t)
class Variable(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, Variable, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, Variable, name)
- def __repr__(self):
- return "<C Variable instance at %s>" % (self.this,)
- def __init__(self, *args):
- _swig_setattr(self, Variable, 'this', _TOSSIM.new_Variable(*args))
- _swig_setattr(self, Variable, 'thisown', 1)
- def __del__(self, destroy=_TOSSIM.delete_Variable):
- try:
- if self.thisown: destroy(self)
- except: pass
+ __repr__ = _swig_repr
+ def __init__(self, *args):
+ this = _TOSSIM.new_Variable(*args)
+ try: self.this.append(this)
+ except: self.this = this
+ __swig_destroy__ = _TOSSIM.delete_Variable
+ __del__ = lambda self : None;
def getData(*args): return _TOSSIM.Variable_getData(*args)
-
-class VariablePtr(Variable):
- def __init__(self, this):
- _swig_setattr(self, Variable, 'this', this)
- if not hasattr(self,"thisown"): _swig_setattr(self, Variable, 'thisown', 0)
- _swig_setattr(self, Variable,self.__class__,Variable)
-_TOSSIM.Variable_swigregister(VariablePtr)
+Variable_swigregister = _TOSSIM.Variable_swigregister
+Variable_swigregister(Variable)
class Mote(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, Mote, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, Mote, name)
- def __repr__(self):
- return "<C Mote instance at %s>" % (self.this,)
- def __init__(self, *args):
- _swig_setattr(self, Mote, 'this', _TOSSIM.new_Mote(*args))
- _swig_setattr(self, Mote, 'thisown', 1)
- def __del__(self, destroy=_TOSSIM.delete_Mote):
- try:
- if self.thisown: destroy(self)
- except: pass
+ __repr__ = _swig_repr
+ def __init__(self, *args):
+ this = _TOSSIM.new_Mote(*args)
+ try: self.this.append(this)
+ except: self.this = this
+ __swig_destroy__ = _TOSSIM.delete_Mote
+ __del__ = lambda self : None;
def id(*args): return _TOSSIM.Mote_id(*args)
def euid(*args): return _TOSSIM.Mote_euid(*args)
def setEuid(*args): return _TOSSIM.Mote_setEuid(*args)
def turnOff(*args): return _TOSSIM.Mote_turnOff(*args)
def turnOn(*args): return _TOSSIM.Mote_turnOn(*args)
def getVariable(*args): return _TOSSIM.Mote_getVariable(*args)
-
-class MotePtr(Mote):
- def __init__(self, this):
- _swig_setattr(self, Mote, 'this', this)
- if not hasattr(self,"thisown"): _swig_setattr(self, Mote, 'thisown', 0)
- _swig_setattr(self, Mote,self.__class__,Mote)
-_TOSSIM.Mote_swigregister(MotePtr)
+Mote_swigregister = _TOSSIM.Mote_swigregister
+Mote_swigregister(Mote)
class Tossim(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, Tossim, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, Tossim, name)
- def __repr__(self):
- return "<C Tossim instance at %s>" % (self.this,)
- def __init__(self, *args):
- _swig_setattr(self, Tossim, 'this', _TOSSIM.new_Tossim(*args))
- _swig_setattr(self, Tossim, 'thisown', 1)
- def __del__(self, destroy=_TOSSIM.delete_Tossim):
- try:
- if self.thisown: destroy(self)
- except: pass
+ __repr__ = _swig_repr
+ def __init__(self, *args):
+ this = _TOSSIM.new_Tossim(*args)
+ try: self.this.append(this)
+ except: self.this = this
+ __swig_destroy__ = _TOSSIM.delete_Tossim
+ __del__ = lambda self : None;
def init(*args): return _TOSSIM.Tossim_init(*args)
def time(*args): return _TOSSIM.Tossim_time(*args)
def ticksPerSecond(*args): return _TOSSIM.Tossim_ticksPerSecond(*args)
def setCurrentNode(*args): return _TOSSIM.Tossim_setCurrentNode(*args)
def addChannel(*args): return _TOSSIM.Tossim_addChannel(*args)
def removeChannel(*args): return _TOSSIM.Tossim_removeChannel(*args)
+ def randomSeed(*args): return _TOSSIM.Tossim_randomSeed(*args)
def runNextEvent(*args): return _TOSSIM.Tossim_runNextEvent(*args)
def mac(*args): return _TOSSIM.Tossim_mac(*args)
def radio(*args): return _TOSSIM.Tossim_radio(*args)
def newPacket(*args): return _TOSSIM.Tossim_newPacket(*args)
+Tossim_swigregister = _TOSSIM.Tossim_swigregister
+Tossim_swigregister(Tossim)
-class TossimPtr(Tossim):
- def __init__(self, this):
- _swig_setattr(self, Tossim, 'this', this)
- if not hasattr(self,"thisown"): _swig_setattr(self, Tossim, 'thisown', 0)
- _swig_setattr(self, Tossim,self.__class__,Tossim)
-_TOSSIM.Tossim_swigregister(TossimPtr)
command error_t AMSend.send[am_id_t id](am_addr_t addr,
message_t* amsg,
uint8_t len) {
+ error_t err;
tossim_header_t* header = getHeader(amsg);
header->type = id;
- header->addr = addr;
+ header->dest = addr;
+ header->src = call AMPacket.address();
header->length = len;
- return call Model.send((int)addr, amsg, len + sizeof(tossim_header_t));
+ err = call Model.send((int)addr, amsg, len + sizeof(tossim_header_t));
+ return err;
}
command error_t AMSend.cancel[am_id_t id](message_t* msg) {
event void Model.receive(message_t* msg) {
uint8_t len;
void* payload;
-
+
memcpy(bufferPointer, msg, sizeof(message_t));
payload = call Packet.getPayload(bufferPointer, &len);
event bool Model.shouldAck(message_t* msg) {
tossim_header_t* header = getHeader(msg);
- if (header->addr == call amAddress()) {
+ if (header->dest == call amAddress()) {
dbg("Acks", "addressed to me so ack it,");
return TRUE;
}
command am_addr_t AMPacket.destination(message_t* amsg) {
tossim_header_t* header = getHeader(amsg);
- return header->addr;
+ return header->dest;
}
command void AMPacket.setDestination(message_t* amsg, am_addr_t addr) {
tossim_header_t* header = getHeader(amsg);
- header->addr = addr;
+ header->dest = addr;
+ }
+
+ command am_addr_t AMPacket.source(message_t* amsg) {
+ tossim_header_t* header = getHeader(amsg);
+ return header->src;
}
+ command void AMPacket.setSource(message_t* amsg, am_addr_t addr) {
+ tossim_header_t* header = getHeader(amsg);
+ header->src = addr;
+ }
+
command bool AMPacket.isForMe(message_t* amsg) {
return (call AMPacket.destination(amsg) == call AMPacket.address() ||
call AMPacket.destination(amsg) == AM_BROADCAST_ADDR);
uint8_t backoffCount;
uint8_t neededFreeSamples;
message_t* sending = NULL;
+ bool transmitting = FALSE;
uint8_t sendingLength = 0;
int destNode;
delay = sim_csma_rxtx_delay();
delay *= (sim_ticks_per_sec() / sim_csma_symbols_per_sec());
evt->time += delay;
-
+ transmitting = TRUE;
evt->handle = send_transmit;
sim_queue_insert(evt);
}
void send_transmit_done(sim_event_t* evt) {
message_t* rval = sending;
sending = NULL;
+ transmitting = FALSE;
dbg("TossimPacketModelC", "PACKET: Signaling send done at %llu.\n", sim_time());
signal Packet.sendDone(rval, SUCCESS);
}
event void GainRadioModel.receive(message_t* msg) {
- if (running) {
+ if (running && !transmitting) {
signal Packet.receive(msg);
}
}
#include "AM.h"
typedef nx_struct tossim_header {
- nx_am_addr_t addr;
+ nx_am_addr_t dest;
+ nx_am_addr_t src;
nx_uint8_t length;
nx_am_id_t type;
} tossim_header_t;
}
if (list != mine) {
if ((list->power - sim_gain_sensitivity()) < heardSignal()) {
- dbg("Gain", "Lost packet from %i as power %lf was too low\n", list->source, list->power);
+ dbg("Gain", "Lost packet from %i as I concurrently received a packet stronger than %lf\n", list->source, list->power);
list->lost = 1;
}
}
}
if ((mine->power - sim_gain_sensitivity()) < heardSignal()) {
- dbg("Gain", "Lost packet as power %lf was too low\n", mine->power);
+ dbg("Gain", "Lost packet from %i as its power %lf was below sensitivity threshold\n", mine->source, mine->power);
mine->lost = 1;
}
// enqueue a receive event to figure out what happens.
void enqueue_receive_event(int source, sim_time_t endTime, message_t* msg, bool receive, double power) {
sim_event_t* evt;
+ receive_message_t* list;
receive_message_t* rcv = allocate_receive_message();
double sigStr = heardSignal();
rcv->source = source;
dbg("Gain", "Lost packet from %i due to %i being off\n", source, sim_node());
rcv->lost = 1;
}
- else {
- if ((sigStr + sim_gain_sensitivity()) >= power) {
- dbg("Gain", "Lost packet from %i due to power being too low (%f >= %f)\n", source, sigStr, power);
- rcv->lost = 1;
- }
- else if (receiving) {
- dbg("Gain", "Lost packet from %i due to being in the midst of a reception.\n", source);
- rcv->lost = 1;
- }
- if (power >= sim_gain_noise_mean(sim_node()) + sim_gain_noise_range(sim_node())) {
- receiving = 1;
+ else if ((sigStr + sim_gain_sensitivity()) >= power) {
+ dbg("Gain", "Lost packet from %i due to power being below reception threshold (%f >= %f)\n", source, sigStr, power);
+ rcv->lost = 1;
+ }
+ else if (receiving) {
+ dbg("Gain", "Lost packet from %i due to being in the midst of a reception.\n", source);
+ rcv->lost = 1;
+ }
+ else { // We are on, are not receiving a packet, and the packet is above the noise floor
+ receiving = 1;
+ }
+
+ list = outstandingReceptionHead;
+ while (list != NULL) {
+ if ((list->power - sim_gain_sensitivity()) < power) {
+ dbg("Gain", "Lost packet from %i as I concurrently received a packet from %i stronger than %lf\n", list->source, source, list->power);
+ list->lost = 1;
}
+ list = list->next;
}
+
rcv->next = outstandingReceptionHead;
outstandingReceptionHead = rcv;
#ifndef __HASHTABLE_CWC22_H__
#define __HASHTABLE_CWC22_H__
+#ifdef __cplusplus
+extern "C" {
+#endif
struct hashtable;
void
hashtable_destroy(struct hashtable *h, int free_values);
+#ifdef __cplusplus
+}
+#endif
+
+
#endif /* __HASHTABLE_CWC22_H__ */
/*
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
void sim_packet_set_destination(sim_packet_t* msg, uint16_t dest)__attribute__ ((C, spontaneous)) {
tossim_header_t* hdr = getHeader((message_t*)msg);
- hdr->addr = dest;
+ hdr->dest = dest;
}__attribute__ ((C, spontaneous))
+
uint16_t sim_packet_destination(sim_packet_t* msg)__attribute__ ((C, spontaneous)) {
tossim_header_t* hdr = getHeader((message_t*)msg);
- return hdr->addr;
+ return hdr->dest;
}
void sim_packet_set_length(sim_packet_t* msg, uint8_t length)__attribute__ ((C, spontaneous)) {
#include <heap.c>
#include <sim_event_queue.c>
#include <sim_tossim.c>
-#include <hashtable.c>
#include <sim_mac.c>
#include <sim_packet.c>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <hashtable.h>
#include <mac.c>
#include <radio.c>
data = NULL;
ptr = NULL;
}
+ printf("Allocated variable %s\n", realName);
}
Variable::~Variable() {
+ printf("Freeing variable %s\n", realName);
free(data);
+ free(realName);
}
+/* This is the sdbm algorithm, taken from
+ http://www.cs.yorku.ca/~oz/hash.html -pal */
+static unsigned int tossim_hash(void* key) {
+ char* str = (char*)key;
+ unsigned int hashVal = 0;
+ int c;
+
+ while ((c = *str++))
+ hashVal = c + (hashVal << 6) + (hashVal << 16) - hashVal;
+
+ return hashVal;
+}
+
+static int tossim_hash_eq(void* key1, void* key2) {
+ return strcmp((char*)key1, (char*)key2) == 0;
+}
+
+
variable_string_t Variable::getData() {
if (data != NULL && ptr != NULL) {
str.ptr = data;
Mote::Mote(nesc_app_t* n) {
app = n;
+ varTable = create_hashtable(128, tossim_hash, tossim_hash_eq);
}
+
Mote::~Mote(){}
unsigned long Mote::id() {
Variable* Mote::getVariable(char* name) {
char* typeStr = "";
int isArray;
- // Could hash this for greater efficiency,
- // but that would either require transformation
- // in Tossim class or a more complex typemap.
- if (app != NULL) {
- for (int i = 0; i < app->numVariables; i++) {
- if(strcmp(name, app->variableNames[i]) == 0) {
- typeStr = app->variableTypes[i];
- isArray = app->variableArray[i];
- break;
+ Variable* var;
+
+ var = (Variable*)hashtable_search(varTable, name);
+ if (var == NULL) {
+ // Could hash this for greater efficiency,
+ // but that would either require transformation
+ // in Tossim class or a more complex typemap.
+ if (app != NULL) {
+ for (int i = 0; i < app->numVariables; i++) {
+ if(strcmp(name, app->variableNames[i]) == 0) {
+ typeStr = app->variableTypes[i];
+ isArray = app->variableArray[i];
+ break;
+ }
}
}
+ // printf("Getting variable %s of type %s %s\n", name, typeStr, isArray? "[]" : "");
+ var = new Variable(name, typeStr, isArray, nodeID);
+ hashtable_insert(varTable, name, var);
}
- // printf("Getting variable %s of type %s %s\n", name, typeStr, isArray? "[]" : "");
- return new Variable(name, typeStr, isArray, nodeID);
+ return var;
}
Tossim::Tossim(nesc_app_t* n) {
return sim_remove_channel(channel, file);
}
+void Tossim::randomSeed(int seed) {
+ return sim_random_seed(seed);
+}
+
bool Tossim::runNextEvent() {
return sim_run_next_event();
}
#include <mac.h>
#include <radio.h>
#include <packet.h>
+#include <hashtable.h>
typedef struct variable_string {
char* type;
private:
unsigned long nodeID;
nesc_app_t* app;
+ struct hashtable* varTable;
};
class Tossim {
void addChannel(char* channel, FILE* file);
bool removeChannel(char* channel, FILE* file);
+ void randomSeed(int seed);
bool runNextEvent();
void addChannel(char* channel, FILE* file);
bool removeChannel(char* channel, FILE* file);
+ void randomSeed(int seed);
bool runNextEvent();
MAC* mac();
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.21
+ * Version 1.3.29
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
* ----------------------------------------------------------------------------- */
#define SWIGPYTHON
+#define SWIG_PYTHON_DIRECTOR_NO_VTABLE
#ifdef __cplusplus
template<class T> class SwigValueWrapper {
T *operator&() { return tt; }
private:
SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
-};
+};
#endif
+/* -----------------------------------------------------------------------------
+ * This section contains generic SWIG labels for method/variable
+ * declarations/attributes, and other compiler dependent labels.
+ * ----------------------------------------------------------------------------- */
-#include "Python.h"
+/* template workaround for compilers that cannot correctly implement the C++ standard */
+#ifndef SWIGTEMPLATEDISAMBIGUATOR
+# if defined(__SUNPRO_CC)
+# if (__SUNPRO_CC <= 0x560)
+# define SWIGTEMPLATEDISAMBIGUATOR template
+# else
+# define SWIGTEMPLATEDISAMBIGUATOR
+# endif
+# else
+# define SWIGTEMPLATEDISAMBIGUATOR
+# endif
+#endif
-/*************************************************************** -*- c -*-
- * python/precommon.swg
- *
- * Rename all exported symbols from common.swg, to avoid symbol
- * clashes if multiple interpreters are included
- *
- ************************************************************************/
+/* inline attribute */
+#ifndef SWIGINLINE
+# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
+# define SWIGINLINE inline
+# else
+# define SWIGINLINE
+# endif
+#endif
-#define SWIG_TypeRegister SWIG_Python_TypeRegister
-#define SWIG_TypeCheck SWIG_Python_TypeCheck
-#define SWIG_TypeCast SWIG_Python_TypeCast
-#define SWIG_TypeDynamicCast SWIG_Python_TypeDynamicCast
-#define SWIG_TypeName SWIG_Python_TypeName
-#define SWIG_TypeQuery SWIG_Python_TypeQuery
-#define SWIG_TypeClientData SWIG_Python_TypeClientData
-#define SWIG_PackData SWIG_Python_PackData
-#define SWIG_UnpackData SWIG_Python_UnpackData
+/* attribute recognised by some compilers to avoid 'unused' warnings */
+#ifndef SWIGUNUSED
+# if defined(__GNUC__)
+# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
+# define SWIGUNUSED __attribute__ ((__unused__))
+# else
+# define SWIGUNUSED
+# endif
+# elif defined(__ICC)
+# define SWIGUNUSED __attribute__ ((__unused__))
+# else
+# define SWIGUNUSED
+# endif
+#endif
+#ifndef SWIGUNUSEDPARM
+# ifdef __cplusplus
+# define SWIGUNUSEDPARM(p)
+# else
+# define SWIGUNUSEDPARM(p) p SWIGUNUSED
+# endif
+#endif
-/***********************************************************************
- * common.swg
- *
- * This file contains generic SWIG runtime support for pointer
- * type checking as well as a few commonly used macros to control
- * external linkage.
- *
- * Author : David Beazley (beazley@cs.uchicago.edu)
- *
- * Copyright (c) 1999-2000, The University of Chicago
- *
- * This file may be freely redistributed without license or fee provided
- * this copyright message remains intact.
- ************************************************************************/
+/* internal SWIG method */
+#ifndef SWIGINTERN
+# define SWIGINTERN static SWIGUNUSED
+#endif
-#include <string.h>
+/* internal inline SWIG method */
+#ifndef SWIGINTERNINLINE
+# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
+#endif
-#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
-# if defined(_MSC_VER) || defined(__GNUC__)
-# if defined(STATIC_LINKED)
-# define SWIGEXPORT(a) a
-# define SWIGIMPORT(a) extern a
-# else
-# define SWIGEXPORT(a) __declspec(dllexport) a
-# define SWIGIMPORT(a) extern a
-# endif
-# else
-# if defined(__BORLANDC__)
-# define SWIGEXPORT(a) a _export
-# define SWIGIMPORT(a) a _export
-# else
-# define SWIGEXPORT(a) a
-# define SWIGIMPORT(a) a
-# endif
+/* exporting methods */
+#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+# ifndef GCC_HASCLASSVISIBILITY
+# define GCC_HASCLASSVISIBILITY
# endif
-#else
-# define SWIGEXPORT(a) a
-# define SWIGIMPORT(a) a
#endif
-#ifdef SWIG_GLOBAL
-# define SWIGRUNTIME(a) SWIGEXPORT(a)
-#else
-# define SWIGRUNTIME(a) static a
+#ifndef SWIGEXPORT
+# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+# if defined(STATIC_LINKED)
+# define SWIGEXPORT
+# else
+# define SWIGEXPORT __declspec(dllexport)
+# endif
+# else
+# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
+# define SWIGEXPORT __attribute__ ((visibility("default")))
+# else
+# define SWIGEXPORT
+# endif
+# endif
#endif
-#ifdef __cplusplus
-extern "C" {
+/* calling conventions for Windows */
+#ifndef SWIGSTDCALL
+# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+# define SWIGSTDCALL __stdcall
+# else
+# define SWIGSTDCALL
+# endif
#endif
-typedef void *(*swig_converter_func)(void *);
-typedef struct swig_type_info *(*swig_dycast_func)(void **);
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
-typedef struct swig_type_info {
- const char *name;
- swig_converter_func converter;
- const char *str;
- void *clientdata;
- swig_dycast_func dcast;
- struct swig_type_info *next;
- struct swig_type_info *prev;
-} swig_type_info;
-#ifdef SWIG_NOINCLUDE
+/* Python.h has to appear first */
+#include <Python.h>
+
+/* -----------------------------------------------------------------------------
+ * swigrun.swg
+ *
+ * This file contains generic CAPI SWIG runtime support for pointer
+ * type checking.
+ * ----------------------------------------------------------------------------- */
-SWIGIMPORT(swig_type_info *) SWIG_TypeRegister(swig_type_info *);
-SWIGIMPORT(swig_type_info *) SWIG_TypeCheck(char *c, swig_type_info *);
-SWIGIMPORT(void *) SWIG_TypeCast(swig_type_info *, void *);
-SWIGIMPORT(swig_type_info *) SWIG_TypeDynamicCast(swig_type_info *, void **);
-SWIGIMPORT(const char *) SWIG_TypeName(const swig_type_info *);
-SWIGIMPORT(swig_type_info *) SWIG_TypeQuery(const char *);
-SWIGIMPORT(void) SWIG_TypeClientData(swig_type_info *, void *);
-SWIGIMPORT(char *) SWIG_PackData(char *, void *, int);
-SWIGIMPORT(char *) SWIG_UnpackData(char *, void *, int);
+/* This should only be incremented when either the layout of swig_type_info changes,
+ or for whatever reason, the runtime changes incompatibly */
+#define SWIG_RUNTIME_VERSION "2"
+/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
+#ifdef SWIG_TYPE_TABLE
+# define SWIG_QUOTE_STRING(x) #x
+# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
+# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
#else
+# define SWIG_TYPE_TABLE_NAME
+#endif
-static swig_type_info *swig_type_list = 0;
-
-/* Register a type mapping with the type-checking */
-SWIGRUNTIME(swig_type_info *)
-SWIG_TypeRegister(swig_type_info *ti) {
- swig_type_info *tc, *head, *ret, *next;
- /* Check to see if this type has already been registered */
- tc = swig_type_list;
- while (tc) {
- if (strcmp(tc->name, ti->name) == 0) {
- /* Already exists in the table. Just add additional types to the list */
- if (tc->clientdata) ti->clientdata = tc->clientdata;
- head = tc;
- next = tc->next;
- goto l1;
- }
- tc = tc->prev;
- }
- head = ti;
- next = 0;
-
- /* Place in list */
- ti->prev = swig_type_list;
- swig_type_list = ti;
-
- /* Build linked lists */
- l1:
- ret = head;
- tc = ti + 1;
- /* Patch up the rest of the links */
- while (tc->name) {
- head->next = tc;
- tc->prev = head;
- head = tc;
- tc++;
- }
- if (next) next->prev = head;
- head->next = next;
- return ret;
-}
-
-/* Check the typename */
-SWIGRUNTIME(swig_type_info *)
-SWIG_TypeCheck(char *c, swig_type_info *ty) {
- swig_type_info *s;
- if (!ty) return 0; /* Void pointer */
- s = ty->next; /* First element always just a name */
- do {
- if (strcmp(s->name,c) == 0) {
- if (s == ty->next) return s;
- /* Move s to the top of the linked list */
- s->prev->next = s->next;
- if (s->next) {
- s->next->prev = s->prev;
+/*
+ You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
+ creating a static or dynamic library from the swig runtime code.
+ In 99.9% of the cases, swig just needs to declare them as 'static'.
+
+ But only do this if is strictly necessary, ie, if you have problems
+ with your compiler or so.
+*/
+
+#ifndef SWIGRUNTIME
+# define SWIGRUNTIME SWIGINTERN
+#endif
+
+#ifndef SWIGRUNTIMEINLINE
+# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
+#endif
+
+/* Generic buffer size */
+#ifndef SWIG_BUFFER_SIZE
+# define SWIG_BUFFER_SIZE 1024
+#endif
+
+/* Flags for pointer conversions */
+#define SWIG_POINTER_DISOWN 0x1
+
+/* Flags for new pointer objects */
+#define SWIG_POINTER_OWN 0x1
+
+
+/*
+ Flags/methods for returning states.
+
+ The swig conversion methods, as ConvertPtr, return and integer
+ that tells if the conversion was successful or not. And if not,
+ an error code can be returned (see swigerrors.swg for the codes).
+
+ Use the following macros/flags to set or process the returning
+ states.
+
+ In old swig versions, you usually write code as:
+
+ if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
+ // success code
+ } else {
+ //fail code
+ }
+
+ Now you can be more explicit as:
+
+ int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
+ if (SWIG_IsOK(res)) {
+ // success code
+ } else {
+ // fail code
+ }
+
+ that seems to be the same, but now you can also do
+
+ Type *ptr;
+ int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
+ if (SWIG_IsOK(res)) {
+ // success code
+ if (SWIG_IsNewObj(res) {
+ ...
+ delete *ptr;
+ } else {
+ ...
+ }
+ } else {
+ // fail code
+ }
+
+ I.e., now SWIG_ConvertPtr can return new objects and you can
+ identify the case and take care of the deallocation. Of course that
+ requires also to SWIG_ConvertPtr to return new result values, as
+
+ int SWIG_ConvertPtr(obj, ptr,...) {
+ if (<obj is ok>) {
+ if (<need new object>) {
+ *ptr = <ptr to new allocated object>;
+ return SWIG_NEWOBJ;
+ } else {
+ *ptr = <ptr to old object>;
+ return SWIG_OLDOBJ;
+ }
+ } else {
+ return SWIG_BADOBJ;
+ }
}
- /* Insert s as second element in the list */
- s->next = ty->next;
- if (ty->next) ty->next->prev = s;
- ty->next = s;
- s->prev = ty;
- return s;
- }
- s = s->next;
- } while (s && (s != ty->next));
- return 0;
-}
-/* Cast a pointer up an inheritance hierarchy */
-SWIGRUNTIME(void *)
-SWIG_TypeCast(swig_type_info *ty, void *ptr) {
- if ((!ty) || (!ty->converter)) return ptr;
- return (*ty->converter)(ptr);
+ Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
+ more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
+ swig errors code.
+
+ Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
+ allows to return the 'cast rank', for example, if you have this
+
+ int food(double)
+ int fooi(int);
+
+ and you call
+
+ food(1) // cast rank '1' (1 -> 1.0)
+ fooi(1) // cast rank '0'
+
+ just use the SWIG_AddCast()/SWIG_CheckState()
+
+
+ */
+#define SWIG_OK (0)
+#define SWIG_ERROR (-1)
+#define SWIG_IsOK(r) (r >= 0)
+#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError)
+
+/* The CastRankLimit says how many bits are used for the cast rank */
+#define SWIG_CASTRANKLIMIT (1 << 8)
+/* The NewMask denotes the object was created (using new/malloc) */
+#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1)
+/* The TmpMask is for in/out typemaps that use temporal objects */
+#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1)
+/* Simple returning values */
+#define SWIG_BADOBJ (SWIG_ERROR)
+#define SWIG_OLDOBJ (SWIG_OK)
+#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK)
+#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK)
+/* Check, add and del mask methods */
+#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
+#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
+#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
+#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
+#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
+#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
+
+
+/* Cast-Rank Mode */
+#if defined(SWIG_CASTRANK_MODE)
+# ifndef SWIG_TypeRank
+# define SWIG_TypeRank unsigned long
+# endif
+# ifndef SWIG_MAXCASTRANK /* Default cast allowed */
+# define SWIG_MAXCASTRANK (2)
+# endif
+# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1)
+# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK)
+SWIGINTERNINLINE int SWIG_AddCast(int r) {
+ return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
+}
+SWIGINTERNINLINE int SWIG_CheckState(int r) {
+ return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
}
+#else /* no cast-rank mode */
+# define SWIG_AddCast
+# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
+#endif
+
+
+
+
+#include <string.h>
-/* Dynamic pointer casting. Down an inheritance hierarchy */
-SWIGRUNTIME(swig_type_info *)
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void *(*swig_converter_func)(void *);
+typedef struct swig_type_info *(*swig_dycast_func)(void **);
+
+/* Structure to store inforomation on one type */
+typedef struct swig_type_info {
+ const char *name; /* mangled name of this type */
+ const char *str; /* human readable name of this type */
+ swig_dycast_func dcast; /* dynamic cast function down a hierarchy */
+ struct swig_cast_info *cast; /* linked list of types that can cast into this type */
+ void *clientdata; /* language specific type data */
+ int owndata; /* flag if the structure owns the clientdata */
+} swig_type_info;
+
+/* Structure to store a type and conversion function used for casting */
+typedef struct swig_cast_info {
+ swig_type_info *type; /* pointer to type that is equivalent to this type */
+ swig_converter_func converter; /* function to cast the void pointers */
+ struct swig_cast_info *next; /* pointer to next cast in linked list */
+ struct swig_cast_info *prev; /* pointer to the previous cast */
+} swig_cast_info;
+
+/* Structure used to store module information
+ * Each module generates one structure like this, and the runtime collects
+ * all of these structures and stores them in a circularly linked list.*/
+typedef struct swig_module_info {
+ swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */
+ size_t size; /* Number of types in this module */
+ struct swig_module_info *next; /* Pointer to next element in circularly linked list */
+ swig_type_info **type_initial; /* Array of initially generated type structures */
+ swig_cast_info **cast_initial; /* Array of initially generated casting structures */
+ void *clientdata; /* Language specific module data */
+} swig_module_info;
+
+/*
+ Compare two type names skipping the space characters, therefore
+ "char*" == "char *" and "Class<int>" == "Class<int >", etc.
+
+ Return 0 when the two name types are equivalent, as in
+ strncmp, but skipping ' '.
+*/
+SWIGRUNTIME int
+SWIG_TypeNameComp(const char *f1, const char *l1,
+ const char *f2, const char *l2) {
+ for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
+ while ((*f1 == ' ') && (f1 != l1)) ++f1;
+ while ((*f2 == ' ') && (f2 != l2)) ++f2;
+ if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
+ }
+ return (l1 - f1) - (l2 - f2);
+}
+
+/*
+ Check type equivalence in a name list like <name1>|<name2>|...
+ Return 0 if not equal, 1 if equal
+*/
+SWIGRUNTIME int
+SWIG_TypeEquiv(const char *nb, const char *tb) {
+ int equiv = 0;
+ const char* te = tb + strlen(tb);
+ const char* ne = nb;
+ while (!equiv && *ne) {
+ for (nb = ne; *ne; ++ne) {
+ if (*ne == '|') break;
+ }
+ equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
+ if (*ne) ++ne;
+ }
+ return equiv;
+}
+
+/*
+ Check type equivalence in a name list like <name1>|<name2>|...
+ Return 0 if equal, -1 if nb < tb, 1 if nb > tb
+*/
+SWIGRUNTIME int
+SWIG_TypeCompare(const char *nb, const char *tb) {
+ int equiv = 0;
+ const char* te = tb + strlen(tb);
+ const char* ne = nb;
+ while (!equiv && *ne) {
+ for (nb = ne; *ne; ++ne) {
+ if (*ne == '|') break;
+ }
+ equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
+ if (*ne) ++ne;
+ }
+ return equiv;
+}
+
+
+/* think of this as a c++ template<> or a scheme macro */
+#define SWIG_TypeCheck_Template(comparison, ty) \
+ if (ty) { \
+ swig_cast_info *iter = ty->cast; \
+ while (iter) { \
+ if (comparison) { \
+ if (iter == ty->cast) return iter; \
+ /* Move iter to the top of the linked list */ \
+ iter->prev->next = iter->next; \
+ if (iter->next) \
+ iter->next->prev = iter->prev; \
+ iter->next = ty->cast; \
+ iter->prev = 0; \
+ if (ty->cast) ty->cast->prev = iter; \
+ ty->cast = iter; \
+ return iter; \
+ } \
+ iter = iter->next; \
+ } \
+ } \
+ return 0
+
+/*
+ Check the typename
+*/
+SWIGRUNTIME swig_cast_info *
+SWIG_TypeCheck(const char *c, swig_type_info *ty) {
+ SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty);
+}
+
+/* Same as previous function, except strcmp is replaced with a pointer comparison */
+SWIGRUNTIME swig_cast_info *
+SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
+ SWIG_TypeCheck_Template(iter->type == from, into);
+}
+
+/*
+ Cast a pointer up an inheritance hierarchy
+*/
+SWIGRUNTIMEINLINE void *
+SWIG_TypeCast(swig_cast_info *ty, void *ptr) {
+ return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr);
+}
+
+/*
+ Dynamic pointer casting. Down an inheritance hierarchy
+*/
+SWIGRUNTIME swig_type_info *
SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
swig_type_info *lastty = ty;
if (!ty || !ty->dcast) return ty;
return lastty;
}
-/* Return the name associated with this type */
-SWIGRUNTIME(const char *)
+/*
+ Return the name associated with this type
+*/
+SWIGRUNTIMEINLINE const char *
SWIG_TypeName(const swig_type_info *ty) {
return ty->name;
}
-/* Search for a swig_type_info structure */
-SWIGRUNTIME(swig_type_info *)
-SWIG_TypeQuery(const char *name) {
- swig_type_info *ty = swig_type_list;
- while (ty) {
- if (ty->str && (strcmp(name,ty->str) == 0)) return ty;
- if (ty->name && (strcmp(name,ty->name) == 0)) return ty;
- ty = ty->prev;
+/*
+ Return the pretty name associated with this type,
+ that is an unmangled type name in a form presentable to the user.
+*/
+SWIGRUNTIME const char *
+SWIG_TypePrettyName(const swig_type_info *type) {
+ /* The "str" field contains the equivalent pretty names of the
+ type, separated by vertical-bar characters. We choose
+ to print the last name, as it is often (?) the most
+ specific. */
+ if (!type) return NULL;
+ if (type->str != NULL) {
+ const char *last_name = type->str;
+ const char *s;
+ for (s = type->str; *s; s++)
+ if (*s == '|') last_name = s+1;
+ return last_name;
}
- return 0;
+ else
+ return type->name;
}
-/* Set the clientdata field for a type */
-SWIGRUNTIME(void)
+/*
+ Set the clientdata field for a type
+*/
+SWIGRUNTIME void
SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
- swig_type_info *tc, *equiv;
- if (ti->clientdata == clientdata) return;
+ swig_cast_info *cast = ti->cast;
+ /* if (ti->clientdata == clientdata) return; */
ti->clientdata = clientdata;
- equiv = ti->next;
- while (equiv) {
- if (!equiv->converter) {
- tc = swig_type_list;
- while (tc) {
- if ((strcmp(tc->name, equiv->name) == 0))
- SWIG_TypeClientData(tc,clientdata);
- tc = tc->prev;
+
+ while (cast) {
+ if (!cast->converter) {
+ swig_type_info *tc = cast->type;
+ if (!tc->clientdata) {
+ SWIG_TypeClientData(tc, clientdata);
}
+ }
+ cast = cast->next;
+ }
+}
+SWIGRUNTIME void
+SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
+ SWIG_TypeClientData(ti, clientdata);
+ ti->owndata = 1;
+}
+
+/*
+ Search for a swig_type_info structure only by mangled name
+ Search is a O(log #types)
+
+ We start searching at module start, and finish searching when start == end.
+ Note: if start == end at the beginning of the function, we go all the way around
+ the circular list.
+*/
+SWIGRUNTIME swig_type_info *
+SWIG_MangledTypeQueryModule(swig_module_info *start,
+ swig_module_info *end,
+ const char *name) {
+ swig_module_info *iter = start;
+ do {
+ if (iter->size) {
+ register size_t l = 0;
+ register size_t r = iter->size - 1;
+ do {
+ /* since l+r >= 0, we can (>> 1) instead (/ 2) */
+ register size_t i = (l + r) >> 1;
+ const char *iname = iter->types[i]->name;
+ if (iname) {
+ register int compare = strcmp(name, iname);
+ if (compare == 0) {
+ return iter->types[i];
+ } else if (compare < 0) {
+ if (i) {
+ r = i - 1;
+ } else {
+ break;
+ }
+ } else if (compare > 0) {
+ l = i + 1;
+ }
+ } else {
+ break; /* should never happen */
+ }
+ } while (l <= r);
}
- equiv = equiv->next;
+ iter = iter->next;
+ } while (iter != end);
+ return 0;
+}
+
+/*
+ Search for a swig_type_info structure for either a mangled name or a human readable name.
+ It first searches the mangled names of the types, which is a O(log #types)
+ If a type is not found it then searches the human readable names, which is O(#types).
+
+ We start searching at module start, and finish searching when start == end.
+ Note: if start == end at the beginning of the function, we go all the way around
+ the circular list.
+*/
+SWIGRUNTIME swig_type_info *
+SWIG_TypeQueryModule(swig_module_info *start,
+ swig_module_info *end,
+ const char *name) {
+ /* STEP 1: Search the name field using binary search */
+ swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
+ if (ret) {
+ return ret;
+ } else {
+ /* STEP 2: If the type hasn't been found, do a complete search
+ of the str field (the human readable name) */
+ swig_module_info *iter = start;
+ do {
+ register size_t i = 0;
+ for (; i < iter->size; ++i) {
+ if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
+ return iter->types[i];
+ }
+ iter = iter->next;
+ } while (iter != end);
}
+
+ /* neither found a match */
+ return 0;
}
-/* Pack binary data into a string */
-SWIGRUNTIME(char *)
-SWIG_PackData(char *c, void *ptr, int sz) {
- static char hex[17] = "0123456789abcdef";
- int i;
- unsigned char *u = (unsigned char *) ptr;
- register unsigned char uu;
- for (i = 0; i < sz; i++,u++) {
- uu = *u;
+/*
+ Pack binary data into a string
+*/
+SWIGRUNTIME char *
+SWIG_PackData(char *c, void *ptr, size_t sz) {
+ static const char hex[17] = "0123456789abcdef";
+ register const unsigned char *u = (unsigned char *) ptr;
+ register const unsigned char *eu = u + sz;
+ for (; u != eu; ++u) {
+ register unsigned char uu = *u;
*(c++) = hex[(uu & 0xf0) >> 4];
*(c++) = hex[uu & 0xf];
}
return c;
}
-/* Unpack binary data from a string */
-SWIGRUNTIME(char *)
-SWIG_UnpackData(char *c, void *ptr, int sz) {
- register unsigned char uu = 0;
- register int d;
- unsigned char *u = (unsigned char *) ptr;
- int i;
- for (i = 0; i < sz; i++, u++) {
- d = *(c++);
+/*
+ Unpack binary data from a string
+*/
+SWIGRUNTIME const char *
+SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
+ register unsigned char *u = (unsigned char *) ptr;
+ register const unsigned char *eu = u + sz;
+ for (; u != eu; ++u) {
+ register char d = *(c++);
+ register unsigned char uu;
if ((d >= '0') && (d <= '9'))
uu = ((d - '0') << 4);
else if ((d >= 'a') && (d <= 'f'))
uu = ((d - ('a'-10)) << 4);
+ else
+ return (char *) 0;
d = *(c++);
if ((d >= '0') && (d <= '9'))
uu |= (d - '0');
else if ((d >= 'a') && (d <= 'f'))
uu |= (d - ('a'-10));
+ else
+ return (char *) 0;
*u = uu;
}
return c;
}
-#endif
+/*
+ Pack 'void *' into a string buffer.
+*/
+SWIGRUNTIME char *
+SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
+ char *r = buff;
+ if ((2*sizeof(void *) + 2) > bsz) return 0;
+ *(r++) = '_';
+ r = SWIG_PackData(r,&ptr,sizeof(void *));
+ if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
+ strcpy(r,name);
+ return buff;
+}
-#ifdef __cplusplus
+SWIGRUNTIME const char *
+SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
+ if (*c != '_') {
+ if (strcmp(c,"NULL") == 0) {
+ *ptr = (void *) 0;
+ return name;
+ } else {
+ return 0;
+ }
+ }
+ return SWIG_UnpackData(++c,ptr,sizeof(void *));
}
-#endif
-/***********************************************************************
- * python.swg
- *
- * This file contains the runtime support for Python modules
- * and includes code for managing global variables and pointer
- * type checking.
- *
- * Author : David Beazley (beazley@cs.uchicago.edu)
- ************************************************************************/
+SWIGRUNTIME char *
+SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
+ char *r = buff;
+ size_t lname = (name ? strlen(name) : 0);
+ if ((2*sz + 2 + lname) > bsz) return 0;
+ *(r++) = '_';
+ r = SWIG_PackData(r,ptr,sz);
+ if (lname) {
+ strncpy(r,name,lname+1);
+ } else {
+ *r = 0;
+ }
+ return buff;
+}
-#include "Python.h"
+SWIGRUNTIME const char *
+SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
+ if (*c != '_') {
+ if (strcmp(c,"NULL") == 0) {
+ memset(ptr,0,sz);
+ return name;
+ } else {
+ return 0;
+ }
+ }
+ return SWIG_UnpackData(++c,ptr,sz);
+}
#ifdef __cplusplus
-extern "C" {
+}
#endif
-#define SWIG_PY_INT 1
-#define SWIG_PY_FLOAT 2
-#define SWIG_PY_STRING 3
-#define SWIG_PY_POINTER 4
-#define SWIG_PY_BINARY 5
+/* Errors in SWIG */
+#define SWIG_UnknownError -1
+#define SWIG_IOError -2
+#define SWIG_RuntimeError -3
+#define SWIG_IndexError -4
+#define SWIG_TypeError -5
+#define SWIG_DivisionByZero -6
+#define SWIG_OverflowError -7
+#define SWIG_SyntaxError -8
+#define SWIG_ValueError -9
+#define SWIG_SystemError -10
+#define SWIG_AttributeError -11
+#define SWIG_MemoryError -12
+#define SWIG_NullReferenceError -13
+
+
+
+/* Python.h has to appear first */
+#include <Python.h>
+
+/* Add PyOS_snprintf for old Pythons */
+#if PY_VERSION_HEX < 0x02020000
+# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM)
+# define PyOS_snprintf _snprintf
+# else
+# define PyOS_snprintf snprintf
+# endif
+#endif
-/* Flags for pointer conversion */
+/* A crude PyString_FromFormat implementation for old Pythons */
+#if PY_VERSION_HEX < 0x02020000
-#define SWIG_POINTER_EXCEPTION 0x1
-#define SWIG_POINTER_DISOWN 0x2
+#ifndef SWIG_PYBUFFER_SIZE
+# define SWIG_PYBUFFER_SIZE 1024
+#endif
-/* Exception handling in wrappers */
-#define SWIG_fail goto fail
+static PyObject *
+PyString_FromFormat(const char *fmt, ...) {
+ va_list ap;
+ char buf[SWIG_PYBUFFER_SIZE * 2];
+ int res;
+ va_start(ap, fmt);
+ res = vsnprintf(buf, sizeof(buf), fmt, ap);
+ va_end(ap);
+ return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf);
+}
+#endif
-/* Constant information structure */
-typedef struct swig_const_info {
- int type;
- char *name;
- long lvalue;
- double dvalue;
- void *pvalue;
- swig_type_info **ptype;
-} swig_const_info;
+/* Add PyObject_Del for old Pythons */
+#if PY_VERSION_HEX < 0x01060000
+# define PyObject_Del(op) PyMem_DEL((op))
+#endif
+#ifndef PyObject_DEL
+# define PyObject_DEL PyObject_Del
+#endif
-/* Common SWIG API */
-#define SWIG_ConvertPtr(obj, pp, type, flags) \
- SWIG_Python_ConvertPtr(obj, pp, type, flags)
-#define SWIG_NewPointerObj(p, type, flags) \
- SWIG_Python_NewPointerObj(p, type, flags)
-#define SWIG_MustGetPtr(p, type, argnum, flags) \
- SWIG_Python_MustGetPtr(p, type, argnum, flags)
-
-/* Python-specific SWIG API */
-#define SWIG_newvarlink() \
- SWIG_Python_newvarlink()
-#define SWIG_addvarlink(p, name, get_attr, set_attr) \
- SWIG_Python_addvarlink(p, name, get_attr, set_attr)
-#define SWIG_ConvertPacked(obj, ptr, sz, ty, flags) \
- SWIG_Python_ConvertPacked(obj, ptr, sz, ty, flags)
-#define SWIG_NewPackedObj(ptr, sz, type) \
- SWIG_Python_NewPackedObj(ptr, sz, type)
-#define SWIG_InstallConstants(d, constants) \
- SWIG_Python_InstallConstants(d, constants)
-
-#ifdef SWIG_NOINCLUDE
-
-SWIGIMPORT(int) SWIG_Python_ConvertPtr(PyObject *, void **, swig_type_info *, int);
-SWIGIMPORT(PyObject *) SWIG_Python_NewPointerObj(void *, swig_type_info *,int own);
-SWIGIMPORT(void *) SWIG_Python_MustGetPtr(PyObject *, swig_type_info *, int, int);
-SWIGIMPORT(PyObject *) SWIG_Python_newvarlink(void);
-SWIGIMPORT(void) SWIG_Python_addvarlink(PyObject *, char *, PyObject *(*)(void), int (*)(PyObject *));
-SWIGIMPORT(int) SWIG_Python_ConvertPacked(PyObject *, void *, int sz, swig_type_info *, int);
-SWIGIMPORT(PyObject *) SWIG_Python_NewPackedObj(void *, int sz, swig_type_info *);
-SWIGIMPORT(void) SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]);
+/* A crude PyExc_StopIteration exception for old Pythons */
+#if PY_VERSION_HEX < 0x02020000
+# ifndef PyExc_StopIteration
+# define PyExc_StopIteration PyExc_RuntimeError
+# endif
+# ifndef PyObject_GenericGetAttr
+# define PyObject_GenericGetAttr 0
+# endif
+#endif
+/* Py_NotImplemented is defined in 2.1 and up. */
+#if PY_VERSION_HEX < 0x02010000
+# ifndef Py_NotImplemented
+# define Py_NotImplemented PyExc_RuntimeError
+# endif
+#endif
-#else
-/* -----------------------------------------------------------------------------
- * global variable support code.
- * ----------------------------------------------------------------------------- */
+/* A crude PyString_AsStringAndSize implementation for old Pythons */
+#if PY_VERSION_HEX < 0x02010000
+# ifndef PyString_AsStringAndSize
+# define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;}
+# endif
+#endif
-typedef struct swig_globalvar {
- char *name; /* Name of global variable */
- PyObject *(*get_attr)(void); /* Return the current value */
- int (*set_attr)(PyObject *); /* Set the value */
- struct swig_globalvar *next;
-} swig_globalvar;
+/* PySequence_Size for old Pythons */
+#if PY_VERSION_HEX < 0x02000000
+# ifndef PySequence_Size
+# define PySequence_Size PySequence_Length
+# endif
+#endif
-typedef struct swig_varlinkobject {
- PyObject_HEAD
- swig_globalvar *vars;
-} swig_varlinkobject;
-static PyObject *
-swig_varlink_repr(swig_varlinkobject *v) {
- v = v;
- return PyString_FromString("<Global variables>");
+/* PyBool_FromLong for old Pythons */
+#if PY_VERSION_HEX < 0x02030000
+static
+PyObject *PyBool_FromLong(long ok)
+{
+ PyObject *result = ok ? Py_True : Py_False;
+ Py_INCREF(result);
+ return result;
}
+#endif
+
-static int
-swig_varlink_print(swig_varlinkobject *v, FILE *fp, int flags) {
- swig_globalvar *var;
- flags = flags;
- fprintf(fp,"Global variables { ");
- for (var = v->vars; var; var=var->next) {
- fprintf(fp,"%s", var->name);
- if (var->next) fprintf(fp,", ");
+/* -----------------------------------------------------------------------------
+ * error manipulation
+ * ----------------------------------------------------------------------------- */
+
+SWIGRUNTIME PyObject*
+SWIG_Python_ErrorType(int code) {
+ PyObject* type = 0;
+ switch(code) {
+ case SWIG_MemoryError:
+ type = PyExc_MemoryError;
+ break;
+ case SWIG_IOError:
+ type = PyExc_IOError;
+ break;
+ case SWIG_RuntimeError:
+ type = PyExc_RuntimeError;
+ break;
+ case SWIG_IndexError:
+ type = PyExc_IndexError;
+ break;
+ case SWIG_TypeError:
+ type = PyExc_TypeError;
+ break;
+ case SWIG_DivisionByZero:
+ type = PyExc_ZeroDivisionError;
+ break;
+ case SWIG_OverflowError:
+ type = PyExc_OverflowError;
+ break;
+ case SWIG_SyntaxError:
+ type = PyExc_SyntaxError;
+ break;
+ case SWIG_ValueError:
+ type = PyExc_ValueError;
+ break;
+ case SWIG_SystemError:
+ type = PyExc_SystemError;
+ break;
+ case SWIG_AttributeError:
+ type = PyExc_AttributeError;
+ break;
+ default:
+ type = PyExc_RuntimeError;
+ }
+ return type;
+}
+
+
+SWIGRUNTIME void
+SWIG_Python_AddErrorMsg(const char* mesg)
+{
+ PyObject *type = 0;
+ PyObject *value = 0;
+ PyObject *traceback = 0;
+
+ if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback);
+ if (value) {
+ PyObject *old_str = PyObject_Str(value);
+ PyErr_Clear();
+ Py_XINCREF(type);
+ PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg);
+ Py_DECREF(old_str);
+ Py_DECREF(value);
+ } else {
+ PyErr_Format(PyExc_RuntimeError, mesg);
}
- fprintf(fp," }\n");
- return 0;
}
-static PyObject *
-swig_varlink_getattr(swig_varlinkobject *v, char *n) {
- swig_globalvar *var = v->vars;
- while (var) {
- if (strcmp(var->name,n) == 0) {
- return (*var->get_attr)();
- }
- var = var->next;
- }
- PyErr_SetString(PyExc_NameError,"Unknown C global variable");
- return NULL;
-}
-
-static int
-swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) {
- swig_globalvar *var = v->vars;
- while (var) {
- if (strcmp(var->name,n) == 0) {
- return (*var->set_attr)(p);
- }
- var = var->next;
- }
- PyErr_SetString(PyExc_NameError,"Unknown C global variable");
- return 1;
-}
-
-statichere PyTypeObject varlinktype = {
- PyObject_HEAD_INIT(0)
- 0,
- (char *)"swigvarlink", /* Type name */
- sizeof(swig_varlinkobject), /* Basic size */
- 0, /* Itemsize */
- 0, /* Deallocator */
- (printfunc) swig_varlink_print, /* Print */
- (getattrfunc) swig_varlink_getattr, /* get attr */
- (setattrfunc) swig_varlink_setattr, /* Set attr */
- 0, /* tp_compare */
- (reprfunc) swig_varlink_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_mapping*/
- 0, /* tp_hash */
-};
-/* Create a variable linking object for use later */
-SWIGRUNTIME(PyObject *)
-SWIG_Python_newvarlink(void) {
- swig_varlinkobject *result = 0;
- result = PyMem_NEW(swig_varlinkobject,1);
- varlinktype.ob_type = &PyType_Type; /* Patch varlinktype into a PyType */
- result->ob_type = &varlinktype;
- result->vars = 0;
- result->ob_refcnt = 0;
- Py_XINCREF((PyObject *) result);
- return ((PyObject*) result);
-}
-
-SWIGRUNTIME(void)
-SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) {
- swig_varlinkobject *v;
- swig_globalvar *gv;
- v= (swig_varlinkobject *) p;
- gv = (swig_globalvar *) malloc(sizeof(swig_globalvar));
- gv->name = (char *) malloc(strlen(name)+1);
- strcpy(gv->name,name);
- gv->get_attr = get_attr;
- gv->set_attr = set_attr;
- gv->next = v->vars;
- v->vars = gv;
-}
-/* Convert a pointer value */
-SWIGRUNTIME(int)
-SWIG_Python_ConvertPtr(PyObject *obj, void **ptr, swig_type_info *ty, int flags) {
- swig_type_info *tc;
- char *c = 0;
- static PyObject *SWIG_this = 0;
- int newref = 0;
- PyObject *pyobj = 0;
-
- if (!obj) return 0;
- if (obj == Py_None) {
- *ptr = 0;
- return 0;
- }
-#ifdef SWIG_COBJECT_TYPES
- if (!(PyCObject_Check(obj))) {
- if (!SWIG_this)
- SWIG_this = PyString_FromString("this");
- pyobj = obj;
- obj = PyObject_GetAttr(obj,SWIG_this);
- newref = 1;
- if (!obj) goto type_error;
- if (!PyCObject_Check(obj)) {
- Py_DECREF(obj);
- goto type_error;
- }
- }
- *ptr = PyCObject_AsVoidPtr(obj);
- c = (char *) PyCObject_GetDesc(obj);
- if (newref) Py_DECREF(obj);
- goto cobject;
-#else
- if (!(PyString_Check(obj))) {
- if (!SWIG_this)
- SWIG_this = PyString_FromString("this");
- pyobj = obj;
- obj = PyObject_GetAttr(obj,SWIG_this);
- newref = 1;
- if (!obj) goto type_error;
- if (!PyString_Check(obj)) {
- Py_DECREF(obj);
- goto type_error;
- }
- }
- c = PyString_AsString(obj);
- /* Pointer values must start with leading underscore */
- if (*c != '_') {
- *ptr = (void *) 0;
- if (strcmp(c,"NULL") == 0) {
- if (newref) { Py_DECREF(obj); }
- return 0;
- } else {
- if (newref) { Py_DECREF(obj); }
- goto type_error;
- }
- }
- c++;
- c = SWIG_UnpackData(c,ptr,sizeof(void *));
- if (newref) { Py_DECREF(obj); }
+#if defined(SWIG_PYTHON_NO_THREADS)
+# if defined(SWIG_PYTHON_THREADS)
+# undef SWIG_PYTHON_THREADS
+# endif
+#endif
+#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */
+# if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL)
+# if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */
+# define SWIG_PYTHON_USE_GIL
+# endif
+# endif
+# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */
+# ifndef SWIG_PYTHON_INITIALIZE_THREADS
+# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads()
+# endif
+# ifdef __cplusplus /* C++ code */
+ class SWIG_Python_Thread_Block {
+ bool status;
+ PyGILState_STATE state;
+ public:
+ void end() { if (status) { PyGILState_Release(state); status = false;} }
+ SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {}
+ ~SWIG_Python_Thread_Block() { end(); }
+ };
+ class SWIG_Python_Thread_Allow {
+ bool status;
+ PyThreadState *save;
+ public:
+ void end() { if (status) { PyEval_RestoreThread(save); status = false; }}
+ SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {}
+ ~SWIG_Python_Thread_Allow() { end(); }
+ };
+# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block
+# define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end()
+# define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow
+# define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end()
+# else /* C code */
+# define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure()
+# define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block)
+# define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread()
+# define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow)
+# endif
+# else /* Old thread way, not implemented, user must provide it */
+# if !defined(SWIG_PYTHON_INITIALIZE_THREADS)
+# define SWIG_PYTHON_INITIALIZE_THREADS
+# endif
+# if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK)
+# define SWIG_PYTHON_THREAD_BEGIN_BLOCK
+# endif
+# if !defined(SWIG_PYTHON_THREAD_END_BLOCK)
+# define SWIG_PYTHON_THREAD_END_BLOCK
+# endif
+# if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW)
+# define SWIG_PYTHON_THREAD_BEGIN_ALLOW
+# endif
+# if !defined(SWIG_PYTHON_THREAD_END_ALLOW)
+# define SWIG_PYTHON_THREAD_END_ALLOW
+# endif
+# endif
+#else /* No thread support */
+# define SWIG_PYTHON_INITIALIZE_THREADS
+# define SWIG_PYTHON_THREAD_BEGIN_BLOCK
+# define SWIG_PYTHON_THREAD_END_BLOCK
+# define SWIG_PYTHON_THREAD_BEGIN_ALLOW
+# define SWIG_PYTHON_THREAD_END_ALLOW
#endif
-#ifdef SWIG_COBJECT_TYPES
-cobject:
+/* -----------------------------------------------------------------------------
+ * Python API portion that goes into the runtime
+ * ----------------------------------------------------------------------------- */
+
+#ifdef __cplusplus
+extern "C" {
+#if 0
+} /* cc-mode */
+#endif
#endif
- if (ty) {
- tc = SWIG_TypeCheck(c,ty);
- if (!tc) goto type_error;
- *ptr = SWIG_TypeCast(tc,(void*) *ptr);
- }
+/* -----------------------------------------------------------------------------
+ * Constant declarations
+ * ----------------------------------------------------------------------------- */
- if ((pyobj) && (flags & SWIG_POINTER_DISOWN)) {
- PyObject *zero = PyInt_FromLong(0);
- PyObject_SetAttrString(pyobj,(char*)"thisown",zero);
- Py_DECREF(zero);
- }
- return 0;
+/* Constant Types */
+#define SWIG_PY_POINTER 4
+#define SWIG_PY_BINARY 5
-type_error:
- if (flags & SWIG_POINTER_EXCEPTION) {
- if (ty && c) {
- char *temp = (char *) malloc(64+strlen(ty->name)+strlen(c));
- sprintf(temp,"Type error. Got %s, expected %s", c, ty->name);
- PyErr_SetString(PyExc_TypeError, temp);
- free((char *) temp);
- } else {
- PyErr_SetString(PyExc_TypeError,"Expected a pointer");
- }
- }
- return -1;
-}
+/* Constant information structure */
+typedef struct swig_const_info {
+ int type;
+ char *name;
+ long lvalue;
+ double dvalue;
+ void *pvalue;
+ swig_type_info **ptype;
+} swig_const_info;
-/* Convert a pointer value, signal an exception on a type mismatch */
-SWIGRUNTIME(void *)
-SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) {
- void *result;
- SWIG_Python_ConvertPtr(obj, &result, ty, flags | SWIG_POINTER_EXCEPTION);
- return result;
+#ifdef __cplusplus
+#if 0
+{ /* cc-mode */
+#endif
}
+#endif
-/* Convert a packed value value */
-SWIGRUNTIME(int)
-SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, int sz, swig_type_info *ty, int flags) {
- swig_type_info *tc;
- char *c = 0;
-
- if ((!obj) || (!PyString_Check(obj))) goto type_error;
- c = PyString_AsString(obj);
- /* Pointer values must start with leading underscore */
- if (*c != '_') goto type_error;
- c++;
- c = SWIG_UnpackData(c,ptr,sz);
- if (ty) {
- tc = SWIG_TypeCheck(c,ty);
- if (!tc) goto type_error;
- }
- return 0;
-type_error:
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * pyrun.swg
+ *
+ * This file contains the runtime support for Python modules
+ * and includes code for managing global variables and pointer
+ * type checking.
+ *
+ * ----------------------------------------------------------------------------- */
- if (flags) {
- if (ty && c) {
- char *temp = (char *) malloc(64+strlen(ty->name)+strlen(c));
- sprintf(temp,"Type error. Got %s, expected %s", c, ty->name);
- PyErr_SetString(PyExc_TypeError, temp);
- free((char *) temp);
- } else {
- PyErr_SetString(PyExc_TypeError,"Expected a pointer");
- }
- }
- return -1;
-}
+/* Common SWIG API */
-/* Create a new pointer object */
-SWIGRUNTIME(PyObject *)
-SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int own) {
- PyObject *robj;
- if (!ptr) {
- Py_INCREF(Py_None);
- return Py_None;
- }
-#ifdef SWIG_COBJECT_TYPES
- robj = PyCObject_FromVoidPtrAndDesc((void *) ptr, (char *) type->name, NULL);
-#else
- {
- char result[1024];
- char *r = result;
- *(r++) = '_';
- r = SWIG_PackData(r,&ptr,sizeof(void *));
- strcpy(r,type->name);
- robj = PyString_FromString(result);
- }
-#endif
- if (!robj || (robj == Py_None)) return robj;
- if (type->clientdata) {
- PyObject *inst;
- PyObject *args = Py_BuildValue((char*)"(O)", robj);
- Py_DECREF(robj);
- inst = PyObject_CallObject((PyObject *) type->clientdata, args);
- Py_DECREF(args);
- if (inst) {
- if (own) {
- PyObject *n = PyInt_FromLong(1);
- PyObject_SetAttrString(inst,(char*)"thisown",n);
- Py_DECREF(n);
- }
- robj = inst;
- }
- }
- return robj;
-}
+/* for raw pointers */
+#define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0)
+#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags)
+#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own)
+#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(ptr, type, flags)
+#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty)
+#define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src)
+#define swig_owntype int
-SWIGRUNTIME(PyObject *)
-SWIG_Python_NewPackedObj(void *ptr, int sz, swig_type_info *type) {
- char result[1024];
- char *r = result;
- if ((2*sz + 1 + strlen(type->name)) > 1000) return 0;
- *(r++) = '_';
- r = SWIG_PackData(r,ptr,sz);
- strcpy(r,type->name);
- return PyString_FromString(result);
-}
+/* for raw packed data */
+#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
+#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
-/* Install Constants */
-SWIGRUNTIME(void)
-SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) {
- int i;
- PyObject *obj;
- for (i = 0; constants[i].type; i++) {
- switch(constants[i].type) {
- case SWIG_PY_INT:
- obj = PyInt_FromLong(constants[i].lvalue);
- break;
- case SWIG_PY_FLOAT:
- obj = PyFloat_FromDouble(constants[i].dvalue);
- break;
- case SWIG_PY_STRING:
- obj = PyString_FromString((char *) constants[i].pvalue);
- break;
- case SWIG_PY_POINTER:
- obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
- break;
- case SWIG_PY_BINARY:
- obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype));
- break;
- default:
- obj = 0;
- break;
- }
- if (obj) {
- PyDict_SetItemString(d,constants[i].name,obj);
- Py_DECREF(obj);
- }
- }
-}
+/* for class or struct pointers */
+#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags)
+#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags)
-#endif
+/* for C or C++ function pointers */
+#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type)
+#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(ptr, type, 0)
-/* Contract support */
+/* for C++ member pointers, ie, member methods */
+#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
+#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
-#define SWIG_contract_assert(expr, msg) if (!(expr)) { PyErr_SetString(PyExc_RuntimeError, (char *) msg ); goto fail; } else
-#ifdef __cplusplus
-}
-#endif
+/* Runtime API */
+#define SWIG_GetModule(clientdata) SWIG_Python_GetModule()
+#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer)
+#define SWIG_NewClientData(obj) PySwigClientData_New(obj)
-/* -------- TYPES TABLE (BEGIN) -------- */
+#define SWIG_SetErrorObj SWIG_Python_SetErrorObj
+#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg
+#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code)
+#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg)
+#define SWIG_fail goto fail
-#define SWIGTYPE_p_Radio swig_types[0]
-#define SWIGTYPE_p_nesc_app_t swig_types[1]
-#define SWIGTYPE_p_FILE swig_types[2]
-#define SWIGTYPE_p_MAC swig_types[3]
-#define SWIGTYPE_p_Packet swig_types[4]
-#define SWIGTYPE_p_Variable swig_types[5]
-#define SWIGTYPE_p_Tossim swig_types[6]
-#define SWIGTYPE_p_variable_string_t swig_types[7]
-#define SWIGTYPE_p_Mote swig_types[8]
-#define SWIGTYPE_p_p_char swig_types[9]
-#define SWIGTYPE_p_int swig_types[10]
-static swig_type_info *swig_types[12];
-/* -------- TYPES TABLE (END) -------- */
+/* Runtime API implementation */
+/* Error manipulation */
-/*-----------------------------------------------
- @(target):= _TOSSIM.so
- ------------------------------------------------*/
-#define SWIG_init init_TOSSIM
+SWIGINTERN void
+SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) {
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ PyErr_SetObject(errtype, obj);
+ Py_DECREF(obj);
+ SWIG_PYTHON_THREAD_END_BLOCK;
+}
-#define SWIG_name "_TOSSIM"
+SWIGINTERN void
+SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) {
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ PyErr_SetString(errtype, (char *) msg);
+ SWIG_PYTHON_THREAD_END_BLOCK;
+}
-#include <memory.h>
-#include <tossim.h>
+#define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj)
-enum {
+/* Set a constant value */
+
+SWIGINTERN void
+SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) {
+ PyDict_SetItemString(d, (char*) name, obj);
+ Py_DECREF(obj);
+}
+
+/* Append a value to the result obj */
+
+SWIGINTERN PyObject*
+SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {
+#if !defined(SWIG_PYTHON_OUTPUT_TUPLE)
+ if (!result) {
+ result = obj;
+ } else if (result == Py_None) {
+ Py_DECREF(result);
+ result = obj;
+ } else {
+ if (!PyList_Check(result)) {
+ PyObject *o2 = result;
+ result = PyList_New(1);
+ PyList_SetItem(result, 0, o2);
+ }
+ PyList_Append(result,obj);
+ Py_DECREF(obj);
+ }
+ return result;
+#else
+ PyObject* o2;
+ PyObject* o3;
+ if (!result) {
+ result = obj;
+ } else if (result == Py_None) {
+ Py_DECREF(result);
+ result = obj;
+ } else {
+ if (!PyTuple_Check(result)) {
+ o2 = result;
+ result = PyTuple_New(1);
+ PyTuple_SET_ITEM(result, 0, o2);
+ }
+ o3 = PyTuple_New(1);
+ PyTuple_SET_ITEM(o3, 0, obj);
+ o2 = result;
+ result = PySequence_Concat(o2, o3);
+ Py_DECREF(o2);
+ Py_DECREF(o3);
+ }
+ return result;
+#endif
+}
+
+/* Unpack the argument tuple */
+
+SWIGINTERN int
+SWIG_Python_UnpackTuple(PyObject *args, const char *name, int min, int max, PyObject **objs)
+{
+ if (!args) {
+ if (!min && !max) {
+ return 1;
+ } else {
+ PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none",
+ name, (min == max ? "" : "at least "), min);
+ return 0;
+ }
+ }
+ if (!PyTuple_Check(args)) {
+ PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple");
+ return 0;
+ } else {
+ register int l = PyTuple_GET_SIZE(args);
+ if (l < min) {
+ PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
+ name, (min == max ? "" : "at least "), min, l);
+ return 0;
+ } else if (l > max) {
+ PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
+ name, (min == max ? "" : "at most "), max, l);
+ return 0;
+ } else {
+ register int i;
+ for (i = 0; i < l; ++i) {
+ objs[i] = PyTuple_GET_ITEM(args, i);
+ }
+ for (; l < max; ++l) {
+ objs[l] = 0;
+ }
+ return i + 1;
+ }
+ }
+}
+
+/* A functor is a function object with one single object argument */
+#if PY_VERSION_HEX >= 0x02020000
+#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL);
+#else
+#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj);
+#endif
+
+/*
+ Helper for static pointer initialization for both C and C++ code, for example
+ static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...);
+*/
+#ifdef __cplusplus
+#define SWIG_STATIC_POINTER(var) var
+#else
+#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var
+#endif
+
+/* -----------------------------------------------------------------------------
+ * Pointer declarations
+ * ----------------------------------------------------------------------------- */
+
+/* Flags for new pointer objects */
+#define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1)
+#define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN)
+
+#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1)
+
+#ifdef __cplusplus
+extern "C" {
+#if 0
+} /* cc-mode */
+#endif
+#endif
+
+/* How to access Py_None */
+#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+# ifndef SWIG_PYTHON_NO_BUILD_NONE
+# ifndef SWIG_PYTHON_BUILD_NONE
+# define SWIG_PYTHON_BUILD_NONE
+# endif
+# endif
+#endif
+
+#ifdef SWIG_PYTHON_BUILD_NONE
+# ifdef Py_None
+# undef Py_None
+# define Py_None SWIG_Py_None()
+# endif
+SWIGRUNTIMEINLINE PyObject *
+_SWIG_Py_None(void)
+{
+ PyObject *none = Py_BuildValue("");
+ Py_DECREF(none);
+ return none;
+}
+SWIGRUNTIME PyObject *
+SWIG_Py_None(void)
+{
+ static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None();
+ return none;
+}
+#endif
+
+/* The python void return value */
+
+SWIGRUNTIMEINLINE PyObject *
+SWIG_Py_Void(void)
+{
+ PyObject *none = Py_None;
+ Py_INCREF(none);
+ return none;
+}
+
+/* PySwigClientData */
+
+typedef struct {
+ PyObject *klass;
+ PyObject *newraw;
+ PyObject *newargs;
+ PyObject *destroy;
+ int delargs;
+ int implicitconv;
+} PySwigClientData;
+
+SWIGRUNTIMEINLINE int
+SWIG_Python_CheckImplicit(swig_type_info *ty)
+{
+ PySwigClientData *data = (PySwigClientData *)ty->clientdata;
+ return data ? data->implicitconv : 0;
+}
+
+SWIGRUNTIMEINLINE PyObject *
+SWIG_Python_ExceptionType(swig_type_info *desc) {
+ PySwigClientData *data = desc ? (PySwigClientData *) desc->clientdata : 0;
+ PyObject *klass = data ? data->klass : 0;
+ return (klass ? klass : PyExc_RuntimeError);
+}
+
+
+SWIGRUNTIME PySwigClientData *
+PySwigClientData_New(PyObject* obj)
+{
+ if (!obj) {
+ return 0;
+ } else {
+ PySwigClientData *data = (PySwigClientData *)malloc(sizeof(PySwigClientData));
+ /* the klass element */
+ data->klass = obj;
+ Py_INCREF(data->klass);
+ /* the newraw method and newargs arguments used to create a new raw instance */
+ if (PyClass_Check(obj)) {
+ data->newraw = 0;
+ data->newargs = obj;
+ Py_INCREF(obj);
+ } else {
+#if (PY_VERSION_HEX < 0x02020000)
+ data->newraw = 0;
+#else
+ data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__");
+#endif
+ if (data->newraw) {
+ Py_INCREF(data->newraw);
+ data->newargs = PyTuple_New(1);
+ PyTuple_SetItem(data->newargs, 0, obj);
+ } else {
+ data->newargs = obj;
+ }
+ Py_INCREF(data->newargs);
+ }
+ /* the destroy method, aka as the C++ delete method */
+ data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__");
+ if (PyErr_Occurred()) {
+ PyErr_Clear();
+ data->destroy = 0;
+ }
+ if (data->destroy) {
+ int flags;
+ Py_INCREF(data->destroy);
+ flags = PyCFunction_GET_FLAGS(data->destroy);
+#ifdef METH_O
+ data->delargs = !(flags & (METH_O));
+#else
+ data->delargs = 0;
+#endif
+ } else {
+ data->delargs = 0;
+ }
+ data->implicitconv = 0;
+ return data;
+ }
+}
+
+SWIGRUNTIME void
+PySwigClientData_Del(PySwigClientData* data)
+{
+ Py_XDECREF(data->newraw);
+ Py_XDECREF(data->newargs);
+ Py_XDECREF(data->destroy);
+}
+
+/* =============== PySwigObject =====================*/
+
+typedef struct {
+ PyObject_HEAD
+ void *ptr;
+ swig_type_info *ty;
+ int own;
+ PyObject *next;
+} PySwigObject;
+
+SWIGRUNTIME PyObject *
+PySwigObject_long(PySwigObject *v)
+{
+ return PyLong_FromVoidPtr(v->ptr);
+}
+
+SWIGRUNTIME PyObject *
+PySwigObject_format(const char* fmt, PySwigObject *v)
+{
+ PyObject *res = NULL;
+ PyObject *args = PyTuple_New(1);
+ if (args) {
+ if (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0) {
+ PyObject *ofmt = PyString_FromString(fmt);
+ if (ofmt) {
+ res = PyString_Format(ofmt,args);
+ Py_DECREF(ofmt);
+ }
+ Py_DECREF(args);
+ }
+ }
+ return res;
+}
+
+SWIGRUNTIME PyObject *
+PySwigObject_oct(PySwigObject *v)
+{
+ return PySwigObject_format("%o",v);
+}
+
+SWIGRUNTIME PyObject *
+PySwigObject_hex(PySwigObject *v)
+{
+ return PySwigObject_format("%x",v);
+}
+
+SWIGRUNTIME PyObject *
+#ifdef METH_NOARGS
+PySwigObject_repr(PySwigObject *v)
+#else
+PySwigObject_repr(PySwigObject *v, PyObject *args)
+#endif
+{
+ const char *name = SWIG_TypePrettyName(v->ty);
+ PyObject *hex = PySwigObject_hex(v);
+ PyObject *repr = PyString_FromFormat("<Swig Object of type '%s' at 0x%s>", name, PyString_AsString(hex));
+ Py_DECREF(hex);
+ if (v->next) {
+#ifdef METH_NOARGS
+ PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next);
+#else
+ PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next, args);
+#endif
+ PyString_ConcatAndDel(&repr,nrep);
+ }
+ return repr;
+}
+
+SWIGRUNTIME int
+PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags))
+{
+#ifdef METH_NOARGS
+ PyObject *repr = PySwigObject_repr(v);
+#else
+ PyObject *repr = PySwigObject_repr(v, NULL);
+#endif
+ if (repr) {
+ fputs(PyString_AsString(repr), fp);
+ Py_DECREF(repr);
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
+SWIGRUNTIME PyObject *
+PySwigObject_str(PySwigObject *v)
+{
+ char result[SWIG_BUFFER_SIZE];
+ return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ?
+ PyString_FromString(result) : 0;
+}
+
+SWIGRUNTIME int
+PySwigObject_compare(PySwigObject *v, PySwigObject *w)
+{
+ void *i = v->ptr;
+ void *j = w->ptr;
+ return (i < j) ? -1 : ((i > j) ? 1 : 0);
+}
+
+SWIGRUNTIME PyTypeObject* _PySwigObject_type(void);
+
+SWIGRUNTIME PyTypeObject*
+PySwigObject_type(void) {
+ static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigObject_type();
+ return type;
+}
+
+SWIGRUNTIMEINLINE int
+PySwigObject_Check(PyObject *op) {
+ return ((op)->ob_type == PySwigObject_type())
+ || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0);
+}
+
+SWIGRUNTIME PyObject *
+PySwigObject_New(void *ptr, swig_type_info *ty, int own);
+
+SWIGRUNTIME void
+PySwigObject_dealloc(PyObject *v)
+{
+ PySwigObject *sobj = (PySwigObject *) v;
+ PyObject *next = sobj->next;
+ if (sobj->own) {
+ swig_type_info *ty = sobj->ty;
+ PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
+ PyObject *destroy = data ? data->destroy : 0;
+ if (destroy) {
+ /* destroy is always a VARARGS method */
+ PyObject *res;
+ if (data->delargs) {
+ /* we need to create a temporal object to carry the destroy operation */
+ PyObject *tmp = PySwigObject_New(sobj->ptr, ty, 0);
+ res = SWIG_Python_CallFunctor(destroy, tmp);
+ Py_DECREF(tmp);
+ } else {
+ PyCFunction meth = PyCFunction_GET_FUNCTION(destroy);
+ PyObject *mself = PyCFunction_GET_SELF(destroy);
+ res = ((*meth)(mself, v));
+ }
+ Py_XDECREF(res);
+ } else {
+ const char *name = SWIG_TypePrettyName(ty);
+#if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
+ printf("swig/python detected a memory leak of type '%s', no destructor found.\n", name);
+#endif
+ }
+ }
+ Py_XDECREF(next);
+ PyObject_DEL(v);
+}
+
+SWIGRUNTIME PyObject*
+PySwigObject_append(PyObject* v, PyObject* next)
+{
+ PySwigObject *sobj = (PySwigObject *) v;
+#ifndef METH_O
+ PyObject *tmp = 0;
+ if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL;
+ next = tmp;
+#endif
+ if (!PySwigObject_Check(next)) {
+ return NULL;
+ }
+ sobj->next = next;
+ Py_INCREF(next);
+ return SWIG_Py_Void();
+}
+
+SWIGRUNTIME PyObject*
+#ifdef METH_NOARGS
+PySwigObject_next(PyObject* v)
+#else
+PySwigObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
+#endif
+{
+ PySwigObject *sobj = (PySwigObject *) v;
+ if (sobj->next) {
+ Py_INCREF(sobj->next);
+ return sobj->next;
+ } else {
+ return SWIG_Py_Void();
+ }
+}
+
+SWIGINTERN PyObject*
+#ifdef METH_NOARGS
+PySwigObject_disown(PyObject *v)
+#else
+PySwigObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
+#endif
+{
+ PySwigObject *sobj = (PySwigObject *)v;
+ sobj->own = 0;
+ return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject*
+#ifdef METH_NOARGS
+PySwigObject_acquire(PyObject *v)
+#else
+PySwigObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
+#endif
+{
+ PySwigObject *sobj = (PySwigObject *)v;
+ sobj->own = SWIG_POINTER_OWN;
+ return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject*
+PySwigObject_own(PyObject *v, PyObject *args)
+{
+ PyObject *val = 0;
+#if (PY_VERSION_HEX < 0x02020000)
+ if (!PyArg_ParseTuple(args,(char *)"|O:own",&val))
+#else
+ if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val))
+#endif
+ {
+ return NULL;
+ }
+ else
+ {
+ PySwigObject *sobj = (PySwigObject *)v;
+ PyObject *obj = PyBool_FromLong(sobj->own);
+ if (val) {
+#ifdef METH_NOARGS
+ if (PyObject_IsTrue(val)) {
+ PySwigObject_acquire(v);
+ } else {
+ PySwigObject_disown(v);
+ }
+#else
+ if (PyObject_IsTrue(val)) {
+ PySwigObject_acquire(v,args);
+ } else {
+ PySwigObject_disown(v,args);
+ }
+#endif
+ }
+ return obj;
+ }
+}
+
+#ifdef METH_O
+static PyMethodDef
+swigobject_methods[] = {
+ {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"},
+ {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"},
+ {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
+ {(char *)"append", (PyCFunction)PySwigObject_append, METH_O, (char *)"appends another 'this' object"},
+ {(char *)"next", (PyCFunction)PySwigObject_next, METH_NOARGS, (char *)"returns the next 'this' object"},
+ {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_NOARGS, (char *)"returns object representation"},
+ {0, 0, 0, 0}
+};
+#else
+static PyMethodDef
+swigobject_methods[] = {
+ {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"},
+ {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"},
+ {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
+ {(char *)"append", (PyCFunction)PySwigObject_append, METH_VARARGS, (char *)"appends another 'this' object"},
+ {(char *)"next", (PyCFunction)PySwigObject_next, METH_VARARGS, (char *)"returns the next 'this' object"},
+ {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_VARARGS, (char *)"returns object representation"},
+ {0, 0, 0, 0}
+};
+#endif
+
+#if PY_VERSION_HEX < 0x02020000
+SWIGINTERN PyObject *
+PySwigObject_getattr(PySwigObject *sobj,char *name)
+{
+ return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name);
+}
+#endif
+
+SWIGRUNTIME PyTypeObject*
+_PySwigObject_type(void) {
+ static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer";
+
+ static PyNumberMethods PySwigObject_as_number = {
+ (binaryfunc)0, /*nb_add*/
+ (binaryfunc)0, /*nb_subtract*/
+ (binaryfunc)0, /*nb_multiply*/
+ (binaryfunc)0, /*nb_divide*/
+ (binaryfunc)0, /*nb_remainder*/
+ (binaryfunc)0, /*nb_divmod*/
+ (ternaryfunc)0,/*nb_power*/
+ (unaryfunc)0, /*nb_negative*/
+ (unaryfunc)0, /*nb_positive*/
+ (unaryfunc)0, /*nb_absolute*/
+ (inquiry)0, /*nb_nonzero*/
+ 0, /*nb_invert*/
+ 0, /*nb_lshift*/
+ 0, /*nb_rshift*/
+ 0, /*nb_and*/
+ 0, /*nb_xor*/
+ 0, /*nb_or*/
+ (coercion)0, /*nb_coerce*/
+ (unaryfunc)PySwigObject_long, /*nb_int*/
+ (unaryfunc)PySwigObject_long, /*nb_long*/
+ (unaryfunc)0, /*nb_float*/
+ (unaryfunc)PySwigObject_oct, /*nb_oct*/
+ (unaryfunc)PySwigObject_hex, /*nb_hex*/
+#if PY_VERSION_HEX >= 0x02020000
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */
+#elif PY_VERSION_HEX >= 0x02000000
+ 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */
+#endif
+ };
+
+ static PyTypeObject pyswigobject_type;
+ static int type_init = 0;
+ if (!type_init) {
+ const PyTypeObject tmp
+ = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ (char *)"PySwigObject", /* tp_name */
+ sizeof(PySwigObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)PySwigObject_dealloc, /* tp_dealloc */
+ (printfunc)PySwigObject_print, /* tp_print */
+#if PY_VERSION_HEX < 0x02020000
+ (getattrfunc)PySwigObject_getattr, /* tp_getattr */
+#else
+ (getattrfunc)0, /* tp_getattr */
+#endif
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)PySwigObject_compare, /* tp_compare */
+ (reprfunc)PySwigObject_repr, /* tp_repr */
+ &PySwigObject_as_number, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)PySwigObject_str, /* tp_str */
+ PyObject_GenericGetAttr, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ swigobject_doc, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+#if PY_VERSION_HEX >= 0x02020000
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ swigobject_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
+ 0, /* tp_free */
+ 0, /* tp_is_gc */
+ 0, /* tp_bases */
+ 0, /* tp_mro */
+ 0, /* tp_cache */
+ 0, /* tp_subclasses */
+ 0, /* tp_weaklist */
+#endif
+#if PY_VERSION_HEX >= 0x02030000
+ 0, /* tp_del */
+#endif
+#ifdef COUNT_ALLOCS
+ 0,0,0,0 /* tp_alloc -> tp_next */
+#endif
+ };
+ pyswigobject_type = tmp;
+ pyswigobject_type.ob_type = &PyType_Type;
+ type_init = 1;
+ }
+ return &pyswigobject_type;
+}
+
+SWIGRUNTIME PyObject *
+PySwigObject_New(void *ptr, swig_type_info *ty, int own)
+{
+ PySwigObject *sobj = PyObject_NEW(PySwigObject, PySwigObject_type());
+ if (sobj) {
+ sobj->ptr = ptr;
+ sobj->ty = ty;
+ sobj->own = own;
+ sobj->next = 0;
+ }
+ return (PyObject *)sobj;
+}
+
+/* -----------------------------------------------------------------------------
+ * Implements a simple Swig Packed type, and use it instead of string
+ * ----------------------------------------------------------------------------- */
+
+typedef struct {
+ PyObject_HEAD
+ void *pack;
+ swig_type_info *ty;
+ size_t size;
+} PySwigPacked;
+
+SWIGRUNTIME int
+PySwigPacked_print(PySwigPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags))
+{
+ char result[SWIG_BUFFER_SIZE];
+ fputs("<Swig Packed ", fp);
+ if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
+ fputs("at ", fp);
+ fputs(result, fp);
+ }
+ fputs(v->ty->name,fp);
+ fputs(">", fp);
+ return 0;
+}
+
+SWIGRUNTIME PyObject *
+PySwigPacked_repr(PySwigPacked *v)
+{
+ char result[SWIG_BUFFER_SIZE];
+ if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
+ return PyString_FromFormat("<Swig Packed at %s%s>", result, v->ty->name);
+ } else {
+ return PyString_FromFormat("<Swig Packed %s>", v->ty->name);
+ }
+}
+
+SWIGRUNTIME PyObject *
+PySwigPacked_str(PySwigPacked *v)
+{
+ char result[SWIG_BUFFER_SIZE];
+ if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){
+ return PyString_FromFormat("%s%s", result, v->ty->name);
+ } else {
+ return PyString_FromString(v->ty->name);
+ }
+}
+
+SWIGRUNTIME int
+PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w)
+{
+ size_t i = v->size;
+ size_t j = w->size;
+ int s = (i < j) ? -1 : ((i > j) ? 1 : 0);
+ return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size);
+}
+
+SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void);
+
+SWIGRUNTIME PyTypeObject*
+PySwigPacked_type(void) {
+ static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigPacked_type();
+ return type;
+}
+
+SWIGRUNTIMEINLINE int
+PySwigPacked_Check(PyObject *op) {
+ return ((op)->ob_type == _PySwigPacked_type())
+ || (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0);
+}
+
+SWIGRUNTIME void
+PySwigPacked_dealloc(PyObject *v)
+{
+ if (PySwigPacked_Check(v)) {
+ PySwigPacked *sobj = (PySwigPacked *) v;
+ free(sobj->pack);
+ }
+ PyObject_DEL(v);
+}
+
+SWIGRUNTIME PyTypeObject*
+_PySwigPacked_type(void) {
+ static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer";
+ static PyTypeObject pyswigpacked_type;
+ static int type_init = 0;
+ if (!type_init) {
+ const PyTypeObject tmp
+ = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ (char *)"PySwigPacked", /* tp_name */
+ sizeof(PySwigPacked), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)PySwigPacked_dealloc, /* tp_dealloc */
+ (printfunc)PySwigPacked_print, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)PySwigPacked_compare, /* tp_compare */
+ (reprfunc)PySwigPacked_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)PySwigPacked_str, /* tp_str */
+ PyObject_GenericGetAttr, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ swigpacked_doc, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+#if PY_VERSION_HEX >= 0x02020000
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
+ 0, /* tp_free */
+ 0, /* tp_is_gc */
+ 0, /* tp_bases */
+ 0, /* tp_mro */
+ 0, /* tp_cache */
+ 0, /* tp_subclasses */
+ 0, /* tp_weaklist */
+#endif
+#if PY_VERSION_HEX >= 0x02030000
+ 0, /* tp_del */
+#endif
+#ifdef COUNT_ALLOCS
+ 0,0,0,0 /* tp_alloc -> tp_next */
+#endif
+ };
+ pyswigpacked_type = tmp;
+ pyswigpacked_type.ob_type = &PyType_Type;
+ type_init = 1;
+ }
+ return &pyswigpacked_type;
+}
+
+SWIGRUNTIME PyObject *
+PySwigPacked_New(void *ptr, size_t size, swig_type_info *ty)
+{
+ PySwigPacked *sobj = PyObject_NEW(PySwigPacked, PySwigPacked_type());
+ if (sobj) {
+ void *pack = malloc(size);
+ if (pack) {
+ memcpy(pack, ptr, size);
+ sobj->pack = pack;
+ sobj->ty = ty;
+ sobj->size = size;
+ } else {
+ PyObject_DEL((PyObject *) sobj);
+ sobj = 0;
+ }
+ }
+ return (PyObject *) sobj;
+}
+
+SWIGRUNTIME swig_type_info *
+PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size)
+{
+ if (PySwigPacked_Check(obj)) {
+ PySwigPacked *sobj = (PySwigPacked *)obj;
+ if (sobj->size != size) return 0;
+ memcpy(ptr, sobj->pack, size);
+ return sobj->ty;
+ } else {
+ return 0;
+ }
+}
+
+/* -----------------------------------------------------------------------------
+ * pointers/data manipulation
+ * ----------------------------------------------------------------------------- */
+
+SWIGRUNTIMEINLINE PyObject *
+_SWIG_This(void)
+{
+ return PyString_FromString("this");
+}
+
+SWIGRUNTIME PyObject *
+SWIG_This(void)
+{
+ static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This();
+ return swig_this;
+}
+
+/* #define SWIG_PYTHON_SLOW_GETSET_THIS */
+
+SWIGRUNTIME PySwigObject *
+SWIG_Python_GetSwigThis(PyObject *pyobj)
+{
+ if (PySwigObject_Check(pyobj)) {
+ return (PySwigObject *) pyobj;
+ } else {
+ PyObject *obj = 0;
+#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000))
+ if (PyInstance_Check(pyobj)) {
+ obj = _PyInstance_Lookup(pyobj, SWIG_This());
+ } else {
+ PyObject **dictptr = _PyObject_GetDictPtr(pyobj);
+ if (dictptr != NULL) {
+ PyObject *dict = *dictptr;
+ obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0;
+ } else {
+#ifdef PyWeakref_CheckProxy
+ if (PyWeakref_CheckProxy(pyobj)) {
+ PyObject *wobj = PyWeakref_GET_OBJECT(pyobj);
+ return wobj ? SWIG_Python_GetSwigThis(wobj) : 0;
+ }
+#endif
+ obj = PyObject_GetAttr(pyobj,SWIG_This());
+ if (obj) {
+ Py_DECREF(obj);
+ } else {
+ if (PyErr_Occurred()) PyErr_Clear();
+ return 0;
+ }
+ }
+ }
+#else
+ obj = PyObject_GetAttr(pyobj,SWIG_This());
+ if (obj) {
+ Py_DECREF(obj);
+ } else {
+ if (PyErr_Occurred()) PyErr_Clear();
+ return 0;
+ }
+#endif
+ if (obj && !PySwigObject_Check(obj)) {
+ /* a PyObject is called 'this', try to get the 'real this'
+ PySwigObject from it */
+ return SWIG_Python_GetSwigThis(obj);
+ }
+ return (PySwigObject *)obj;
+ }
+}
+
+/* Acquire a pointer value */
+
+SWIGRUNTIME int
+SWIG_Python_AcquirePtr(PyObject *obj, int own) {
+ if (own) {
+ PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
+ if (sobj) {
+ int oldown = sobj->own;
+ sobj->own = own;
+ return oldown;
+ }
+ }
+ return 0;
+}
+
+/* Convert a pointer value */
+
+SWIGRUNTIME int
+SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) {
+ if (!obj) return SWIG_ERROR;
+ if (obj == Py_None) {
+ if (ptr) *ptr = 0;
+ return SWIG_OK;
+ } else {
+ PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
+ while (sobj) {
+ void *vptr = sobj->ptr;
+ if (ty) {
+ swig_type_info *to = sobj->ty;
+ if (to == ty) {
+ /* no type cast needed */
+ if (ptr) *ptr = vptr;
+ break;
+ } else {
+ swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
+ if (!tc) {
+ sobj = (PySwigObject *)sobj->next;
+ } else {
+ if (ptr) *ptr = SWIG_TypeCast(tc,vptr);
+ break;
+ }
+ }
+ } else {
+ if (ptr) *ptr = vptr;
+ break;
+ }
+ }
+ if (sobj) {
+ if (own) *own = sobj->own;
+ if (flags & SWIG_POINTER_DISOWN) {
+ sobj->own = 0;
+ }
+ return SWIG_OK;
+ } else {
+ int res = SWIG_ERROR;
+ if (flags & SWIG_POINTER_IMPLICIT_CONV) {
+ PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
+ if (data && !data->implicitconv) {
+ PyObject *klass = data->klass;
+ if (klass) {
+ PyObject *impconv;
+ data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/
+ impconv = SWIG_Python_CallFunctor(klass, obj);
+ data->implicitconv = 0;
+ if (PyErr_Occurred()) {
+ PyErr_Clear();
+ impconv = 0;
+ }
+ if (impconv) {
+ PySwigObject *iobj = SWIG_Python_GetSwigThis(impconv);
+ if (iobj) {
+ void *vptr;
+ res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0);
+ if (SWIG_IsOK(res)) {
+ if (ptr) {
+ *ptr = vptr;
+ /* transfer the ownership to 'ptr' */
+ iobj->own = 0;
+ res = SWIG_AddCast(res);
+ res = SWIG_AddNewMask(res);
+ } else {
+ res = SWIG_AddCast(res);
+ }
+ }
+ }
+ Py_DECREF(impconv);
+ }
+ }
+ }
+ }
+ return res;
+ }
+ }
+}
+
+/* Convert a function ptr value */
+
+SWIGRUNTIME int
+SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
+ if (!PyCFunction_Check(obj)) {
+ return SWIG_ConvertPtr(obj, ptr, ty, 0);
+ } else {
+ void *vptr = 0;
+
+ /* here we get the method pointer for callbacks */
+ char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);
+ const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0;
+ if (desc) {
+ desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0;
+ if (!desc) return SWIG_ERROR;
+ }
+ if (ty) {
+ swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
+ if (!tc) return SWIG_ERROR;
+ *ptr = SWIG_TypeCast(tc,vptr);
+ } else {
+ *ptr = vptr;
+ }
+ return SWIG_OK;
+ }
+}
+
+/* Convert a packed value value */
+
+SWIGRUNTIME int
+SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) {
+ swig_type_info *to = PySwigPacked_UnpackData(obj, ptr, sz);
+ if (!to) return SWIG_ERROR;
+ if (ty) {
+ if (to != ty) {
+ /* check type cast? */
+ swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
+ if (!tc) return SWIG_ERROR;
+ }
+ }
+ return SWIG_OK;
+}
+
+/* -----------------------------------------------------------------------------
+ * Create a new pointer object
+ * ----------------------------------------------------------------------------- */
+
+/*
+ Create a new instance object, whitout calling __init__, and set the
+ 'this' attribute.
+*/
+
+SWIGRUNTIME PyObject*
+SWIG_Python_NewShadowInstance(PySwigClientData *data, PyObject *swig_this)
+{
+#if (PY_VERSION_HEX >= 0x02020000)
+ PyObject *inst = 0;
+ PyObject *newraw = data->newraw;
+ if (newraw) {
+ inst = PyObject_Call(newraw, data->newargs, NULL);
+ if (inst) {
+#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
+ PyObject **dictptr = _PyObject_GetDictPtr(inst);
+ if (dictptr != NULL) {
+ PyObject *dict = *dictptr;
+ if (dict == NULL) {
+ dict = PyDict_New();
+ *dictptr = dict;
+ PyDict_SetItem(dict, SWIG_This(), swig_this);
+ }
+ }
+#else
+ PyObject *key = SWIG_This();
+ PyObject_SetAttr(inst, key, swig_this);
+#endif
+ }
+ } else {
+ PyObject *dict = PyDict_New();
+ PyDict_SetItem(dict, SWIG_This(), swig_this);
+ inst = PyInstance_NewRaw(data->newargs, dict);
+ Py_DECREF(dict);
+ }
+ return inst;
+#else
+#if (PY_VERSION_HEX >= 0x02010000)
+ PyObject *inst;
+ PyObject *dict = PyDict_New();
+ PyDict_SetItem(dict, SWIG_This(), swig_this);
+ inst = PyInstance_NewRaw(data->newargs, dict);
+ Py_DECREF(dict);
+ return (PyObject *) inst;
+#else
+ PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type);
+ if (inst == NULL) {
+ return NULL;
+ }
+ inst->in_class = (PyClassObject *)data->newargs;
+ Py_INCREF(inst->in_class);
+ inst->in_dict = PyDict_New();
+ if (inst->in_dict == NULL) {
+ Py_DECREF(inst);
+ return NULL;
+ }
+#ifdef Py_TPFLAGS_HAVE_WEAKREFS
+ inst->in_weakreflist = NULL;
+#endif
+#ifdef Py_TPFLAGS_GC
+ PyObject_GC_Init(inst);
+#endif
+ PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this);
+ return (PyObject *) inst;
+#endif
+#endif
+}
+
+SWIGRUNTIME void
+SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this)
+{
+ PyObject *dict;
+#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
+ PyObject **dictptr = _PyObject_GetDictPtr(inst);
+ if (dictptr != NULL) {
+ dict = *dictptr;
+ if (dict == NULL) {
+ dict = PyDict_New();
+ *dictptr = dict;
+ }
+ PyDict_SetItem(dict, SWIG_This(), swig_this);
+ return;
+ }
+#endif
+ dict = PyObject_GetAttrString(inst, "__dict__");
+ PyDict_SetItem(dict, SWIG_This(), swig_this);
+ Py_DECREF(dict);
+}
+
+
+SWIGINTERN PyObject *
+SWIG_Python_InitShadowInstance(PyObject *args) {
+ PyObject *obj[2];
+ if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) {
+ return NULL;
+ } else {
+ PySwigObject *sthis = SWIG_Python_GetSwigThis(obj[0]);
+ if (sthis) {
+ PySwigObject_append((PyObject*) sthis, obj[1]);
+ } else {
+ SWIG_Python_SetSwigThis(obj[0], obj[1]);
+ }
+ return SWIG_Py_Void();
+ }
+}
+
+/* Create a new pointer object */
+
+SWIGRUNTIME PyObject *
+SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) {
+ if (!ptr) {
+ return SWIG_Py_Void();
+ } else {
+ int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0;
+ PyObject *robj = PySwigObject_New(ptr, type, own);
+ PySwigClientData *clientdata = type ? (PySwigClientData *)(type->clientdata) : 0;
+ if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) {
+ PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj);
+ if (inst) {
+ Py_DECREF(robj);
+ robj = inst;
+ }
+ }
+ return robj;
+ }
+}
+
+/* Create a new packed object */
+
+SWIGRUNTIMEINLINE PyObject *
+SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
+ return ptr ? PySwigPacked_New((void *) ptr, sz, type) : SWIG_Py_Void();
+}
+
+/* -----------------------------------------------------------------------------*
+ * Get type list
+ * -----------------------------------------------------------------------------*/
+
+#ifdef SWIG_LINK_RUNTIME
+void *SWIG_ReturnGlobalTypeList(void *);
+#endif
+
+SWIGRUNTIME swig_module_info *
+SWIG_Python_GetModule(void) {
+ static void *type_pointer = (void *)0;
+ /* first check if module already created */
+ if (!type_pointer) {
+#ifdef SWIG_LINK_RUNTIME
+ type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
+#else
+ type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
+ (char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
+ if (PyErr_Occurred()) {
+ PyErr_Clear();
+ type_pointer = (void *)0;
+ }
+#endif
+ }
+ return (swig_module_info *) type_pointer;
+}
+
+#if PY_MAJOR_VERSION < 2
+/* PyModule_AddObject function was introduced in Python 2.0. The following function
+ is copied out of Python/modsupport.c in python version 2.3.4 */
+SWIGINTERN int
+PyModule_AddObject(PyObject *m, char *name, PyObject *o)
+{
+ PyObject *dict;
+ if (!PyModule_Check(m)) {
+ PyErr_SetString(PyExc_TypeError,
+ "PyModule_AddObject() needs module as first arg");
+ return SWIG_ERROR;
+ }
+ if (!o) {
+ PyErr_SetString(PyExc_TypeError,
+ "PyModule_AddObject() needs non-NULL value");
+ return SWIG_ERROR;
+ }
+
+ dict = PyModule_GetDict(m);
+ if (dict == NULL) {
+ /* Internal error -- modules must have a dict! */
+ PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__",
+ PyModule_GetName(m));
+ return SWIG_ERROR;
+ }
+ if (PyDict_SetItemString(dict, name, o))
+ return SWIG_ERROR;
+ Py_DECREF(o);
+ return SWIG_OK;
+}
+#endif
+
+SWIGRUNTIME void
+SWIG_Python_DestroyModule(void *vptr)
+{
+ swig_module_info *swig_module = (swig_module_info *) vptr;
+ swig_type_info **types = swig_module->types;
+ size_t i;
+ for (i =0; i < swig_module->size; ++i) {
+ swig_type_info *ty = types[i];
+ if (ty->owndata) {
+ PySwigClientData *data = (PySwigClientData *) ty->clientdata;
+ if (data) PySwigClientData_Del(data);
+ }
+ }
+ Py_DECREF(SWIG_This());
+}
+
+SWIGRUNTIME void
+SWIG_Python_SetModule(swig_module_info *swig_module) {
+ static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */
+
+ PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
+ swig_empty_runtime_method_table);
+ PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
+ if (pointer && module) {
+ PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
+ } else {
+ Py_XDECREF(pointer);
+ }
+}
+
+/* The python cached type query */
+SWIGRUNTIME PyObject *
+SWIG_Python_TypeCache() {
+ static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New();
+ return cache;
+}
+
+SWIGRUNTIME swig_type_info *
+SWIG_Python_TypeQuery(const char *type)
+{
+ PyObject *cache = SWIG_Python_TypeCache();
+ PyObject *key = PyString_FromString(type);
+ PyObject *obj = PyDict_GetItem(cache, key);
+ swig_type_info *descriptor;
+ if (obj) {
+ descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
+ } else {
+ swig_module_info *swig_module = SWIG_Python_GetModule();
+ descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
+ if (descriptor) {
+ obj = PyCObject_FromVoidPtr(descriptor, NULL);
+ PyDict_SetItem(cache, key, obj);
+ Py_DECREF(obj);
+ }
+ }
+ Py_DECREF(key);
+ return descriptor;
+}
+
+/*
+ For backward compatibility only
+*/
+#define SWIG_POINTER_EXCEPTION 0
+#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg)
+#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags)
+
+SWIGRUNTIME int
+SWIG_Python_AddErrMesg(const char* mesg, int infront)
+{
+ if (PyErr_Occurred()) {
+ PyObject *type = 0;
+ PyObject *value = 0;
+ PyObject *traceback = 0;
+ PyErr_Fetch(&type, &value, &traceback);
+ if (value) {
+ PyObject *old_str = PyObject_Str(value);
+ Py_XINCREF(type);
+ PyErr_Clear();
+ if (infront) {
+ PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str));
+ } else {
+ PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg);
+ }
+ Py_DECREF(old_str);
+ }
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+SWIGRUNTIME int
+SWIG_Python_ArgFail(int argnum)
+{
+ if (PyErr_Occurred()) {
+ /* add information about failing argument */
+ char mesg[256];
+ PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum);
+ return SWIG_Python_AddErrMesg(mesg, 1);
+ } else {
+ return 0;
+ }
+}
+
+SWIGRUNTIMEINLINE const char *
+PySwigObject_GetDesc(PyObject *self)
+{
+ PySwigObject *v = (PySwigObject *)self;
+ swig_type_info *ty = v ? v->ty : 0;
+ return ty ? ty->str : (char*)"";
+}
+
+SWIGRUNTIME void
+SWIG_Python_TypeError(const char *type, PyObject *obj)
+{
+ if (type) {
+#if defined(SWIG_COBJECT_TYPES)
+ if (obj && PySwigObject_Check(obj)) {
+ const char *otype = (const char *) PySwigObject_GetDesc(obj);
+ if (otype) {
+ PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received",
+ type, otype);
+ return;
+ }
+ } else
+#endif
+ {
+ const char *otype = (obj ? obj->ob_type->tp_name : 0);
+ if (otype) {
+ PyObject *str = PyObject_Str(obj);
+ const char *cstr = str ? PyString_AsString(str) : 0;
+ if (cstr) {
+ PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received",
+ type, otype, cstr);
+ } else {
+ PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received",
+ type, otype);
+ }
+ Py_XDECREF(str);
+ return;
+ }
+ }
+ PyErr_Format(PyExc_TypeError, "a '%s' is expected", type);
+ } else {
+ PyErr_Format(PyExc_TypeError, "unexpected type is received");
+ }
+}
+
+
+/* Convert a pointer value, signal an exception on a type mismatch */
+SWIGRUNTIME void *
+SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) {
+ void *result;
+ if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) {
+ PyErr_Clear();
+ if (flags & SWIG_POINTER_EXCEPTION) {
+ SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
+ SWIG_Python_ArgFail(argnum);
+ }
+ }
+ return result;
+}
+
+
+#ifdef __cplusplus
+#if 0
+{ /* cc-mode */
+#endif
+}
+#endif
+
+
+
+#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0)
+
+#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else
+
+
+
+/* -------- TYPES TABLE (BEGIN) -------- */
+
+#define SWIGTYPE_p_FILE swig_types[0]
+#define SWIGTYPE_p_MAC swig_types[1]
+#define SWIGTYPE_p_Mote swig_types[2]
+#define SWIGTYPE_p_Packet swig_types[3]
+#define SWIGTYPE_p_Radio swig_types[4]
+#define SWIGTYPE_p_Tossim swig_types[5]
+#define SWIGTYPE_p_Variable swig_types[6]
+#define SWIGTYPE_p_char swig_types[7]
+#define SWIGTYPE_p_int swig_types[8]
+#define SWIGTYPE_p_nesc_app swig_types[9]
+#define SWIGTYPE_p_p_char swig_types[10]
+#define SWIGTYPE_p_var_string swig_types[11]
+static swig_type_info *swig_types[13];
+static swig_module_info swig_module = {swig_types, 12, 0, 0, 0, 0};
+#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
+#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
+
+/* -------- TYPES TABLE (END) -------- */
+
+#if (PY_VERSION_HEX <= 0x02000000)
+# if !defined(SWIG_PYTHON_CLASSIC)
+# error "This python version requires to use swig with the '-classic' option"
+# endif
+#endif
+
+/*-----------------------------------------------
+ @(target):= _TOSSIM.so
+ ------------------------------------------------*/
+#define SWIG_init init_TOSSIM
+
+#define SWIG_name "_TOSSIM"
+
+#define SWIGVERSION 0x010329
+
+
+#define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a))
+#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast< void** >(a))
+
+
+#include <stdexcept>
+
+
+namespace swig {
+ class PyObject_ptr {
+ protected:
+ PyObject *_obj;
+
+ public:
+ PyObject_ptr() :_obj(0)
+ {
+ }
+
+ PyObject_ptr(const PyObject_ptr& item) : _obj(item._obj)
+ {
+ Py_XINCREF(_obj);
+ }
+
+ PyObject_ptr(PyObject *obj, bool initial_ref = true) :_obj(obj)
+ {
+ if (initial_ref) Py_XINCREF(_obj);
+ }
+
+ PyObject_ptr & operator=(const PyObject_ptr& item)
+ {
+ Py_XINCREF(item._obj);
+ Py_XDECREF(_obj);
+ _obj = item._obj;
+ return *this;
+ }
+
+ ~PyObject_ptr()
+ {
+ Py_XDECREF(_obj);
+ }
+
+ operator PyObject *() const
+ {
+ return _obj;
+ }
+
+ PyObject *operator->() const
+ {
+ return _obj;
+ }
+ };
+}
+
+
+namespace swig {
+ struct PyObject_var : PyObject_ptr {
+ PyObject_var(PyObject* obj = 0) : PyObject_ptr(obj, false) { }
+
+ PyObject_var & operator = (PyObject* obj)
+ {
+ Py_XDECREF(_obj);
+ _obj = obj;
+ return *this;
+ }
+ };
+}
+
+
+#include <memory.h>
+#include <tossim.h>
+
+enum {
PRIMITIVE_INTEGER = 0,
PRIMITIVE_FLOAT = 1,
PRIMITIVE_UNKNOWN = 2
#include <mac.h>
+ #define SWIG_From_long PyInt_FromLong
+
+
+SWIGINTERNINLINE PyObject *
+SWIG_From_int (int value)
+{
+ return SWIG_From_long (value);
+}
+
+
+#include <limits.h>
+#ifndef LLONG_MIN
+# define LLONG_MIN LONG_LONG_MIN
+#endif
+#ifndef LLONG_MAX
+# define LLONG_MAX LONG_LONG_MAX
+#endif
+#ifndef ULLONG_MAX
+# define ULLONG_MAX ULONG_LONG_MAX
+#endif
+
+
+SWIGINTERN int
+SWIG_AsVal_double (PyObject *obj, double *val)
+{
+ int res = SWIG_TypeError;
+ if (PyFloat_Check(obj)) {
+ if (val) *val = PyFloat_AsDouble(obj);
+ return SWIG_OK;
+ } else if (PyInt_Check(obj)) {
+ if (val) *val = PyInt_AsLong(obj);
+ return SWIG_OK;
+ } else if (PyLong_Check(obj)) {
+ double v = PyLong_AsDouble(obj);
+ if (!PyErr_Occurred()) {
+ if (val) *val = v;
+ return SWIG_OK;
+ } else {
+ PyErr_Clear();
+ }
+ }
+#ifdef SWIG_PYTHON_CAST_MODE
+ {
+ int dispatch = 0;
+ double d = PyFloat_AsDouble(obj);
+ if (!PyErr_Occurred()) {
+ if (val) *val = d;
+ return SWIG_AddCast(SWIG_OK);
+ } else {
+ PyErr_Clear();
+ }
+ if (!dispatch) {
+ long v = PyLong_AsLong(obj);
+ if (!PyErr_Occurred()) {
+ if (val) *val = v;
+ return SWIG_AddCast(SWIG_AddCast(SWIG_OK));
+ } else {
+ PyErr_Clear();
+ }
+ }
+ }
+#endif
+ return res;
+}
+
+
+#include <float.h>
+
+
+#include <math.h>
+
+
+SWIGINTERNINLINE int
+SWIG_CanCastAsInteger(double *d, double min, double max) {
+ double x = *d;
+ if ((min <= x && x <= max)) {
+ double fx = floor(x);
+ double cx = ceil(x);
+ double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */
+ if ((errno == EDOM) || (errno == ERANGE)) {
+ errno = 0;
+ } else {
+ double summ, reps, diff;
+ if (rd < x) {
+ diff = x - rd;
+ } else if (rd > x) {
+ diff = rd - x;
+ } else {
+ return 1;
+ }
+ summ = rd + x;
+ reps = diff/summ;
+ if (reps < 8*DBL_EPSILON) {
+ *d = rd;
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
+
+SWIGINTERN int
+SWIG_AsVal_long (PyObject *obj, long* val)
+{
+ if (PyInt_Check(obj)) {
+ if (val) *val = PyInt_AsLong(obj);
+ return SWIG_OK;
+ } else if (PyLong_Check(obj)) {
+ long v = PyLong_AsLong(obj);
+ if (!PyErr_Occurred()) {
+ if (val) *val = v;
+ return SWIG_OK;
+ } else {
+ PyErr_Clear();
+ }
+ }
+#ifdef SWIG_PYTHON_CAST_MODE
+ {
+ int dispatch = 0;
+ long v = PyInt_AsLong(obj);
+ if (!PyErr_Occurred()) {
+ if (val) *val = v;
+ return SWIG_AddCast(SWIG_OK);
+ } else {
+ PyErr_Clear();
+ }
+ if (!dispatch) {
+ double d;
+ int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d));
+ if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) {
+ if (val) *val = (long)(d);
+ return res;
+ }
+ }
+ }
+#endif
+ return SWIG_TypeError;
+}
+
+
+SWIGINTERN int
+SWIG_AsVal_int (PyObject * obj, int *val)
+{
+ long v;
+ int res = SWIG_AsVal_long (obj, &v);
+ if (SWIG_IsOK(res)) {
+ if ((v < INT_MIN || v > INT_MAX)) {
+ return SWIG_OverflowError;
+ } else {
+ if (val) *val = static_cast< int >(v);
+ }
+ }
+ return res;
+}
+
+
#include <radio.h>
+ #define SWIG_From_double PyFloat_FromDouble
+
+
+SWIGINTERNINLINE PyObject*
+ SWIG_From_bool (bool value)
+{
+ return PyBool_FromLong(value ? 1 : 0);
+}
+
+
#include <packet.h>
+
+SWIGINTERN swig_type_info*
+SWIG_pchar_descriptor()
+{
+ static int init = 0;
+ static swig_type_info* info = 0;
+ if (!init) {
+ info = SWIG_TypeQuery("_p_char");
+ init = 1;
+ }
+ return info;
+}
+
+
+SWIGINTERNINLINE PyObject *
+SWIG_FromCharPtrAndSize(const char* carray, size_t size)
+{
+ if (carray) {
+ if (size > INT_MAX) {
+ swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
+ return pchar_descriptor ?
+ SWIG_NewPointerObj(const_cast< char * >(carray), pchar_descriptor, 0) : SWIG_Py_Void();
+ } else {
+ return PyString_FromStringAndSize(carray, static_cast< int >(size));
+ }
+ } else {
+ return SWIG_Py_Void();
+ }
+}
+
+
+SWIGINTERNINLINE PyObject *
+SWIG_FromCharPtr(const char *cptr)
+{
+ return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0));
+}
+
+
+SWIGINTERN int
+SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
+{
+ if (PyString_Check(obj)) {
+ char *cstr; int len;
+ PyString_AsStringAndSize(obj, &cstr, &len);
+ if (cptr) {
+ if (alloc) {
+ /*
+ In python the user should not be able to modify the inner
+ string representation. To warranty that, if you define
+ SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string
+ buffer is always returned.
+
+ The default behavior is just to return the pointer value,
+ so, be careful.
+ */
+#if defined(SWIG_PYTHON_SAFE_CSTRINGS)
+ if (*alloc != SWIG_OLDOBJ)
+#else
+ if (*alloc == SWIG_NEWOBJ)
+#endif
+ {
+ *cptr = reinterpret_cast< char* >(memcpy((new char[len + 1]), cstr, sizeof(char)*(len + 1)));
+ *alloc = SWIG_NEWOBJ;
+ }
+ else {
+ *cptr = cstr;
+ *alloc = SWIG_OLDOBJ;
+ }
+ } else {
+ *cptr = PyString_AsString(obj);
+ }
+ }
+ if (psize) *psize = len + 1;
+ return SWIG_OK;
+ } else {
+ swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
+ if (pchar_descriptor) {
+ void* vptr = 0;
+ if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) {
+ if (cptr) *cptr = (char *) vptr;
+ if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0;
+ if (alloc) *alloc = SWIG_OLDOBJ;
+ return SWIG_OK;
+ }
+ }
+ }
+ return SWIG_TypeError;
+}
+
+
+
+
+
+SWIGINTERN int
+SWIG_AsVal_long_SS_long (PyObject *obj, long long *val)
+{
+ int res = SWIG_TypeError;
+ if (PyLong_Check(obj)) {
+ long long v = PyLong_AsLongLong(obj);
+ if (!PyErr_Occurred()) {
+ if (val) *val = v;
+ return SWIG_OK;
+ } else {
+ PyErr_Clear();
+ }
+ } else {
+ long v;
+ res = SWIG_AsVal_long (obj,&v);
+ if (SWIG_IsOK(res)) {
+ if (val) *val = v;
+ return res;
+ }
+ }
+#ifdef SWIG_PYTHON_CAST_MODE
+ {
+ const double mant_max = 1LL << DBL_MANT_DIG;
+ const double mant_min = -mant_max;
+ double d;
+ res = SWIG_AsVal_double (obj,&d);
+ if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, mant_min, mant_max)) {
+ if (val) *val = (long long)(d);
+ return SWIG_AddCast(res);
+ }
+ res = SWIG_TypeError;
+ }
+#endif
+ return res;
+}
+
+
+SWIGINTERNINLINE PyObject*
+SWIG_From_unsigned_SS_long (unsigned long value)
+{
+ return (value > LONG_MAX) ?
+ PyLong_FromUnsignedLong(value) : PyInt_FromLong(static_cast< long >(value));
+}
+
+
+SWIGINTERNINLINE PyObject*
+SWIG_From_long_SS_long (long long value)
+{
+ return ((value < LONG_MIN) || (value > LONG_MAX)) ?
+ PyLong_FromLongLong(value) : PyInt_FromLong(static_cast< long >(value));
+}
+
+
+SWIGINTERN int
+SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val)
+{
+ if (PyInt_Check(obj)) {
+ long v = PyInt_AsLong(obj);
+ if (v >= 0) {
+ if (val) *val = v;
+ return SWIG_OK;
+ } else {
+ return SWIG_OverflowError;
+ }
+ } else if (PyLong_Check(obj)) {
+ unsigned long v = PyLong_AsUnsignedLong(obj);
+ if (!PyErr_Occurred()) {
+ if (val) *val = v;
+ return SWIG_OK;
+ } else {
+ PyErr_Clear();
+ }
+ }
+#ifdef SWIG_PYTHON_CAST_MODE
+ {
+ int dispatch = 0;
+ unsigned long v = PyLong_AsUnsignedLong(obj);
+ if (!PyErr_Occurred()) {
+ if (val) *val = v;
+ return SWIG_AddCast(SWIG_OK);
+ } else {
+ PyErr_Clear();
+ }
+ if (!dispatch) {
+ double d;
+ int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d));
+ if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) {
+ if (val) *val = (unsigned long)(d);
+ return res;
+ }
+ }
+ }
+#endif
+ return SWIG_TypeError;
+}
+
#ifdef __cplusplus
extern "C" {
#endif
-static PyObject *_wrap_new_MAC(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- MAC *result;
-
- if(!PyArg_ParseTuple(args,(char *)":new_MAC")) goto fail;
- result = (MAC *)new MAC();
-
- resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_MAC, 1);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_new_MAC(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ MAC *result = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)":new_MAC")) SWIG_fail;
+ result = (MAC *)new MAC();
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_MAC, SWIG_POINTER_NEW | 0 );
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_delete_MAC(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- MAC *arg1 = (MAC *) 0 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:delete_MAC",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_MAC,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- delete arg1;
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_delete_MAC(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ MAC *arg1 = (MAC *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:delete_MAC",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_MAC, SWIG_POINTER_DISOWN | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_MAC" "', argument " "1"" of type '" "MAC *""'");
+ }
+ arg1 = reinterpret_cast< MAC * >(argp1);
+ delete arg1;
+
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_MAC_initHigh(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- MAC *arg1 = (MAC *) 0 ;
- int result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:MAC_initHigh",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_MAC,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (int)(arg1)->initHigh();
-
- resultobj = PyInt_FromLong((long)result);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_MAC_initHigh(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ MAC *arg1 = (MAC *) 0 ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:MAC_initHigh",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_MAC, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MAC_initHigh" "', argument " "1"" of type '" "MAC *""'");
+ }
+ arg1 = reinterpret_cast< MAC * >(argp1);
+ result = (int)(arg1)->initHigh();
+ resultobj = SWIG_From_int(static_cast< int >(result));
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_MAC_initLow(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- MAC *arg1 = (MAC *) 0 ;
- int result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:MAC_initLow",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_MAC,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (int)(arg1)->initLow();
-
- resultobj = PyInt_FromLong((long)result);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_MAC_initLow(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ MAC *arg1 = (MAC *) 0 ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:MAC_initLow",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_MAC, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MAC_initLow" "', argument " "1"" of type '" "MAC *""'");
+ }
+ arg1 = reinterpret_cast< MAC * >(argp1);
+ result = (int)(arg1)->initLow();
+ resultobj = SWIG_From_int(static_cast< int >(result));
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_MAC_high(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- MAC *arg1 = (MAC *) 0 ;
- int result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:MAC_high",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_MAC,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (int)(arg1)->high();
-
- resultobj = PyInt_FromLong((long)result);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_MAC_high(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ MAC *arg1 = (MAC *) 0 ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:MAC_high",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_MAC, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MAC_high" "', argument " "1"" of type '" "MAC *""'");
+ }
+ arg1 = reinterpret_cast< MAC * >(argp1);
+ result = (int)(arg1)->high();
+ resultobj = SWIG_From_int(static_cast< int >(result));
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_MAC_low(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- MAC *arg1 = (MAC *) 0 ;
- int result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:MAC_low",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_MAC,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (int)(arg1)->low();
-
- resultobj = PyInt_FromLong((long)result);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_MAC_low(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ MAC *arg1 = (MAC *) 0 ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:MAC_low",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_MAC, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MAC_low" "', argument " "1"" of type '" "MAC *""'");
+ }
+ arg1 = reinterpret_cast< MAC * >(argp1);
+ result = (int)(arg1)->low();
+ resultobj = SWIG_From_int(static_cast< int >(result));
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_MAC_symbolsPerSec(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- MAC *arg1 = (MAC *) 0 ;
- int result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:MAC_symbolsPerSec",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_MAC,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (int)(arg1)->symbolsPerSec();
-
- resultobj = PyInt_FromLong((long)result);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_MAC_symbolsPerSec(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ MAC *arg1 = (MAC *) 0 ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:MAC_symbolsPerSec",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_MAC, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MAC_symbolsPerSec" "', argument " "1"" of type '" "MAC *""'");
+ }
+ arg1 = reinterpret_cast< MAC * >(argp1);
+ result = (int)(arg1)->symbolsPerSec();
+ resultobj = SWIG_From_int(static_cast< int >(result));
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_MAC_bitsPerSymbol(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- MAC *arg1 = (MAC *) 0 ;
- int result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:MAC_bitsPerSymbol",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_MAC,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (int)(arg1)->bitsPerSymbol();
-
- resultobj = PyInt_FromLong((long)result);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_MAC_bitsPerSymbol(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ MAC *arg1 = (MAC *) 0 ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:MAC_bitsPerSymbol",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_MAC, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MAC_bitsPerSymbol" "', argument " "1"" of type '" "MAC *""'");
+ }
+ arg1 = reinterpret_cast< MAC * >(argp1);
+ result = (int)(arg1)->bitsPerSymbol();
+ resultobj = SWIG_From_int(static_cast< int >(result));
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_MAC_preambleLength(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- MAC *arg1 = (MAC *) 0 ;
- int result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:MAC_preambleLength",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_MAC,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (int)(arg1)->preambleLength();
-
- resultobj = PyInt_FromLong((long)result);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_MAC_preambleLength(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ MAC *arg1 = (MAC *) 0 ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:MAC_preambleLength",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_MAC, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MAC_preambleLength" "', argument " "1"" of type '" "MAC *""'");
+ }
+ arg1 = reinterpret_cast< MAC * >(argp1);
+ result = (int)(arg1)->preambleLength();
+ resultobj = SWIG_From_int(static_cast< int >(result));
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_MAC_exponentBase(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- MAC *arg1 = (MAC *) 0 ;
- int result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:MAC_exponentBase",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_MAC,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (int)(arg1)->exponentBase();
-
- resultobj = PyInt_FromLong((long)result);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_MAC_exponentBase(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ MAC *arg1 = (MAC *) 0 ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:MAC_exponentBase",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_MAC, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MAC_exponentBase" "', argument " "1"" of type '" "MAC *""'");
+ }
+ arg1 = reinterpret_cast< MAC * >(argp1);
+ result = (int)(arg1)->exponentBase();
+ resultobj = SWIG_From_int(static_cast< int >(result));
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_MAC_maxIterations(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- MAC *arg1 = (MAC *) 0 ;
- int result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:MAC_maxIterations",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_MAC,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (int)(arg1)->maxIterations();
-
- resultobj = PyInt_FromLong((long)result);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_MAC_maxIterations(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ MAC *arg1 = (MAC *) 0 ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:MAC_maxIterations",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_MAC, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MAC_maxIterations" "', argument " "1"" of type '" "MAC *""'");
+ }
+ arg1 = reinterpret_cast< MAC * >(argp1);
+ result = (int)(arg1)->maxIterations();
+ resultobj = SWIG_From_int(static_cast< int >(result));
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_MAC_minFreeSamples(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- MAC *arg1 = (MAC *) 0 ;
- int result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:MAC_minFreeSamples",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_MAC,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (int)(arg1)->minFreeSamples();
-
- resultobj = PyInt_FromLong((long)result);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_MAC_minFreeSamples(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ MAC *arg1 = (MAC *) 0 ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:MAC_minFreeSamples",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_MAC, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MAC_minFreeSamples" "', argument " "1"" of type '" "MAC *""'");
+ }
+ arg1 = reinterpret_cast< MAC * >(argp1);
+ result = (int)(arg1)->minFreeSamples();
+ resultobj = SWIG_From_int(static_cast< int >(result));
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_MAC_rxtxDelay(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- MAC *arg1 = (MAC *) 0 ;
- int result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:MAC_rxtxDelay",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_MAC,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (int)(arg1)->rxtxDelay();
-
- resultobj = PyInt_FromLong((long)result);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_MAC_rxtxDelay(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ MAC *arg1 = (MAC *) 0 ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:MAC_rxtxDelay",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_MAC, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MAC_rxtxDelay" "', argument " "1"" of type '" "MAC *""'");
+ }
+ arg1 = reinterpret_cast< MAC * >(argp1);
+ result = (int)(arg1)->rxtxDelay();
+ resultobj = SWIG_From_int(static_cast< int >(result));
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_MAC_ackTime(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- MAC *arg1 = (MAC *) 0 ;
- int result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:MAC_ackTime",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_MAC,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (int)(arg1)->ackTime();
-
- resultobj = PyInt_FromLong((long)result);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_MAC_ackTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ MAC *arg1 = (MAC *) 0 ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:MAC_ackTime",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_MAC, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MAC_ackTime" "', argument " "1"" of type '" "MAC *""'");
+ }
+ arg1 = reinterpret_cast< MAC * >(argp1);
+ result = (int)(arg1)->ackTime();
+ resultobj = SWIG_From_int(static_cast< int >(result));
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_MAC_setInitHigh(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- MAC *arg1 = (MAC *) 0 ;
- int arg2 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"Oi:MAC_setInitHigh",&obj0,&arg2)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_MAC,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- (arg1)->setInitHigh(arg2);
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_MAC_setInitHigh(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ MAC *arg1 = (MAC *) 0 ;
+ int arg2 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:MAC_setInitHigh",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_MAC, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MAC_setInitHigh" "', argument " "1"" of type '" "MAC *""'");
+ }
+ arg1 = reinterpret_cast< MAC * >(argp1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "MAC_setInitHigh" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ (arg1)->setInitHigh(arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_MAC_setInitLow(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- MAC *arg1 = (MAC *) 0 ;
- int arg2 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"Oi:MAC_setInitLow",&obj0,&arg2)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_MAC,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- (arg1)->setInitLow(arg2);
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_MAC_setInitLow(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ MAC *arg1 = (MAC *) 0 ;
+ int arg2 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:MAC_setInitLow",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_MAC, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MAC_setInitLow" "', argument " "1"" of type '" "MAC *""'");
+ }
+ arg1 = reinterpret_cast< MAC * >(argp1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "MAC_setInitLow" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ (arg1)->setInitLow(arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_MAC_setHigh(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- MAC *arg1 = (MAC *) 0 ;
- int arg2 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"Oi:MAC_setHigh",&obj0,&arg2)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_MAC,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- (arg1)->setHigh(arg2);
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_MAC_setHigh(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ MAC *arg1 = (MAC *) 0 ;
+ int arg2 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:MAC_setHigh",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_MAC, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MAC_setHigh" "', argument " "1"" of type '" "MAC *""'");
+ }
+ arg1 = reinterpret_cast< MAC * >(argp1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "MAC_setHigh" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ (arg1)->setHigh(arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_MAC_setLow(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- MAC *arg1 = (MAC *) 0 ;
- int arg2 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"Oi:MAC_setLow",&obj0,&arg2)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_MAC,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- (arg1)->setLow(arg2);
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_MAC_setLow(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ MAC *arg1 = (MAC *) 0 ;
+ int arg2 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:MAC_setLow",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_MAC, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MAC_setLow" "', argument " "1"" of type '" "MAC *""'");
+ }
+ arg1 = reinterpret_cast< MAC * >(argp1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "MAC_setLow" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ (arg1)->setLow(arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_MAC_setSymbolsPerSec(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- MAC *arg1 = (MAC *) 0 ;
- int arg2 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"Oi:MAC_setSymbolsPerSec",&obj0,&arg2)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_MAC,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- (arg1)->setSymbolsPerSec(arg2);
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_MAC_setSymbolsPerSec(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ MAC *arg1 = (MAC *) 0 ;
+ int arg2 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:MAC_setSymbolsPerSec",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_MAC, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MAC_setSymbolsPerSec" "', argument " "1"" of type '" "MAC *""'");
+ }
+ arg1 = reinterpret_cast< MAC * >(argp1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "MAC_setSymbolsPerSec" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ (arg1)->setSymbolsPerSec(arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_MAC_setBitsBerSymbol(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- MAC *arg1 = (MAC *) 0 ;
- int arg2 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"Oi:MAC_setBitsBerSymbol",&obj0,&arg2)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_MAC,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- (arg1)->setBitsBerSymbol(arg2);
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_MAC_setBitsBerSymbol(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ MAC *arg1 = (MAC *) 0 ;
+ int arg2 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:MAC_setBitsBerSymbol",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_MAC, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MAC_setBitsBerSymbol" "', argument " "1"" of type '" "MAC *""'");
+ }
+ arg1 = reinterpret_cast< MAC * >(argp1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "MAC_setBitsBerSymbol" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ (arg1)->setBitsBerSymbol(arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_MAC_setPreambleLength(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- MAC *arg1 = (MAC *) 0 ;
- int arg2 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"Oi:MAC_setPreambleLength",&obj0,&arg2)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_MAC,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- (arg1)->setPreambleLength(arg2);
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_MAC_setPreambleLength(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ MAC *arg1 = (MAC *) 0 ;
+ int arg2 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:MAC_setPreambleLength",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_MAC, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MAC_setPreambleLength" "', argument " "1"" of type '" "MAC *""'");
+ }
+ arg1 = reinterpret_cast< MAC * >(argp1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "MAC_setPreambleLength" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ (arg1)->setPreambleLength(arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_MAC_setExponentBase(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- MAC *arg1 = (MAC *) 0 ;
- int arg2 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"Oi:MAC_setExponentBase",&obj0,&arg2)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_MAC,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- (arg1)->setExponentBase(arg2);
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_MAC_setExponentBase(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ MAC *arg1 = (MAC *) 0 ;
+ int arg2 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:MAC_setExponentBase",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_MAC, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MAC_setExponentBase" "', argument " "1"" of type '" "MAC *""'");
+ }
+ arg1 = reinterpret_cast< MAC * >(argp1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "MAC_setExponentBase" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ (arg1)->setExponentBase(arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_MAC_setMaxIterations(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- MAC *arg1 = (MAC *) 0 ;
- int arg2 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"Oi:MAC_setMaxIterations",&obj0,&arg2)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_MAC,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- (arg1)->setMaxIterations(arg2);
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_MAC_setMaxIterations(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ MAC *arg1 = (MAC *) 0 ;
+ int arg2 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:MAC_setMaxIterations",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_MAC, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MAC_setMaxIterations" "', argument " "1"" of type '" "MAC *""'");
+ }
+ arg1 = reinterpret_cast< MAC * >(argp1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "MAC_setMaxIterations" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ (arg1)->setMaxIterations(arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_MAC_setMinFreeSamples(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- MAC *arg1 = (MAC *) 0 ;
- int arg2 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"Oi:MAC_setMinFreeSamples",&obj0,&arg2)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_MAC,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- (arg1)->setMinFreeSamples(arg2);
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_MAC_setMinFreeSamples(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ MAC *arg1 = (MAC *) 0 ;
+ int arg2 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:MAC_setMinFreeSamples",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_MAC, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MAC_setMinFreeSamples" "', argument " "1"" of type '" "MAC *""'");
+ }
+ arg1 = reinterpret_cast< MAC * >(argp1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "MAC_setMinFreeSamples" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ (arg1)->setMinFreeSamples(arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_MAC_setRxtxDelay(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- MAC *arg1 = (MAC *) 0 ;
- int arg2 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"Oi:MAC_setRxtxDelay",&obj0,&arg2)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_MAC,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- (arg1)->setRxtxDelay(arg2);
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_MAC_setRxtxDelay(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ MAC *arg1 = (MAC *) 0 ;
+ int arg2 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:MAC_setRxtxDelay",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_MAC, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MAC_setRxtxDelay" "', argument " "1"" of type '" "MAC *""'");
+ }
+ arg1 = reinterpret_cast< MAC * >(argp1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "MAC_setRxtxDelay" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ (arg1)->setRxtxDelay(arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_MAC_setAckTime(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- MAC *arg1 = (MAC *) 0 ;
- int arg2 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"Oi:MAC_setAckTime",&obj0,&arg2)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_MAC,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- (arg1)->setAckTime(arg2);
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_MAC_setAckTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ MAC *arg1 = (MAC *) 0 ;
+ int arg2 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:MAC_setAckTime",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_MAC, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MAC_setAckTime" "', argument " "1"" of type '" "MAC *""'");
+ }
+ arg1 = reinterpret_cast< MAC * >(argp1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "MAC_setAckTime" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ (arg1)->setAckTime(arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject * MAC_swigregister(PyObject *self, PyObject *args) {
- PyObject *obj;
- if (!PyArg_ParseTuple(args,(char*)"O", &obj)) return NULL;
- SWIG_TypeClientData(SWIGTYPE_p_MAC, obj);
- Py_INCREF(obj);
- return Py_BuildValue((char *)"");
-}
-static PyObject *_wrap_new_Radio(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Radio *result;
-
- if(!PyArg_ParseTuple(args,(char *)":new_Radio")) goto fail;
- result = (Radio *)new Radio();
-
- resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_Radio, 1);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *MAC_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *obj;
+ if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
+ SWIG_TypeNewClientData(SWIGTYPE_p_MAC, SWIG_NewClientData(obj));
+ return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject *_wrap_new_Radio(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Radio *result = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)":new_Radio")) SWIG_fail;
+ result = (Radio *)new Radio();
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Radio, SWIG_POINTER_NEW | 0 );
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_delete_Radio(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Radio *arg1 = (Radio *) 0 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:delete_Radio",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Radio,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- delete arg1;
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_delete_Radio(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Radio *arg1 = (Radio *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:delete_Radio",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Radio, SWIG_POINTER_DISOWN | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Radio" "', argument " "1"" of type '" "Radio *""'");
+ }
+ arg1 = reinterpret_cast< Radio * >(argp1);
+ delete arg1;
+
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Radio_add(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Radio *arg1 = (Radio *) 0 ;
- int arg2 ;
- int arg3 ;
- double arg4 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"Oiid:Radio_add",&obj0,&arg2,&arg3,&arg4)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Radio,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- (arg1)->add(arg2,arg3,arg4);
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Radio_add(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Radio *arg1 = (Radio *) 0 ;
+ int arg2 ;
+ int arg3 ;
+ double arg4 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ int val3 ;
+ int ecode3 = 0 ;
+ double val4 ;
+ int ecode4 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOOO:Radio_add",&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Radio, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Radio_add" "', argument " "1"" of type '" "Radio *""'");
+ }
+ arg1 = reinterpret_cast< Radio * >(argp1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Radio_add" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ ecode3 = SWIG_AsVal_int(obj2, &val3);
+ if (!SWIG_IsOK(ecode3)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Radio_add" "', argument " "3"" of type '" "int""'");
+ }
+ arg3 = static_cast< int >(val3);
+ ecode4 = SWIG_AsVal_double(obj3, &val4);
+ if (!SWIG_IsOK(ecode4)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "Radio_add" "', argument " "4"" of type '" "double""'");
+ }
+ arg4 = static_cast< double >(val4);
+ (arg1)->add(arg2,arg3,arg4);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Radio_gain(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Radio *arg1 = (Radio *) 0 ;
- int arg2 ;
- int arg3 ;
- double result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"Oii:Radio_gain",&obj0,&arg2,&arg3)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Radio,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (double)(arg1)->gain(arg2,arg3);
-
- resultobj = PyFloat_FromDouble(result);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Radio_gain(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Radio *arg1 = (Radio *) 0 ;
+ int arg2 ;
+ int arg3 ;
+ double result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ int val3 ;
+ int ecode3 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOO:Radio_gain",&obj0,&obj1,&obj2)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Radio, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Radio_gain" "', argument " "1"" of type '" "Radio *""'");
+ }
+ arg1 = reinterpret_cast< Radio * >(argp1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Radio_gain" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ ecode3 = SWIG_AsVal_int(obj2, &val3);
+ if (!SWIG_IsOK(ecode3)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Radio_gain" "', argument " "3"" of type '" "int""'");
+ }
+ arg3 = static_cast< int >(val3);
+ result = (double)(arg1)->gain(arg2,arg3);
+ resultobj = SWIG_From_double(static_cast< double >(result));
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Radio_connected(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Radio *arg1 = (Radio *) 0 ;
- int arg2 ;
- int arg3 ;
- bool result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"Oii:Radio_connected",&obj0,&arg2,&arg3)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Radio,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (bool)(arg1)->connected(arg2,arg3);
-
- resultobj = PyInt_FromLong((long)result);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Radio_connected(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Radio *arg1 = (Radio *) 0 ;
+ int arg2 ;
+ int arg3 ;
+ bool result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ int val3 ;
+ int ecode3 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOO:Radio_connected",&obj0,&obj1,&obj2)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Radio, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Radio_connected" "', argument " "1"" of type '" "Radio *""'");
+ }
+ arg1 = reinterpret_cast< Radio * >(argp1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Radio_connected" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ ecode3 = SWIG_AsVal_int(obj2, &val3);
+ if (!SWIG_IsOK(ecode3)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Radio_connected" "', argument " "3"" of type '" "int""'");
+ }
+ arg3 = static_cast< int >(val3);
+ result = (bool)(arg1)->connected(arg2,arg3);
+ resultobj = SWIG_From_bool(static_cast< bool >(result));
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Radio_remove(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Radio *arg1 = (Radio *) 0 ;
- int arg2 ;
- int arg3 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"Oii:Radio_remove",&obj0,&arg2,&arg3)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Radio,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- (arg1)->remove(arg2,arg3);
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Radio_remove(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Radio *arg1 = (Radio *) 0 ;
+ int arg2 ;
+ int arg3 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ int val3 ;
+ int ecode3 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOO:Radio_remove",&obj0,&obj1,&obj2)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Radio, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Radio_remove" "', argument " "1"" of type '" "Radio *""'");
+ }
+ arg1 = reinterpret_cast< Radio * >(argp1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Radio_remove" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ ecode3 = SWIG_AsVal_int(obj2, &val3);
+ if (!SWIG_IsOK(ecode3)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Radio_remove" "', argument " "3"" of type '" "int""'");
+ }
+ arg3 = static_cast< int >(val3);
+ (arg1)->remove(arg2,arg3);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Radio_setNoise(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Radio *arg1 = (Radio *) 0 ;
- int arg2 ;
- double arg3 ;
- double arg4 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"Oidd:Radio_setNoise",&obj0,&arg2,&arg3,&arg4)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Radio,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- (arg1)->setNoise(arg2,arg3,arg4);
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Radio_setNoise(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Radio *arg1 = (Radio *) 0 ;
+ int arg2 ;
+ double arg3 ;
+ double arg4 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ double val3 ;
+ int ecode3 = 0 ;
+ double val4 ;
+ int ecode4 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOOO:Radio_setNoise",&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Radio, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Radio_setNoise" "', argument " "1"" of type '" "Radio *""'");
+ }
+ arg1 = reinterpret_cast< Radio * >(argp1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Radio_setNoise" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ ecode3 = SWIG_AsVal_double(obj2, &val3);
+ if (!SWIG_IsOK(ecode3)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Radio_setNoise" "', argument " "3"" of type '" "double""'");
+ }
+ arg3 = static_cast< double >(val3);
+ ecode4 = SWIG_AsVal_double(obj3, &val4);
+ if (!SWIG_IsOK(ecode4)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "Radio_setNoise" "', argument " "4"" of type '" "double""'");
+ }
+ arg4 = static_cast< double >(val4);
+ (arg1)->setNoise(arg2,arg3,arg4);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Radio_setSensitivity(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Radio *arg1 = (Radio *) 0 ;
- double arg2 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"Od:Radio_setSensitivity",&obj0,&arg2)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Radio,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- (arg1)->setSensitivity(arg2);
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Radio_setSensitivity(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Radio *arg1 = (Radio *) 0 ;
+ double arg2 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ double val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:Radio_setSensitivity",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Radio, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Radio_setSensitivity" "', argument " "1"" of type '" "Radio *""'");
+ }
+ arg1 = reinterpret_cast< Radio * >(argp1);
+ ecode2 = SWIG_AsVal_double(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Radio_setSensitivity" "', argument " "2"" of type '" "double""'");
+ }
+ arg2 = static_cast< double >(val2);
+ (arg1)->setSensitivity(arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject * Radio_swigregister(PyObject *self, PyObject *args) {
- PyObject *obj;
- if (!PyArg_ParseTuple(args,(char*)"O", &obj)) return NULL;
- SWIG_TypeClientData(SWIGTYPE_p_Radio, obj);
- Py_INCREF(obj);
- return Py_BuildValue((char *)"");
-}
-static PyObject *_wrap_new_Packet(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Packet *result;
-
- if(!PyArg_ParseTuple(args,(char *)":new_Packet")) goto fail;
- result = (Packet *)new Packet();
-
- resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_Packet, 1);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *Radio_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *obj;
+ if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
+ SWIG_TypeNewClientData(SWIGTYPE_p_Radio, SWIG_NewClientData(obj));
+ return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject *_wrap_new_Packet(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Packet *result = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)":new_Packet")) SWIG_fail;
+ result = (Packet *)new Packet();
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Packet, SWIG_POINTER_NEW | 0 );
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_delete_Packet(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Packet *arg1 = (Packet *) 0 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:delete_Packet",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Packet,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- delete arg1;
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_delete_Packet(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Packet *arg1 = (Packet *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:delete_Packet",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Packet, SWIG_POINTER_DISOWN | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Packet" "', argument " "1"" of type '" "Packet *""'");
+ }
+ arg1 = reinterpret_cast< Packet * >(argp1);
+ delete arg1;
+
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Packet_setDestination(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Packet *arg1 = (Packet *) 0 ;
- int arg2 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"Oi:Packet_setDestination",&obj0,&arg2)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Packet,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- (arg1)->setDestination(arg2);
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Packet_setDestination(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Packet *arg1 = (Packet *) 0 ;
+ int arg2 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:Packet_setDestination",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Packet, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_setDestination" "', argument " "1"" of type '" "Packet *""'");
+ }
+ arg1 = reinterpret_cast< Packet * >(argp1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Packet_setDestination" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ (arg1)->setDestination(arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Packet_destination(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Packet *arg1 = (Packet *) 0 ;
- int result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:Packet_destination",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Packet,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (int)(arg1)->destination();
-
- resultobj = PyInt_FromLong((long)result);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Packet_destination(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Packet *arg1 = (Packet *) 0 ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:Packet_destination",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Packet, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_destination" "', argument " "1"" of type '" "Packet *""'");
+ }
+ arg1 = reinterpret_cast< Packet * >(argp1);
+ result = (int)(arg1)->destination();
+ resultobj = SWIG_From_int(static_cast< int >(result));
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Packet_setLength(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Packet *arg1 = (Packet *) 0 ;
- int arg2 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"Oi:Packet_setLength",&obj0,&arg2)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Packet,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- (arg1)->setLength(arg2);
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Packet_setLength(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Packet *arg1 = (Packet *) 0 ;
+ int arg2 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:Packet_setLength",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Packet, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_setLength" "', argument " "1"" of type '" "Packet *""'");
+ }
+ arg1 = reinterpret_cast< Packet * >(argp1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Packet_setLength" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ (arg1)->setLength(arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Packet_length(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Packet *arg1 = (Packet *) 0 ;
- int result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:Packet_length",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Packet,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (int)(arg1)->length();
-
- resultobj = PyInt_FromLong((long)result);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Packet_length(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Packet *arg1 = (Packet *) 0 ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:Packet_length",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Packet, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_length" "', argument " "1"" of type '" "Packet *""'");
+ }
+ arg1 = reinterpret_cast< Packet * >(argp1);
+ result = (int)(arg1)->length();
+ resultobj = SWIG_From_int(static_cast< int >(result));
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Packet_setType(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Packet *arg1 = (Packet *) 0 ;
- int arg2 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"Oi:Packet_setType",&obj0,&arg2)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Packet,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- (arg1)->setType(arg2);
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Packet_setType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Packet *arg1 = (Packet *) 0 ;
+ int arg2 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:Packet_setType",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Packet, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_setType" "', argument " "1"" of type '" "Packet *""'");
+ }
+ arg1 = reinterpret_cast< Packet * >(argp1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Packet_setType" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ (arg1)->setType(arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Packet_type(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Packet *arg1 = (Packet *) 0 ;
- int result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:Packet_type",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Packet,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (int)(arg1)->type();
-
- resultobj = PyInt_FromLong((long)result);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Packet_type(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Packet *arg1 = (Packet *) 0 ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:Packet_type",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Packet, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_type" "', argument " "1"" of type '" "Packet *""'");
+ }
+ arg1 = reinterpret_cast< Packet * >(argp1);
+ result = (int)(arg1)->type();
+ resultobj = SWIG_From_int(static_cast< int >(result));
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Packet_data(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Packet *arg1 = (Packet *) 0 ;
- char *result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:Packet_data",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Packet,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (char *)(arg1)->data();
-
- resultobj = result ? PyString_FromString(result) : Py_BuildValue((char*)"");
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Packet_data(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Packet *arg1 = (Packet *) 0 ;
+ char *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:Packet_data",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Packet, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_data" "', argument " "1"" of type '" "Packet *""'");
+ }
+ arg1 = reinterpret_cast< Packet * >(argp1);
+ result = (char *)(arg1)->data();
+ resultobj = SWIG_FromCharPtr(result);
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Packet_setData(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Packet *arg1 = (Packet *) 0 ;
- char *arg2 ;
- int arg3 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"OO:Packet_setData",&obj0,&obj1)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Packet,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- {
- arg2 = (char *) PyString_AsString(obj1);
- arg3 = (int) PyString_Size(obj1);
- }
- (arg1)->setData(arg2,arg3);
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Packet_setData(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Packet *arg1 = (Packet *) 0 ;
+ char *arg2 = (char *) 0 ;
+ int arg3 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ size_t size2 = 0 ;
+ int alloc2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:Packet_setData",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Packet, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_setData" "', argument " "1"" of type '" "Packet *""'");
+ }
+ arg1 = reinterpret_cast< Packet * >(argp1);
+ res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, &size2, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Packet_setData" "', argument " "2"" of type '" "char *""'");
+ }
+ arg2 = static_cast< char * >(buf2);
+ arg3 = static_cast< int >(size2 - 1);
+ (arg1)->setData(arg2,arg3);
+ resultobj = SWIG_Py_Void();
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ return resultobj;
+fail:
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ return NULL;
}
-static PyObject *_wrap_Packet_maxLength(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Packet *arg1 = (Packet *) 0 ;
- int result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:Packet_maxLength",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Packet,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (int)(arg1)->maxLength();
-
- resultobj = PyInt_FromLong((long)result);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Packet_maxLength(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Packet *arg1 = (Packet *) 0 ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:Packet_maxLength",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Packet, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_maxLength" "', argument " "1"" of type '" "Packet *""'");
+ }
+ arg1 = reinterpret_cast< Packet * >(argp1);
+ result = (int)(arg1)->maxLength();
+ resultobj = SWIG_From_int(static_cast< int >(result));
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Packet_setStrength(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Packet *arg1 = (Packet *) 0 ;
- int arg2 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"Oi:Packet_setStrength",&obj0,&arg2)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Packet,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- (arg1)->setStrength(arg2);
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Packet_setStrength(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Packet *arg1 = (Packet *) 0 ;
+ int arg2 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:Packet_setStrength",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Packet, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_setStrength" "', argument " "1"" of type '" "Packet *""'");
+ }
+ arg1 = reinterpret_cast< Packet * >(argp1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Packet_setStrength" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ (arg1)->setStrength(arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Packet_deliver(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Packet *arg1 = (Packet *) 0 ;
- int arg2 ;
- long long arg3 ;
- PyObject * obj0 = 0 ;
- PyObject * obj2 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"OiO:Packet_deliver",&obj0,&arg2,&obj2)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Packet,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- arg3 = (long long) PyLong_AsLongLong(obj2);
- if (PyErr_Occurred()) SWIG_fail;
- (arg1)->deliver(arg2,arg3);
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Packet_deliver(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Packet *arg1 = (Packet *) 0 ;
+ int arg2 ;
+ long long arg3 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ long long val3 ;
+ int ecode3 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOO:Packet_deliver",&obj0,&obj1,&obj2)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Packet, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_deliver" "', argument " "1"" of type '" "Packet *""'");
+ }
+ arg1 = reinterpret_cast< Packet * >(argp1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Packet_deliver" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ ecode3 = SWIG_AsVal_long_SS_long(obj2, &val3);
+ if (!SWIG_IsOK(ecode3)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Packet_deliver" "', argument " "3"" of type '" "long long""'");
+ }
+ arg3 = static_cast< long long >(val3);
+ (arg1)->deliver(arg2,arg3);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Packet_deliverNow(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Packet *arg1 = (Packet *) 0 ;
- int arg2 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"Oi:Packet_deliverNow",&obj0,&arg2)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Packet,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- (arg1)->deliverNow(arg2);
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Packet_deliverNow(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Packet *arg1 = (Packet *) 0 ;
+ int arg2 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:Packet_deliverNow",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Packet, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Packet_deliverNow" "', argument " "1"" of type '" "Packet *""'");
+ }
+ arg1 = reinterpret_cast< Packet * >(argp1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Packet_deliverNow" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ (arg1)->deliverNow(arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject * Packet_swigregister(PyObject *self, PyObject *args) {
- PyObject *obj;
- if (!PyArg_ParseTuple(args,(char*)"O", &obj)) return NULL;
- SWIG_TypeClientData(SWIGTYPE_p_Packet, obj);
- Py_INCREF(obj);
- return Py_BuildValue((char *)"");
-}
-static PyObject *_wrap_variable_string_t_type_set(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- variable_string_t *arg1 = (variable_string_t *) 0 ;
- char *arg2 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"Os:variable_string_t_type_set",&obj0,&arg2)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_variable_string_t,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- {
- if (arg1->type) delete [] arg1->type;
- if (arg2) {
- arg1->type = (char *) (new char[strlen(arg2)+1]);
- strcpy((char *) arg1->type,arg2);
- } else {
- arg1->type = 0;
- }
- }
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *Packet_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *obj;
+ if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
+ SWIG_TypeNewClientData(SWIGTYPE_p_Packet, SWIG_NewClientData(obj));
+ return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject *_wrap_variable_string_t_type_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ variable_string_t *arg1 = (variable_string_t *) 0 ;
+ char *arg2 = (char *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:variable_string_t_type_set",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_var_string, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "variable_string_t_type_set" "', argument " "1"" of type '" "variable_string_t *""'");
+ }
+ arg1 = reinterpret_cast< variable_string_t * >(argp1);
+ res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "variable_string_t_type_set" "', argument " "2"" of type '" "char *""'");
+ }
+ arg2 = buf2;
+ if (arg1->type) delete[] arg1->type;
+ if (arg2) {
+ size_t size = strlen(arg2) + 1;
+ arg1->type = reinterpret_cast< char* >(memcpy((new char[size]), arg2, sizeof(char)*(size)));
+ } else {
+ arg1->type = 0;
+ }
+ resultobj = SWIG_Py_Void();
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ return resultobj;
+fail:
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ return NULL;
}
-static PyObject *_wrap_variable_string_t_type_get(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- variable_string_t *arg1 = (variable_string_t *) 0 ;
- char *result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:variable_string_t_type_get",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_variable_string_t,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (char *) ((arg1)->type);
-
- resultobj = result ? PyString_FromString(result) : Py_BuildValue((char*)"");
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_variable_string_t_type_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ variable_string_t *arg1 = (variable_string_t *) 0 ;
+ char *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:variable_string_t_type_get",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_var_string, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "variable_string_t_type_get" "', argument " "1"" of type '" "variable_string_t *""'");
+ }
+ arg1 = reinterpret_cast< variable_string_t * >(argp1);
+ result = (char *) ((arg1)->type);
+ resultobj = SWIG_FromCharPtr(result);
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_variable_string_t_ptr_set(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- variable_string_t *arg1 = (variable_string_t *) 0 ;
- char *arg2 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"Os:variable_string_t_ptr_set",&obj0,&arg2)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_variable_string_t,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- {
- if (arg1->ptr) delete [] arg1->ptr;
- if (arg2) {
- arg1->ptr = (char *) (new char[strlen(arg2)+1]);
- strcpy((char *) arg1->ptr,arg2);
- } else {
- arg1->ptr = 0;
- }
- }
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_variable_string_t_ptr_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ variable_string_t *arg1 = (variable_string_t *) 0 ;
+ char *arg2 = (char *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:variable_string_t_ptr_set",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_var_string, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "variable_string_t_ptr_set" "', argument " "1"" of type '" "variable_string_t *""'");
+ }
+ arg1 = reinterpret_cast< variable_string_t * >(argp1);
+ res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "variable_string_t_ptr_set" "', argument " "2"" of type '" "char *""'");
+ }
+ arg2 = buf2;
+ if (arg1->ptr) delete[] arg1->ptr;
+ if (arg2) {
+ size_t size = strlen(arg2) + 1;
+ arg1->ptr = reinterpret_cast< char* >(memcpy((new char[size]), arg2, sizeof(char)*(size)));
+ } else {
+ arg1->ptr = 0;
+ }
+ resultobj = SWIG_Py_Void();
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ return resultobj;
+fail:
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ return NULL;
}
-static PyObject *_wrap_variable_string_t_ptr_get(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- variable_string_t *arg1 = (variable_string_t *) 0 ;
- char *result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:variable_string_t_ptr_get",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_variable_string_t,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (char *) ((arg1)->ptr);
-
- resultobj = result ? PyString_FromString(result) : Py_BuildValue((char*)"");
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_variable_string_t_ptr_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ variable_string_t *arg1 = (variable_string_t *) 0 ;
+ char *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:variable_string_t_ptr_get",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_var_string, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "variable_string_t_ptr_get" "', argument " "1"" of type '" "variable_string_t *""'");
+ }
+ arg1 = reinterpret_cast< variable_string_t * >(argp1);
+ result = (char *) ((arg1)->ptr);
+ resultobj = SWIG_FromCharPtr(result);
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_variable_string_t_len_set(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- variable_string_t *arg1 = (variable_string_t *) 0 ;
- int arg2 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"Oi:variable_string_t_len_set",&obj0,&arg2)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_variable_string_t,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- if (arg1) (arg1)->len = arg2;
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_variable_string_t_len_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ variable_string_t *arg1 = (variable_string_t *) 0 ;
+ int arg2 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:variable_string_t_len_set",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_var_string, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "variable_string_t_len_set" "', argument " "1"" of type '" "variable_string_t *""'");
+ }
+ arg1 = reinterpret_cast< variable_string_t * >(argp1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "variable_string_t_len_set" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ if (arg1) (arg1)->len = arg2;
+
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_variable_string_t_len_get(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- variable_string_t *arg1 = (variable_string_t *) 0 ;
- int result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:variable_string_t_len_get",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_variable_string_t,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (int) ((arg1)->len);
-
- resultobj = PyInt_FromLong((long)result);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_variable_string_t_len_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ variable_string_t *arg1 = (variable_string_t *) 0 ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:variable_string_t_len_get",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_var_string, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "variable_string_t_len_get" "', argument " "1"" of type '" "variable_string_t *""'");
+ }
+ arg1 = reinterpret_cast< variable_string_t * >(argp1);
+ result = (int) ((arg1)->len);
+ resultobj = SWIG_From_int(static_cast< int >(result));
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_variable_string_t_isArray_set(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- variable_string_t *arg1 = (variable_string_t *) 0 ;
- int arg2 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"Oi:variable_string_t_isArray_set",&obj0,&arg2)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_variable_string_t,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- if (arg1) (arg1)->isArray = arg2;
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_variable_string_t_isArray_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ variable_string_t *arg1 = (variable_string_t *) 0 ;
+ int arg2 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:variable_string_t_isArray_set",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_var_string, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "variable_string_t_isArray_set" "', argument " "1"" of type '" "variable_string_t *""'");
+ }
+ arg1 = reinterpret_cast< variable_string_t * >(argp1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "variable_string_t_isArray_set" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ if (arg1) (arg1)->isArray = arg2;
+
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_variable_string_t_isArray_get(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- variable_string_t *arg1 = (variable_string_t *) 0 ;
- int result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:variable_string_t_isArray_get",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_variable_string_t,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (int) ((arg1)->isArray);
-
- resultobj = PyInt_FromLong((long)result);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_variable_string_t_isArray_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ variable_string_t *arg1 = (variable_string_t *) 0 ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:variable_string_t_isArray_get",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_var_string, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "variable_string_t_isArray_get" "', argument " "1"" of type '" "variable_string_t *""'");
+ }
+ arg1 = reinterpret_cast< variable_string_t * >(argp1);
+ result = (int) ((arg1)->isArray);
+ resultobj = SWIG_From_int(static_cast< int >(result));
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_new_variable_string_t(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- variable_string_t *result;
-
- if(!PyArg_ParseTuple(args,(char *)":new_variable_string_t")) goto fail;
- result = (variable_string_t *)new variable_string_t();
-
- resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_variable_string_t, 1);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_new_variable_string_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ variable_string_t *result = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)":new_variable_string_t")) SWIG_fail;
+ result = (variable_string_t *)new variable_string_t();
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_var_string, SWIG_POINTER_NEW | 0 );
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_delete_variable_string_t(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- variable_string_t *arg1 = (variable_string_t *) 0 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:delete_variable_string_t",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_variable_string_t,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- delete arg1;
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_delete_variable_string_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ variable_string_t *arg1 = (variable_string_t *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:delete_variable_string_t",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_var_string, SWIG_POINTER_DISOWN | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_variable_string_t" "', argument " "1"" of type '" "variable_string_t *""'");
+ }
+ arg1 = reinterpret_cast< variable_string_t * >(argp1);
+ delete arg1;
+
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject * variable_string_t_swigregister(PyObject *self, PyObject *args) {
- PyObject *obj;
- if (!PyArg_ParseTuple(args,(char*)"O", &obj)) return NULL;
- SWIG_TypeClientData(SWIGTYPE_p_variable_string_t, obj);
- Py_INCREF(obj);
- return Py_BuildValue((char *)"");
-}
-static PyObject *_wrap_nesc_app_t_numVariables_set(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- nesc_app_t *arg1 = (nesc_app_t *) 0 ;
- int arg2 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"Oi:nesc_app_t_numVariables_set",&obj0,&arg2)) goto fail;
- {
- if (!PyList_Check(obj0)) {
- PyErr_SetString(PyExc_TypeError, "Requires a list as a parameter.");
- return NULL;
+SWIGINTERN PyObject *variable_string_t_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *obj;
+ if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
+ SWIG_TypeNewClientData(SWIGTYPE_p_var_string, SWIG_NewClientData(obj));
+ return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject *_wrap_nesc_app_t_numVariables_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ nesc_app_t *arg1 = (nesc_app_t *) 0 ;
+ int arg2 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:nesc_app_t_numVariables_set",&obj0,&obj1)) SWIG_fail;
+ {
+ if (!PyList_Check(obj0)) {
+ PyErr_SetString(PyExc_TypeError, "Requires a list as a parameter.");
+ return NULL;
+ }
+ else {
+ int size = PyList_Size(obj0);
+ int i = 0;
+ nesc_app_t* app;
+
+ if (size % 3 != 0) {
+ PyErr_SetString(PyExc_RuntimeError, "List must have 2*N elements.");
+ return NULL;
+ }
+
+ app = (nesc_app_t*)malloc(sizeof(nesc_app_t));
+
+ app->numVariables = size / 3;
+ app->variableNames = (char**)malloc(sizeof(char*) * app->numVariables);
+ app->variableTypes = (char**)malloc(sizeof(char*) * app->numVariables);
+ app->variableArray = (int*)malloc(sizeof(int) * app->numVariables);
+
+ memset(app->variableNames, 0, sizeof(char*) * app->numVariables);
+ memset(app->variableTypes, 0, sizeof(char*) * app->numVariables);
+ memset(app->variableArray, 0, sizeof(int) * app->numVariables);
+
+ for (i = 0; i < app->numVariables; i++) {
+ PyObject* name = PyList_GetItem(obj0, 3 * i);
+ PyObject* array = PyList_GetItem(obj0, (3 * i) + 1);
+ PyObject* format = PyList_GetItem(obj0, (3 * i) + 2);
+ if (PyString_Check(name) && PyString_Check(format)) {
+ app->variableNames[i] = PyString_AsString(name);
+ app->variableTypes[i] = PyString_AsString(format);
+ if (strcmp(PyString_AsString(array), "array") == 0) {
+ app->variableArray[i] = 1;
+ //printf("%s is an array\n", PyString_AsString(name));
+ }
+ else {
+ app->variableArray[i] = 0;
+ //printf("%s is a scalar\n", PyString_AsString(name));
+ }
}
else {
- int size = PyList_Size(obj0);
- int i = 0;
- nesc_app_t* app;
-
- if (size % 3 != 0) {
- PyErr_SetString(PyExc_RuntimeError, "List must have 2*N elements.");
- return NULL;
- }
-
- app = (nesc_app_t*)malloc(sizeof(nesc_app_t));
-
- app->numVariables = size / 3;
- app->variableNames = (char**)malloc(sizeof(char*) * app->numVariables);
- app->variableTypes = (char**)malloc(sizeof(char*) * app->numVariables);
- app->variableArray = (int*)malloc(sizeof(int) * app->numVariables);
-
- memset(app->variableNames, 0, sizeof(char*) * app->numVariables);
- memset(app->variableTypes, 0, sizeof(char*) * app->numVariables);
- memset(app->variableArray, 0, sizeof(int) * app->numVariables);
-
- for (i = 0; i < app->numVariables; i++) {
- PyObject* name = PyList_GetItem(obj0, 3 * i);
- PyObject* array = PyList_GetItem(obj0, (3 * i) + 1);
- PyObject* format = PyList_GetItem(obj0, (3 * i) + 2);
- if (PyString_Check(name) && PyString_Check(format)) {
- app->variableNames[i] = PyString_AsString(name);
- app->variableTypes[i] = PyString_AsString(format);
- if (strcmp(PyString_AsString(array), "array") == 0) {
- app->variableArray[i] = 1;
- //printf("%s is an array\n", PyString_AsString(name));
- }
- else {
- app->variableArray[i] = 0;
- //printf("%s is a scalar\n", PyString_AsString(name));
- }
- }
- else {
- app->variableNames[i] = "<bad string>";
- app->variableTypes[i] = "<bad string>";
- }
- }
-
- arg1 = app;
+ app->variableNames[i] = "<bad string>";
+ app->variableTypes[i] = "<bad string>";
}
+ }
+
+ arg1 = app;
}
- if (arg1) (arg1)->numVariables = arg2;
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+ }
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "nesc_app_t_numVariables_set" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ if (arg1) (arg1)->numVariables = arg2;
+
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_nesc_app_t_numVariables_get(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- nesc_app_t *arg1 = (nesc_app_t *) 0 ;
- int result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:nesc_app_t_numVariables_get",&obj0)) goto fail;
- {
- if (!PyList_Check(obj0)) {
- PyErr_SetString(PyExc_TypeError, "Requires a list as a parameter.");
- return NULL;
+SWIGINTERN PyObject *_wrap_nesc_app_t_numVariables_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ nesc_app_t *arg1 = (nesc_app_t *) 0 ;
+ int result;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:nesc_app_t_numVariables_get",&obj0)) SWIG_fail;
+ {
+ if (!PyList_Check(obj0)) {
+ PyErr_SetString(PyExc_TypeError, "Requires a list as a parameter.");
+ return NULL;
+ }
+ else {
+ int size = PyList_Size(obj0);
+ int i = 0;
+ nesc_app_t* app;
+
+ if (size % 3 != 0) {
+ PyErr_SetString(PyExc_RuntimeError, "List must have 2*N elements.");
+ return NULL;
+ }
+
+ app = (nesc_app_t*)malloc(sizeof(nesc_app_t));
+
+ app->numVariables = size / 3;
+ app->variableNames = (char**)malloc(sizeof(char*) * app->numVariables);
+ app->variableTypes = (char**)malloc(sizeof(char*) * app->numVariables);
+ app->variableArray = (int*)malloc(sizeof(int) * app->numVariables);
+
+ memset(app->variableNames, 0, sizeof(char*) * app->numVariables);
+ memset(app->variableTypes, 0, sizeof(char*) * app->numVariables);
+ memset(app->variableArray, 0, sizeof(int) * app->numVariables);
+
+ for (i = 0; i < app->numVariables; i++) {
+ PyObject* name = PyList_GetItem(obj0, 3 * i);
+ PyObject* array = PyList_GetItem(obj0, (3 * i) + 1);
+ PyObject* format = PyList_GetItem(obj0, (3 * i) + 2);
+ if (PyString_Check(name) && PyString_Check(format)) {
+ app->variableNames[i] = PyString_AsString(name);
+ app->variableTypes[i] = PyString_AsString(format);
+ if (strcmp(PyString_AsString(array), "array") == 0) {
+ app->variableArray[i] = 1;
+ //printf("%s is an array\n", PyString_AsString(name));
+ }
+ else {
+ app->variableArray[i] = 0;
+ //printf("%s is a scalar\n", PyString_AsString(name));
+ }
}
else {
- int size = PyList_Size(obj0);
- int i = 0;
- nesc_app_t* app;
-
- if (size % 3 != 0) {
- PyErr_SetString(PyExc_RuntimeError, "List must have 2*N elements.");
- return NULL;
- }
-
- app = (nesc_app_t*)malloc(sizeof(nesc_app_t));
-
- app->numVariables = size / 3;
- app->variableNames = (char**)malloc(sizeof(char*) * app->numVariables);
- app->variableTypes = (char**)malloc(sizeof(char*) * app->numVariables);
- app->variableArray = (int*)malloc(sizeof(int) * app->numVariables);
-
- memset(app->variableNames, 0, sizeof(char*) * app->numVariables);
- memset(app->variableTypes, 0, sizeof(char*) * app->numVariables);
- memset(app->variableArray, 0, sizeof(int) * app->numVariables);
-
- for (i = 0; i < app->numVariables; i++) {
- PyObject* name = PyList_GetItem(obj0, 3 * i);
- PyObject* array = PyList_GetItem(obj0, (3 * i) + 1);
- PyObject* format = PyList_GetItem(obj0, (3 * i) + 2);
- if (PyString_Check(name) && PyString_Check(format)) {
- app->variableNames[i] = PyString_AsString(name);
- app->variableTypes[i] = PyString_AsString(format);
- if (strcmp(PyString_AsString(array), "array") == 0) {
- app->variableArray[i] = 1;
- //printf("%s is an array\n", PyString_AsString(name));
- }
- else {
- app->variableArray[i] = 0;
- //printf("%s is a scalar\n", PyString_AsString(name));
- }
- }
- else {
- app->variableNames[i] = "<bad string>";
- app->variableTypes[i] = "<bad string>";
- }
- }
-
- arg1 = app;
+ app->variableNames[i] = "<bad string>";
+ app->variableTypes[i] = "<bad string>";
}
+ }
+
+ arg1 = app;
}
- result = (int) ((arg1)->numVariables);
-
- resultobj = PyInt_FromLong((long)result);
- return resultobj;
- fail:
- return NULL;
+ }
+ result = (int) ((arg1)->numVariables);
+ resultobj = SWIG_From_int(static_cast< int >(result));
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_nesc_app_t_variableNames_set(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- nesc_app_t *arg1 = (nesc_app_t *) 0 ;
- char **arg2 = (char **) 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"OO:nesc_app_t_variableNames_set",&obj0,&obj1)) goto fail;
- {
- if (!PyList_Check(obj0)) {
- PyErr_SetString(PyExc_TypeError, "Requires a list as a parameter.");
- return NULL;
+SWIGINTERN PyObject *_wrap_nesc_app_t_variableNames_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ nesc_app_t *arg1 = (nesc_app_t *) 0 ;
+ char **arg2 = (char **) 0 ;
+ void *argp2 = 0 ;
+ int res2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:nesc_app_t_variableNames_set",&obj0,&obj1)) SWIG_fail;
+ {
+ if (!PyList_Check(obj0)) {
+ PyErr_SetString(PyExc_TypeError, "Requires a list as a parameter.");
+ return NULL;
+ }
+ else {
+ int size = PyList_Size(obj0);
+ int i = 0;
+ nesc_app_t* app;
+
+ if (size % 3 != 0) {
+ PyErr_SetString(PyExc_RuntimeError, "List must have 2*N elements.");
+ return NULL;
+ }
+
+ app = (nesc_app_t*)malloc(sizeof(nesc_app_t));
+
+ app->numVariables = size / 3;
+ app->variableNames = (char**)malloc(sizeof(char*) * app->numVariables);
+ app->variableTypes = (char**)malloc(sizeof(char*) * app->numVariables);
+ app->variableArray = (int*)malloc(sizeof(int) * app->numVariables);
+
+ memset(app->variableNames, 0, sizeof(char*) * app->numVariables);
+ memset(app->variableTypes, 0, sizeof(char*) * app->numVariables);
+ memset(app->variableArray, 0, sizeof(int) * app->numVariables);
+
+ for (i = 0; i < app->numVariables; i++) {
+ PyObject* name = PyList_GetItem(obj0, 3 * i);
+ PyObject* array = PyList_GetItem(obj0, (3 * i) + 1);
+ PyObject* format = PyList_GetItem(obj0, (3 * i) + 2);
+ if (PyString_Check(name) && PyString_Check(format)) {
+ app->variableNames[i] = PyString_AsString(name);
+ app->variableTypes[i] = PyString_AsString(format);
+ if (strcmp(PyString_AsString(array), "array") == 0) {
+ app->variableArray[i] = 1;
+ //printf("%s is an array\n", PyString_AsString(name));
+ }
+ else {
+ app->variableArray[i] = 0;
+ //printf("%s is a scalar\n", PyString_AsString(name));
+ }
}
else {
- int size = PyList_Size(obj0);
- int i = 0;
- nesc_app_t* app;
-
- if (size % 3 != 0) {
- PyErr_SetString(PyExc_RuntimeError, "List must have 2*N elements.");
- return NULL;
- }
-
- app = (nesc_app_t*)malloc(sizeof(nesc_app_t));
-
- app->numVariables = size / 3;
- app->variableNames = (char**)malloc(sizeof(char*) * app->numVariables);
- app->variableTypes = (char**)malloc(sizeof(char*) * app->numVariables);
- app->variableArray = (int*)malloc(sizeof(int) * app->numVariables);
-
- memset(app->variableNames, 0, sizeof(char*) * app->numVariables);
- memset(app->variableTypes, 0, sizeof(char*) * app->numVariables);
- memset(app->variableArray, 0, sizeof(int) * app->numVariables);
-
- for (i = 0; i < app->numVariables; i++) {
- PyObject* name = PyList_GetItem(obj0, 3 * i);
- PyObject* array = PyList_GetItem(obj0, (3 * i) + 1);
- PyObject* format = PyList_GetItem(obj0, (3 * i) + 2);
- if (PyString_Check(name) && PyString_Check(format)) {
- app->variableNames[i] = PyString_AsString(name);
- app->variableTypes[i] = PyString_AsString(format);
- if (strcmp(PyString_AsString(array), "array") == 0) {
- app->variableArray[i] = 1;
- //printf("%s is an array\n", PyString_AsString(name));
- }
- else {
- app->variableArray[i] = 0;
- //printf("%s is a scalar\n", PyString_AsString(name));
- }
- }
- else {
- app->variableNames[i] = "<bad string>";
- app->variableTypes[i] = "<bad string>";
- }
- }
-
- arg1 = app;
+ app->variableNames[i] = "<bad string>";
+ app->variableTypes[i] = "<bad string>";
}
+ }
+
+ arg1 = app;
}
- if ((SWIG_ConvertPtr(obj1,(void **) &arg2, SWIGTYPE_p_p_char,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- if (arg1) (arg1)->variableNames = arg2;
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+ }
+ res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_p_char, 0 | 0 );
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "nesc_app_t_variableNames_set" "', argument " "2"" of type '" "char **""'");
+ }
+ arg2 = reinterpret_cast< char ** >(argp2);
+ if (arg1) (arg1)->variableNames = arg2;
+
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_nesc_app_t_variableNames_get(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- nesc_app_t *arg1 = (nesc_app_t *) 0 ;
- char **result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:nesc_app_t_variableNames_get",&obj0)) goto fail;
- {
- if (!PyList_Check(obj0)) {
- PyErr_SetString(PyExc_TypeError, "Requires a list as a parameter.");
- return NULL;
+SWIGINTERN PyObject *_wrap_nesc_app_t_variableNames_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ nesc_app_t *arg1 = (nesc_app_t *) 0 ;
+ char **result = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:nesc_app_t_variableNames_get",&obj0)) SWIG_fail;
+ {
+ if (!PyList_Check(obj0)) {
+ PyErr_SetString(PyExc_TypeError, "Requires a list as a parameter.");
+ return NULL;
+ }
+ else {
+ int size = PyList_Size(obj0);
+ int i = 0;
+ nesc_app_t* app;
+
+ if (size % 3 != 0) {
+ PyErr_SetString(PyExc_RuntimeError, "List must have 2*N elements.");
+ return NULL;
+ }
+
+ app = (nesc_app_t*)malloc(sizeof(nesc_app_t));
+
+ app->numVariables = size / 3;
+ app->variableNames = (char**)malloc(sizeof(char*) * app->numVariables);
+ app->variableTypes = (char**)malloc(sizeof(char*) * app->numVariables);
+ app->variableArray = (int*)malloc(sizeof(int) * app->numVariables);
+
+ memset(app->variableNames, 0, sizeof(char*) * app->numVariables);
+ memset(app->variableTypes, 0, sizeof(char*) * app->numVariables);
+ memset(app->variableArray, 0, sizeof(int) * app->numVariables);
+
+ for (i = 0; i < app->numVariables; i++) {
+ PyObject* name = PyList_GetItem(obj0, 3 * i);
+ PyObject* array = PyList_GetItem(obj0, (3 * i) + 1);
+ PyObject* format = PyList_GetItem(obj0, (3 * i) + 2);
+ if (PyString_Check(name) && PyString_Check(format)) {
+ app->variableNames[i] = PyString_AsString(name);
+ app->variableTypes[i] = PyString_AsString(format);
+ if (strcmp(PyString_AsString(array), "array") == 0) {
+ app->variableArray[i] = 1;
+ //printf("%s is an array\n", PyString_AsString(name));
+ }
+ else {
+ app->variableArray[i] = 0;
+ //printf("%s is a scalar\n", PyString_AsString(name));
+ }
}
else {
- int size = PyList_Size(obj0);
- int i = 0;
- nesc_app_t* app;
-
- if (size % 3 != 0) {
- PyErr_SetString(PyExc_RuntimeError, "List must have 2*N elements.");
- return NULL;
- }
-
- app = (nesc_app_t*)malloc(sizeof(nesc_app_t));
-
- app->numVariables = size / 3;
- app->variableNames = (char**)malloc(sizeof(char*) * app->numVariables);
- app->variableTypes = (char**)malloc(sizeof(char*) * app->numVariables);
- app->variableArray = (int*)malloc(sizeof(int) * app->numVariables);
-
- memset(app->variableNames, 0, sizeof(char*) * app->numVariables);
- memset(app->variableTypes, 0, sizeof(char*) * app->numVariables);
- memset(app->variableArray, 0, sizeof(int) * app->numVariables);
-
- for (i = 0; i < app->numVariables; i++) {
- PyObject* name = PyList_GetItem(obj0, 3 * i);
- PyObject* array = PyList_GetItem(obj0, (3 * i) + 1);
- PyObject* format = PyList_GetItem(obj0, (3 * i) + 2);
- if (PyString_Check(name) && PyString_Check(format)) {
- app->variableNames[i] = PyString_AsString(name);
- app->variableTypes[i] = PyString_AsString(format);
- if (strcmp(PyString_AsString(array), "array") == 0) {
- app->variableArray[i] = 1;
- //printf("%s is an array\n", PyString_AsString(name));
- }
- else {
- app->variableArray[i] = 0;
- //printf("%s is a scalar\n", PyString_AsString(name));
- }
- }
- else {
- app->variableNames[i] = "<bad string>";
- app->variableTypes[i] = "<bad string>";
- }
- }
-
- arg1 = app;
+ app->variableNames[i] = "<bad string>";
+ app->variableTypes[i] = "<bad string>";
}
+ }
+
+ arg1 = app;
}
- result = (char **) ((arg1)->variableNames);
-
- resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_p_char, 0);
- return resultobj;
- fail:
- return NULL;
+ }
+ result = (char **) ((arg1)->variableNames);
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_p_char, 0 | 0 );
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_nesc_app_t_variableTypes_set(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- nesc_app_t *arg1 = (nesc_app_t *) 0 ;
- char **arg2 = (char **) 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"OO:nesc_app_t_variableTypes_set",&obj0,&obj1)) goto fail;
- {
- if (!PyList_Check(obj0)) {
- PyErr_SetString(PyExc_TypeError, "Requires a list as a parameter.");
- return NULL;
+SWIGINTERN PyObject *_wrap_nesc_app_t_variableTypes_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ nesc_app_t *arg1 = (nesc_app_t *) 0 ;
+ char **arg2 = (char **) 0 ;
+ void *argp2 = 0 ;
+ int res2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:nesc_app_t_variableTypes_set",&obj0,&obj1)) SWIG_fail;
+ {
+ if (!PyList_Check(obj0)) {
+ PyErr_SetString(PyExc_TypeError, "Requires a list as a parameter.");
+ return NULL;
+ }
+ else {
+ int size = PyList_Size(obj0);
+ int i = 0;
+ nesc_app_t* app;
+
+ if (size % 3 != 0) {
+ PyErr_SetString(PyExc_RuntimeError, "List must have 2*N elements.");
+ return NULL;
+ }
+
+ app = (nesc_app_t*)malloc(sizeof(nesc_app_t));
+
+ app->numVariables = size / 3;
+ app->variableNames = (char**)malloc(sizeof(char*) * app->numVariables);
+ app->variableTypes = (char**)malloc(sizeof(char*) * app->numVariables);
+ app->variableArray = (int*)malloc(sizeof(int) * app->numVariables);
+
+ memset(app->variableNames, 0, sizeof(char*) * app->numVariables);
+ memset(app->variableTypes, 0, sizeof(char*) * app->numVariables);
+ memset(app->variableArray, 0, sizeof(int) * app->numVariables);
+
+ for (i = 0; i < app->numVariables; i++) {
+ PyObject* name = PyList_GetItem(obj0, 3 * i);
+ PyObject* array = PyList_GetItem(obj0, (3 * i) + 1);
+ PyObject* format = PyList_GetItem(obj0, (3 * i) + 2);
+ if (PyString_Check(name) && PyString_Check(format)) {
+ app->variableNames[i] = PyString_AsString(name);
+ app->variableTypes[i] = PyString_AsString(format);
+ if (strcmp(PyString_AsString(array), "array") == 0) {
+ app->variableArray[i] = 1;
+ //printf("%s is an array\n", PyString_AsString(name));
+ }
+ else {
+ app->variableArray[i] = 0;
+ //printf("%s is a scalar\n", PyString_AsString(name));
+ }
}
else {
- int size = PyList_Size(obj0);
- int i = 0;
- nesc_app_t* app;
-
- if (size % 3 != 0) {
- PyErr_SetString(PyExc_RuntimeError, "List must have 2*N elements.");
- return NULL;
- }
-
- app = (nesc_app_t*)malloc(sizeof(nesc_app_t));
-
- app->numVariables = size / 3;
- app->variableNames = (char**)malloc(sizeof(char*) * app->numVariables);
- app->variableTypes = (char**)malloc(sizeof(char*) * app->numVariables);
- app->variableArray = (int*)malloc(sizeof(int) * app->numVariables);
-
- memset(app->variableNames, 0, sizeof(char*) * app->numVariables);
- memset(app->variableTypes, 0, sizeof(char*) * app->numVariables);
- memset(app->variableArray, 0, sizeof(int) * app->numVariables);
-
- for (i = 0; i < app->numVariables; i++) {
- PyObject* name = PyList_GetItem(obj0, 3 * i);
- PyObject* array = PyList_GetItem(obj0, (3 * i) + 1);
- PyObject* format = PyList_GetItem(obj0, (3 * i) + 2);
- if (PyString_Check(name) && PyString_Check(format)) {
- app->variableNames[i] = PyString_AsString(name);
- app->variableTypes[i] = PyString_AsString(format);
- if (strcmp(PyString_AsString(array), "array") == 0) {
- app->variableArray[i] = 1;
- //printf("%s is an array\n", PyString_AsString(name));
- }
- else {
- app->variableArray[i] = 0;
- //printf("%s is a scalar\n", PyString_AsString(name));
- }
- }
- else {
- app->variableNames[i] = "<bad string>";
- app->variableTypes[i] = "<bad string>";
- }
- }
-
- arg1 = app;
+ app->variableNames[i] = "<bad string>";
+ app->variableTypes[i] = "<bad string>";
}
+ }
+
+ arg1 = app;
}
- if ((SWIG_ConvertPtr(obj1,(void **) &arg2, SWIGTYPE_p_p_char,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- if (arg1) (arg1)->variableTypes = arg2;
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+ }
+ res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_p_char, 0 | 0 );
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "nesc_app_t_variableTypes_set" "', argument " "2"" of type '" "char **""'");
+ }
+ arg2 = reinterpret_cast< char ** >(argp2);
+ if (arg1) (arg1)->variableTypes = arg2;
+
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_nesc_app_t_variableTypes_get(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- nesc_app_t *arg1 = (nesc_app_t *) 0 ;
- char **result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:nesc_app_t_variableTypes_get",&obj0)) goto fail;
- {
- if (!PyList_Check(obj0)) {
- PyErr_SetString(PyExc_TypeError, "Requires a list as a parameter.");
- return NULL;
+SWIGINTERN PyObject *_wrap_nesc_app_t_variableTypes_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ nesc_app_t *arg1 = (nesc_app_t *) 0 ;
+ char **result = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:nesc_app_t_variableTypes_get",&obj0)) SWIG_fail;
+ {
+ if (!PyList_Check(obj0)) {
+ PyErr_SetString(PyExc_TypeError, "Requires a list as a parameter.");
+ return NULL;
+ }
+ else {
+ int size = PyList_Size(obj0);
+ int i = 0;
+ nesc_app_t* app;
+
+ if (size % 3 != 0) {
+ PyErr_SetString(PyExc_RuntimeError, "List must have 2*N elements.");
+ return NULL;
+ }
+
+ app = (nesc_app_t*)malloc(sizeof(nesc_app_t));
+
+ app->numVariables = size / 3;
+ app->variableNames = (char**)malloc(sizeof(char*) * app->numVariables);
+ app->variableTypes = (char**)malloc(sizeof(char*) * app->numVariables);
+ app->variableArray = (int*)malloc(sizeof(int) * app->numVariables);
+
+ memset(app->variableNames, 0, sizeof(char*) * app->numVariables);
+ memset(app->variableTypes, 0, sizeof(char*) * app->numVariables);
+ memset(app->variableArray, 0, sizeof(int) * app->numVariables);
+
+ for (i = 0; i < app->numVariables; i++) {
+ PyObject* name = PyList_GetItem(obj0, 3 * i);
+ PyObject* array = PyList_GetItem(obj0, (3 * i) + 1);
+ PyObject* format = PyList_GetItem(obj0, (3 * i) + 2);
+ if (PyString_Check(name) && PyString_Check(format)) {
+ app->variableNames[i] = PyString_AsString(name);
+ app->variableTypes[i] = PyString_AsString(format);
+ if (strcmp(PyString_AsString(array), "array") == 0) {
+ app->variableArray[i] = 1;
+ //printf("%s is an array\n", PyString_AsString(name));
+ }
+ else {
+ app->variableArray[i] = 0;
+ //printf("%s is a scalar\n", PyString_AsString(name));
+ }
}
else {
- int size = PyList_Size(obj0);
- int i = 0;
- nesc_app_t* app;
-
- if (size % 3 != 0) {
- PyErr_SetString(PyExc_RuntimeError, "List must have 2*N elements.");
- return NULL;
- }
-
- app = (nesc_app_t*)malloc(sizeof(nesc_app_t));
-
- app->numVariables = size / 3;
- app->variableNames = (char**)malloc(sizeof(char*) * app->numVariables);
- app->variableTypes = (char**)malloc(sizeof(char*) * app->numVariables);
- app->variableArray = (int*)malloc(sizeof(int) * app->numVariables);
-
- memset(app->variableNames, 0, sizeof(char*) * app->numVariables);
- memset(app->variableTypes, 0, sizeof(char*) * app->numVariables);
- memset(app->variableArray, 0, sizeof(int) * app->numVariables);
-
- for (i = 0; i < app->numVariables; i++) {
- PyObject* name = PyList_GetItem(obj0, 3 * i);
- PyObject* array = PyList_GetItem(obj0, (3 * i) + 1);
- PyObject* format = PyList_GetItem(obj0, (3 * i) + 2);
- if (PyString_Check(name) && PyString_Check(format)) {
- app->variableNames[i] = PyString_AsString(name);
- app->variableTypes[i] = PyString_AsString(format);
- if (strcmp(PyString_AsString(array), "array") == 0) {
- app->variableArray[i] = 1;
- //printf("%s is an array\n", PyString_AsString(name));
- }
- else {
- app->variableArray[i] = 0;
- //printf("%s is a scalar\n", PyString_AsString(name));
- }
- }
- else {
- app->variableNames[i] = "<bad string>";
- app->variableTypes[i] = "<bad string>";
- }
- }
-
- arg1 = app;
+ app->variableNames[i] = "<bad string>";
+ app->variableTypes[i] = "<bad string>";
}
+ }
+
+ arg1 = app;
}
- result = (char **) ((arg1)->variableTypes);
-
- resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_p_char, 0);
- return resultobj;
- fail:
- return NULL;
+ }
+ result = (char **) ((arg1)->variableTypes);
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_p_char, 0 | 0 );
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_nesc_app_t_variableArray_set(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- nesc_app_t *arg1 = (nesc_app_t *) 0 ;
- int *arg2 = (int *) 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"OO:nesc_app_t_variableArray_set",&obj0,&obj1)) goto fail;
- {
- if (!PyList_Check(obj0)) {
- PyErr_SetString(PyExc_TypeError, "Requires a list as a parameter.");
- return NULL;
+SWIGINTERN PyObject *_wrap_nesc_app_t_variableArray_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ nesc_app_t *arg1 = (nesc_app_t *) 0 ;
+ int *arg2 = (int *) 0 ;
+ void *argp2 = 0 ;
+ int res2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:nesc_app_t_variableArray_set",&obj0,&obj1)) SWIG_fail;
+ {
+ if (!PyList_Check(obj0)) {
+ PyErr_SetString(PyExc_TypeError, "Requires a list as a parameter.");
+ return NULL;
+ }
+ else {
+ int size = PyList_Size(obj0);
+ int i = 0;
+ nesc_app_t* app;
+
+ if (size % 3 != 0) {
+ PyErr_SetString(PyExc_RuntimeError, "List must have 2*N elements.");
+ return NULL;
+ }
+
+ app = (nesc_app_t*)malloc(sizeof(nesc_app_t));
+
+ app->numVariables = size / 3;
+ app->variableNames = (char**)malloc(sizeof(char*) * app->numVariables);
+ app->variableTypes = (char**)malloc(sizeof(char*) * app->numVariables);
+ app->variableArray = (int*)malloc(sizeof(int) * app->numVariables);
+
+ memset(app->variableNames, 0, sizeof(char*) * app->numVariables);
+ memset(app->variableTypes, 0, sizeof(char*) * app->numVariables);
+ memset(app->variableArray, 0, sizeof(int) * app->numVariables);
+
+ for (i = 0; i < app->numVariables; i++) {
+ PyObject* name = PyList_GetItem(obj0, 3 * i);
+ PyObject* array = PyList_GetItem(obj0, (3 * i) + 1);
+ PyObject* format = PyList_GetItem(obj0, (3 * i) + 2);
+ if (PyString_Check(name) && PyString_Check(format)) {
+ app->variableNames[i] = PyString_AsString(name);
+ app->variableTypes[i] = PyString_AsString(format);
+ if (strcmp(PyString_AsString(array), "array") == 0) {
+ app->variableArray[i] = 1;
+ //printf("%s is an array\n", PyString_AsString(name));
+ }
+ else {
+ app->variableArray[i] = 0;
+ //printf("%s is a scalar\n", PyString_AsString(name));
+ }
}
else {
- int size = PyList_Size(obj0);
- int i = 0;
- nesc_app_t* app;
-
- if (size % 3 != 0) {
- PyErr_SetString(PyExc_RuntimeError, "List must have 2*N elements.");
- return NULL;
- }
-
- app = (nesc_app_t*)malloc(sizeof(nesc_app_t));
-
- app->numVariables = size / 3;
- app->variableNames = (char**)malloc(sizeof(char*) * app->numVariables);
- app->variableTypes = (char**)malloc(sizeof(char*) * app->numVariables);
- app->variableArray = (int*)malloc(sizeof(int) * app->numVariables);
-
- memset(app->variableNames, 0, sizeof(char*) * app->numVariables);
- memset(app->variableTypes, 0, sizeof(char*) * app->numVariables);
- memset(app->variableArray, 0, sizeof(int) * app->numVariables);
-
- for (i = 0; i < app->numVariables; i++) {
- PyObject* name = PyList_GetItem(obj0, 3 * i);
- PyObject* array = PyList_GetItem(obj0, (3 * i) + 1);
- PyObject* format = PyList_GetItem(obj0, (3 * i) + 2);
- if (PyString_Check(name) && PyString_Check(format)) {
- app->variableNames[i] = PyString_AsString(name);
- app->variableTypes[i] = PyString_AsString(format);
- if (strcmp(PyString_AsString(array), "array") == 0) {
- app->variableArray[i] = 1;
- //printf("%s is an array\n", PyString_AsString(name));
- }
- else {
- app->variableArray[i] = 0;
- //printf("%s is a scalar\n", PyString_AsString(name));
- }
- }
- else {
- app->variableNames[i] = "<bad string>";
- app->variableTypes[i] = "<bad string>";
- }
- }
-
- arg1 = app;
+ app->variableNames[i] = "<bad string>";
+ app->variableTypes[i] = "<bad string>";
}
+ }
+
+ arg1 = app;
}
- if ((SWIG_ConvertPtr(obj1,(void **) &arg2, SWIGTYPE_p_int,SWIG_POINTER_EXCEPTION | SWIG_POINTER_DISOWN )) == -1) SWIG_fail;
- if (arg1) (arg1)->variableArray = arg2;
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+ }
+ res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_int, SWIG_POINTER_DISOWN | 0 );
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "nesc_app_t_variableArray_set" "', argument " "2"" of type '" "int *""'");
+ }
+ arg2 = reinterpret_cast< int * >(argp2);
+ if (arg1) (arg1)->variableArray = arg2;
+
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_nesc_app_t_variableArray_get(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- nesc_app_t *arg1 = (nesc_app_t *) 0 ;
- int *result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:nesc_app_t_variableArray_get",&obj0)) goto fail;
- {
- if (!PyList_Check(obj0)) {
- PyErr_SetString(PyExc_TypeError, "Requires a list as a parameter.");
- return NULL;
+SWIGINTERN PyObject *_wrap_nesc_app_t_variableArray_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ nesc_app_t *arg1 = (nesc_app_t *) 0 ;
+ int *result = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:nesc_app_t_variableArray_get",&obj0)) SWIG_fail;
+ {
+ if (!PyList_Check(obj0)) {
+ PyErr_SetString(PyExc_TypeError, "Requires a list as a parameter.");
+ return NULL;
+ }
+ else {
+ int size = PyList_Size(obj0);
+ int i = 0;
+ nesc_app_t* app;
+
+ if (size % 3 != 0) {
+ PyErr_SetString(PyExc_RuntimeError, "List must have 2*N elements.");
+ return NULL;
+ }
+
+ app = (nesc_app_t*)malloc(sizeof(nesc_app_t));
+
+ app->numVariables = size / 3;
+ app->variableNames = (char**)malloc(sizeof(char*) * app->numVariables);
+ app->variableTypes = (char**)malloc(sizeof(char*) * app->numVariables);
+ app->variableArray = (int*)malloc(sizeof(int) * app->numVariables);
+
+ memset(app->variableNames, 0, sizeof(char*) * app->numVariables);
+ memset(app->variableTypes, 0, sizeof(char*) * app->numVariables);
+ memset(app->variableArray, 0, sizeof(int) * app->numVariables);
+
+ for (i = 0; i < app->numVariables; i++) {
+ PyObject* name = PyList_GetItem(obj0, 3 * i);
+ PyObject* array = PyList_GetItem(obj0, (3 * i) + 1);
+ PyObject* format = PyList_GetItem(obj0, (3 * i) + 2);
+ if (PyString_Check(name) && PyString_Check(format)) {
+ app->variableNames[i] = PyString_AsString(name);
+ app->variableTypes[i] = PyString_AsString(format);
+ if (strcmp(PyString_AsString(array), "array") == 0) {
+ app->variableArray[i] = 1;
+ //printf("%s is an array\n", PyString_AsString(name));
+ }
+ else {
+ app->variableArray[i] = 0;
+ //printf("%s is a scalar\n", PyString_AsString(name));
+ }
}
else {
- int size = PyList_Size(obj0);
- int i = 0;
- nesc_app_t* app;
-
- if (size % 3 != 0) {
- PyErr_SetString(PyExc_RuntimeError, "List must have 2*N elements.");
- return NULL;
- }
-
- app = (nesc_app_t*)malloc(sizeof(nesc_app_t));
-
- app->numVariables = size / 3;
- app->variableNames = (char**)malloc(sizeof(char*) * app->numVariables);
- app->variableTypes = (char**)malloc(sizeof(char*) * app->numVariables);
- app->variableArray = (int*)malloc(sizeof(int) * app->numVariables);
-
- memset(app->variableNames, 0, sizeof(char*) * app->numVariables);
- memset(app->variableTypes, 0, sizeof(char*) * app->numVariables);
- memset(app->variableArray, 0, sizeof(int) * app->numVariables);
-
- for (i = 0; i < app->numVariables; i++) {
- PyObject* name = PyList_GetItem(obj0, 3 * i);
- PyObject* array = PyList_GetItem(obj0, (3 * i) + 1);
- PyObject* format = PyList_GetItem(obj0, (3 * i) + 2);
- if (PyString_Check(name) && PyString_Check(format)) {
- app->variableNames[i] = PyString_AsString(name);
- app->variableTypes[i] = PyString_AsString(format);
- if (strcmp(PyString_AsString(array), "array") == 0) {
- app->variableArray[i] = 1;
- //printf("%s is an array\n", PyString_AsString(name));
- }
- else {
- app->variableArray[i] = 0;
- //printf("%s is a scalar\n", PyString_AsString(name));
- }
- }
- else {
- app->variableNames[i] = "<bad string>";
- app->variableTypes[i] = "<bad string>";
- }
- }
-
- arg1 = app;
+ app->variableNames[i] = "<bad string>";
+ app->variableTypes[i] = "<bad string>";
}
+ }
+
+ arg1 = app;
}
- result = (int *) ((arg1)->variableArray);
-
- resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_int, 0);
- return resultobj;
- fail:
- return NULL;
+ }
+ result = (int *) ((arg1)->variableArray);
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_int, 0 | 0 );
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_new_nesc_app_t(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- nesc_app_t *result;
-
- if(!PyArg_ParseTuple(args,(char *)":new_nesc_app_t")) goto fail;
- result = (nesc_app_t *)new nesc_app_t();
-
- resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_nesc_app_t, 1);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_new_nesc_app_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ nesc_app_t *result = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)":new_nesc_app_t")) SWIG_fail;
+ result = (nesc_app_t *)new nesc_app_t();
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_nesc_app, SWIG_POINTER_NEW | 0 );
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_delete_nesc_app_t(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- nesc_app_t *arg1 = (nesc_app_t *) 0 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:delete_nesc_app_t",&obj0)) goto fail;
- {
- if (!PyList_Check(obj0)) {
- PyErr_SetString(PyExc_TypeError, "Requires a list as a parameter.");
- return NULL;
+SWIGINTERN PyObject *_wrap_delete_nesc_app_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ nesc_app_t *arg1 = (nesc_app_t *) 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:delete_nesc_app_t",&obj0)) SWIG_fail;
+ {
+ if (!PyList_Check(obj0)) {
+ PyErr_SetString(PyExc_TypeError, "Requires a list as a parameter.");
+ return NULL;
+ }
+ else {
+ int size = PyList_Size(obj0);
+ int i = 0;
+ nesc_app_t* app;
+
+ if (size % 3 != 0) {
+ PyErr_SetString(PyExc_RuntimeError, "List must have 2*N elements.");
+ return NULL;
+ }
+
+ app = (nesc_app_t*)malloc(sizeof(nesc_app_t));
+
+ app->numVariables = size / 3;
+ app->variableNames = (char**)malloc(sizeof(char*) * app->numVariables);
+ app->variableTypes = (char**)malloc(sizeof(char*) * app->numVariables);
+ app->variableArray = (int*)malloc(sizeof(int) * app->numVariables);
+
+ memset(app->variableNames, 0, sizeof(char*) * app->numVariables);
+ memset(app->variableTypes, 0, sizeof(char*) * app->numVariables);
+ memset(app->variableArray, 0, sizeof(int) * app->numVariables);
+
+ for (i = 0; i < app->numVariables; i++) {
+ PyObject* name = PyList_GetItem(obj0, 3 * i);
+ PyObject* array = PyList_GetItem(obj0, (3 * i) + 1);
+ PyObject* format = PyList_GetItem(obj0, (3 * i) + 2);
+ if (PyString_Check(name) && PyString_Check(format)) {
+ app->variableNames[i] = PyString_AsString(name);
+ app->variableTypes[i] = PyString_AsString(format);
+ if (strcmp(PyString_AsString(array), "array") == 0) {
+ app->variableArray[i] = 1;
+ //printf("%s is an array\n", PyString_AsString(name));
+ }
+ else {
+ app->variableArray[i] = 0;
+ //printf("%s is a scalar\n", PyString_AsString(name));
+ }
}
else {
- int size = PyList_Size(obj0);
- int i = 0;
- nesc_app_t* app;
-
- if (size % 3 != 0) {
- PyErr_SetString(PyExc_RuntimeError, "List must have 2*N elements.");
- return NULL;
- }
-
- app = (nesc_app_t*)malloc(sizeof(nesc_app_t));
-
- app->numVariables = size / 3;
- app->variableNames = (char**)malloc(sizeof(char*) * app->numVariables);
- app->variableTypes = (char**)malloc(sizeof(char*) * app->numVariables);
- app->variableArray = (int*)malloc(sizeof(int) * app->numVariables);
-
- memset(app->variableNames, 0, sizeof(char*) * app->numVariables);
- memset(app->variableTypes, 0, sizeof(char*) * app->numVariables);
- memset(app->variableArray, 0, sizeof(int) * app->numVariables);
-
- for (i = 0; i < app->numVariables; i++) {
- PyObject* name = PyList_GetItem(obj0, 3 * i);
- PyObject* array = PyList_GetItem(obj0, (3 * i) + 1);
- PyObject* format = PyList_GetItem(obj0, (3 * i) + 2);
- if (PyString_Check(name) && PyString_Check(format)) {
- app->variableNames[i] = PyString_AsString(name);
- app->variableTypes[i] = PyString_AsString(format);
- if (strcmp(PyString_AsString(array), "array") == 0) {
- app->variableArray[i] = 1;
- //printf("%s is an array\n", PyString_AsString(name));
- }
- else {
- app->variableArray[i] = 0;
- //printf("%s is a scalar\n", PyString_AsString(name));
- }
- }
- else {
- app->variableNames[i] = "<bad string>";
- app->variableTypes[i] = "<bad string>";
- }
- }
-
- arg1 = app;
+ app->variableNames[i] = "<bad string>";
+ app->variableTypes[i] = "<bad string>";
}
+ }
+
+ arg1 = app;
}
- delete arg1;
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+ }
+ delete arg1;
+
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject * nesc_app_t_swigregister(PyObject *self, PyObject *args) {
- PyObject *obj;
- if (!PyArg_ParseTuple(args,(char*)"O", &obj)) return NULL;
- SWIG_TypeClientData(SWIGTYPE_p_nesc_app_t, obj);
- Py_INCREF(obj);
- return Py_BuildValue((char *)"");
-}
-static PyObject *_wrap_new_Variable(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- char *arg1 ;
- char *arg2 ;
- int arg3 ;
- int arg4 ;
- Variable *result;
-
- if(!PyArg_ParseTuple(args,(char *)"ssii:new_Variable",&arg1,&arg2,&arg3,&arg4)) goto fail;
- result = (Variable *)new Variable(arg1,arg2,arg3,arg4);
-
- resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_Variable, 1);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *nesc_app_t_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *obj;
+ if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
+ SWIG_TypeNewClientData(SWIGTYPE_p_nesc_app, SWIG_NewClientData(obj));
+ return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject *_wrap_new_Variable(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ char *arg1 = (char *) 0 ;
+ char *arg2 = (char *) 0 ;
+ int arg3 ;
+ int arg4 ;
+ Variable *result = 0 ;
+ int res1 ;
+ char *buf1 = 0 ;
+ int alloc1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ int val3 ;
+ int ecode3 = 0 ;
+ int val4 ;
+ int ecode4 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOOO:new_Variable",&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
+ res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1);
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Variable" "', argument " "1"" of type '" "char *""'");
+ }
+ arg1 = buf1;
+ res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_Variable" "', argument " "2"" of type '" "char *""'");
+ }
+ arg2 = buf2;
+ ecode3 = SWIG_AsVal_int(obj2, &val3);
+ if (!SWIG_IsOK(ecode3)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "new_Variable" "', argument " "3"" of type '" "int""'");
+ }
+ arg3 = static_cast< int >(val3);
+ ecode4 = SWIG_AsVal_int(obj3, &val4);
+ if (!SWIG_IsOK(ecode4)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "new_Variable" "', argument " "4"" of type '" "int""'");
+ }
+ arg4 = static_cast< int >(val4);
+ result = (Variable *)new Variable(arg1,arg2,arg3,arg4);
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Variable, SWIG_POINTER_NEW | 0 );
+ if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ return resultobj;
+fail:
+ if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ return NULL;
}
-static PyObject *_wrap_delete_Variable(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Variable *arg1 = (Variable *) 0 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:delete_Variable",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Variable,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- delete arg1;
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_delete_Variable(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Variable *arg1 = (Variable *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:delete_Variable",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Variable, SWIG_POINTER_DISOWN | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Variable" "', argument " "1"" of type '" "Variable *""'");
+ }
+ arg1 = reinterpret_cast< Variable * >(argp1);
+ delete arg1;
+
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Variable_getData(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Variable *arg1 = (Variable *) 0 ;
- variable_string_t result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:Variable_getData",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Variable,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (arg1)->getData();
-
- {
- if ((&result)->isArray) {
- //printf("Generating array %s\n", (&result)->type);
- resultobj = listFromArray ((&result)->type, (&result)->ptr, (&result)->len);
- }
- else {
- //printf("Generating scalar %s\n", (&result)->type);
- resultobj = valueFromScalar((&result)->type, (&result)->ptr, (&result)->len);
- }
- if (resultobj == NULL) {
- PyErr_SetString(PyExc_RuntimeError, "Error generating Python type from TinyOS variable.");
- }
+SWIGINTERN PyObject *_wrap_Variable_getData(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Variable *arg1 = (Variable *) 0 ;
+ variable_string_t result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:Variable_getData",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Variable, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Variable_getData" "', argument " "1"" of type '" "Variable *""'");
+ }
+ arg1 = reinterpret_cast< Variable * >(argp1);
+ result = (arg1)->getData();
+ {
+ if ((&result)->isArray) {
+ //printf("Generating array %s\n", (&result)->type);
+ resultobj = listFromArray ((&result)->type, (&result)->ptr, (&result)->len);
}
- return resultobj;
- fail:
- return NULL;
+ else {
+ //printf("Generating scalar %s\n", (&result)->type);
+ resultobj = valueFromScalar((&result)->type, (&result)->ptr, (&result)->len);
+ }
+ if (resultobj == NULL) {
+ PyErr_SetString(PyExc_RuntimeError, "Error generating Python type from TinyOS variable.");
+ }
+ }
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject * Variable_swigregister(PyObject *self, PyObject *args) {
- PyObject *obj;
- if (!PyArg_ParseTuple(args,(char*)"O", &obj)) return NULL;
- SWIG_TypeClientData(SWIGTYPE_p_Variable, obj);
- Py_INCREF(obj);
- return Py_BuildValue((char *)"");
-}
-static PyObject *_wrap_new_Mote(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- nesc_app_t *arg1 = (nesc_app_t *) 0 ;
- Mote *result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:new_Mote",&obj0)) goto fail;
- {
- if (!PyList_Check(obj0)) {
- PyErr_SetString(PyExc_TypeError, "Requires a list as a parameter.");
- return NULL;
+SWIGINTERN PyObject *Variable_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *obj;
+ if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
+ SWIG_TypeNewClientData(SWIGTYPE_p_Variable, SWIG_NewClientData(obj));
+ return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject *_wrap_new_Mote(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ nesc_app_t *arg1 = (nesc_app_t *) 0 ;
+ Mote *result = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:new_Mote",&obj0)) SWIG_fail;
+ {
+ if (!PyList_Check(obj0)) {
+ PyErr_SetString(PyExc_TypeError, "Requires a list as a parameter.");
+ return NULL;
+ }
+ else {
+ int size = PyList_Size(obj0);
+ int i = 0;
+ nesc_app_t* app;
+
+ if (size % 3 != 0) {
+ PyErr_SetString(PyExc_RuntimeError, "List must have 2*N elements.");
+ return NULL;
+ }
+
+ app = (nesc_app_t*)malloc(sizeof(nesc_app_t));
+
+ app->numVariables = size / 3;
+ app->variableNames = (char**)malloc(sizeof(char*) * app->numVariables);
+ app->variableTypes = (char**)malloc(sizeof(char*) * app->numVariables);
+ app->variableArray = (int*)malloc(sizeof(int) * app->numVariables);
+
+ memset(app->variableNames, 0, sizeof(char*) * app->numVariables);
+ memset(app->variableTypes, 0, sizeof(char*) * app->numVariables);
+ memset(app->variableArray, 0, sizeof(int) * app->numVariables);
+
+ for (i = 0; i < app->numVariables; i++) {
+ PyObject* name = PyList_GetItem(obj0, 3 * i);
+ PyObject* array = PyList_GetItem(obj0, (3 * i) + 1);
+ PyObject* format = PyList_GetItem(obj0, (3 * i) + 2);
+ if (PyString_Check(name) && PyString_Check(format)) {
+ app->variableNames[i] = PyString_AsString(name);
+ app->variableTypes[i] = PyString_AsString(format);
+ if (strcmp(PyString_AsString(array), "array") == 0) {
+ app->variableArray[i] = 1;
+ //printf("%s is an array\n", PyString_AsString(name));
+ }
+ else {
+ app->variableArray[i] = 0;
+ //printf("%s is a scalar\n", PyString_AsString(name));
+ }
}
else {
- int size = PyList_Size(obj0);
- int i = 0;
- nesc_app_t* app;
-
- if (size % 3 != 0) {
- PyErr_SetString(PyExc_RuntimeError, "List must have 2*N elements.");
- return NULL;
- }
-
- app = (nesc_app_t*)malloc(sizeof(nesc_app_t));
-
- app->numVariables = size / 3;
- app->variableNames = (char**)malloc(sizeof(char*) * app->numVariables);
- app->variableTypes = (char**)malloc(sizeof(char*) * app->numVariables);
- app->variableArray = (int*)malloc(sizeof(int) * app->numVariables);
-
- memset(app->variableNames, 0, sizeof(char*) * app->numVariables);
- memset(app->variableTypes, 0, sizeof(char*) * app->numVariables);
- memset(app->variableArray, 0, sizeof(int) * app->numVariables);
-
- for (i = 0; i < app->numVariables; i++) {
- PyObject* name = PyList_GetItem(obj0, 3 * i);
- PyObject* array = PyList_GetItem(obj0, (3 * i) + 1);
- PyObject* format = PyList_GetItem(obj0, (3 * i) + 2);
- if (PyString_Check(name) && PyString_Check(format)) {
- app->variableNames[i] = PyString_AsString(name);
- app->variableTypes[i] = PyString_AsString(format);
- if (strcmp(PyString_AsString(array), "array") == 0) {
- app->variableArray[i] = 1;
- //printf("%s is an array\n", PyString_AsString(name));
- }
- else {
- app->variableArray[i] = 0;
- //printf("%s is a scalar\n", PyString_AsString(name));
- }
- }
- else {
- app->variableNames[i] = "<bad string>";
- app->variableTypes[i] = "<bad string>";
- }
- }
-
- arg1 = app;
+ app->variableNames[i] = "<bad string>";
+ app->variableTypes[i] = "<bad string>";
}
+ }
+
+ arg1 = app;
}
- result = (Mote *)new Mote(arg1);
-
- resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_Mote, 1);
- return resultobj;
- fail:
- return NULL;
-}
-
-
-static PyObject *_wrap_delete_Mote(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Mote *arg1 = (Mote *) 0 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:delete_Mote",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Mote,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- delete arg1;
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+ }
+ result = (Mote *)new Mote(arg1);
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Mote, SWIG_POINTER_NEW | 0 );
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Mote_id(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Mote *arg1 = (Mote *) 0 ;
- unsigned long result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:Mote_id",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Mote,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (unsigned long)(arg1)->id();
-
- resultobj = PyInt_FromLong((long)result);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_delete_Mote(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Mote *arg1 = (Mote *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:delete_Mote",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Mote, SWIG_POINTER_DISOWN | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Mote" "', argument " "1"" of type '" "Mote *""'");
+ }
+ arg1 = reinterpret_cast< Mote * >(argp1);
+ delete arg1;
+
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Mote_euid(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Mote *arg1 = (Mote *) 0 ;
- long long result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:Mote_euid",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Mote,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (long long)(arg1)->euid();
-
- resultobj = PyLong_FromLongLong(result);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Mote_id(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Mote *arg1 = (Mote *) 0 ;
+ unsigned long result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:Mote_id",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Mote, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Mote_id" "', argument " "1"" of type '" "Mote *""'");
+ }
+ arg1 = reinterpret_cast< Mote * >(argp1);
+ result = (unsigned long)(arg1)->id();
+ resultobj = SWIG_From_unsigned_SS_long(static_cast< unsigned long >(result));
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Mote_setEuid(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Mote *arg1 = (Mote *) 0 ;
- long long arg2 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"OO:Mote_setEuid",&obj0,&obj1)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Mote,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- arg2 = (long long) PyLong_AsLongLong(obj1);
- if (PyErr_Occurred()) SWIG_fail;
- (arg1)->setEuid(arg2);
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Mote_euid(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Mote *arg1 = (Mote *) 0 ;
+ long long result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:Mote_euid",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Mote, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Mote_euid" "', argument " "1"" of type '" "Mote *""'");
+ }
+ arg1 = reinterpret_cast< Mote * >(argp1);
+ result = (long long)(arg1)->euid();
+ resultobj = SWIG_From_long_SS_long(static_cast< long long >(result));
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Mote_bootTime(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Mote *arg1 = (Mote *) 0 ;
- long long result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:Mote_bootTime",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Mote,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (long long)(arg1)->bootTime();
-
- resultobj = PyLong_FromLongLong(result);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Mote_setEuid(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Mote *arg1 = (Mote *) 0 ;
+ long long arg2 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ long long val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:Mote_setEuid",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Mote, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Mote_setEuid" "', argument " "1"" of type '" "Mote *""'");
+ }
+ arg1 = reinterpret_cast< Mote * >(argp1);
+ ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Mote_setEuid" "', argument " "2"" of type '" "long long""'");
+ }
+ arg2 = static_cast< long long >(val2);
+ (arg1)->setEuid(arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Mote_bootAtTime(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Mote *arg1 = (Mote *) 0 ;
- long long arg2 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"OO:Mote_bootAtTime",&obj0,&obj1)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Mote,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- arg2 = (long long) PyLong_AsLongLong(obj1);
- if (PyErr_Occurred()) SWIG_fail;
- (arg1)->bootAtTime(arg2);
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Mote_bootTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Mote *arg1 = (Mote *) 0 ;
+ long long result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:Mote_bootTime",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Mote, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Mote_bootTime" "', argument " "1"" of type '" "Mote *""'");
+ }
+ arg1 = reinterpret_cast< Mote * >(argp1);
+ result = (long long)(arg1)->bootTime();
+ resultobj = SWIG_From_long_SS_long(static_cast< long long >(result));
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Mote_isOn(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Mote *arg1 = (Mote *) 0 ;
- bool result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:Mote_isOn",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Mote,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (bool)(arg1)->isOn();
-
- resultobj = PyInt_FromLong((long)result);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Mote_bootAtTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Mote *arg1 = (Mote *) 0 ;
+ long long arg2 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ long long val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:Mote_bootAtTime",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Mote, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Mote_bootAtTime" "', argument " "1"" of type '" "Mote *""'");
+ }
+ arg1 = reinterpret_cast< Mote * >(argp1);
+ ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Mote_bootAtTime" "', argument " "2"" of type '" "long long""'");
+ }
+ arg2 = static_cast< long long >(val2);
+ (arg1)->bootAtTime(arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Mote_turnOff(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Mote *arg1 = (Mote *) 0 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:Mote_turnOff",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Mote,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- (arg1)->turnOff();
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Mote_isOn(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Mote *arg1 = (Mote *) 0 ;
+ bool result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:Mote_isOn",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Mote, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Mote_isOn" "', argument " "1"" of type '" "Mote *""'");
+ }
+ arg1 = reinterpret_cast< Mote * >(argp1);
+ result = (bool)(arg1)->isOn();
+ resultobj = SWIG_From_bool(static_cast< bool >(result));
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Mote_turnOn(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Mote *arg1 = (Mote *) 0 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:Mote_turnOn",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Mote,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- (arg1)->turnOn();
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Mote_turnOff(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Mote *arg1 = (Mote *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:Mote_turnOff",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Mote, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Mote_turnOff" "', argument " "1"" of type '" "Mote *""'");
+ }
+ arg1 = reinterpret_cast< Mote * >(argp1);
+ (arg1)->turnOff();
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Mote_getVariable(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Mote *arg1 = (Mote *) 0 ;
- char *arg2 ;
- Variable *result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"Os:Mote_getVariable",&obj0,&arg2)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Mote,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (Variable *)(arg1)->getVariable(arg2);
-
- resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_Variable, 0);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Mote_turnOn(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Mote *arg1 = (Mote *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:Mote_turnOn",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Mote, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Mote_turnOn" "', argument " "1"" of type '" "Mote *""'");
+ }
+ arg1 = reinterpret_cast< Mote * >(argp1);
+ (arg1)->turnOn();
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject * Mote_swigregister(PyObject *self, PyObject *args) {
- PyObject *obj;
- if (!PyArg_ParseTuple(args,(char*)"O", &obj)) return NULL;
- SWIG_TypeClientData(SWIGTYPE_p_Mote, obj);
- Py_INCREF(obj);
- return Py_BuildValue((char *)"");
+SWIGINTERN PyObject *_wrap_Mote_getVariable(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Mote *arg1 = (Mote *) 0 ;
+ char *arg2 = (char *) 0 ;
+ Variable *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:Mote_getVariable",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Mote, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Mote_getVariable" "', argument " "1"" of type '" "Mote *""'");
+ }
+ arg1 = reinterpret_cast< Mote * >(argp1);
+ res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Mote_getVariable" "', argument " "2"" of type '" "char *""'");
+ }
+ arg2 = buf2;
+ result = (Variable *)(arg1)->getVariable(arg2);
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Variable, 0 | 0 );
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ return resultobj;
+fail:
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ return NULL;
}
-static PyObject *_wrap_new_Tossim(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- nesc_app_t *arg1 = (nesc_app_t *) 0 ;
- Tossim *result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:new_Tossim",&obj0)) goto fail;
- {
- if (!PyList_Check(obj0)) {
- PyErr_SetString(PyExc_TypeError, "Requires a list as a parameter.");
- return NULL;
+
+
+SWIGINTERN PyObject *Mote_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *obj;
+ if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
+ SWIG_TypeNewClientData(SWIGTYPE_p_Mote, SWIG_NewClientData(obj));
+ return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject *_wrap_new_Tossim(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ nesc_app_t *arg1 = (nesc_app_t *) 0 ;
+ Tossim *result = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:new_Tossim",&obj0)) SWIG_fail;
+ {
+ if (!PyList_Check(obj0)) {
+ PyErr_SetString(PyExc_TypeError, "Requires a list as a parameter.");
+ return NULL;
+ }
+ else {
+ int size = PyList_Size(obj0);
+ int i = 0;
+ nesc_app_t* app;
+
+ if (size % 3 != 0) {
+ PyErr_SetString(PyExc_RuntimeError, "List must have 2*N elements.");
+ return NULL;
+ }
+
+ app = (nesc_app_t*)malloc(sizeof(nesc_app_t));
+
+ app->numVariables = size / 3;
+ app->variableNames = (char**)malloc(sizeof(char*) * app->numVariables);
+ app->variableTypes = (char**)malloc(sizeof(char*) * app->numVariables);
+ app->variableArray = (int*)malloc(sizeof(int) * app->numVariables);
+
+ memset(app->variableNames, 0, sizeof(char*) * app->numVariables);
+ memset(app->variableTypes, 0, sizeof(char*) * app->numVariables);
+ memset(app->variableArray, 0, sizeof(int) * app->numVariables);
+
+ for (i = 0; i < app->numVariables; i++) {
+ PyObject* name = PyList_GetItem(obj0, 3 * i);
+ PyObject* array = PyList_GetItem(obj0, (3 * i) + 1);
+ PyObject* format = PyList_GetItem(obj0, (3 * i) + 2);
+ if (PyString_Check(name) && PyString_Check(format)) {
+ app->variableNames[i] = PyString_AsString(name);
+ app->variableTypes[i] = PyString_AsString(format);
+ if (strcmp(PyString_AsString(array), "array") == 0) {
+ app->variableArray[i] = 1;
+ //printf("%s is an array\n", PyString_AsString(name));
+ }
+ else {
+ app->variableArray[i] = 0;
+ //printf("%s is a scalar\n", PyString_AsString(name));
+ }
}
else {
- int size = PyList_Size(obj0);
- int i = 0;
- nesc_app_t* app;
-
- if (size % 3 != 0) {
- PyErr_SetString(PyExc_RuntimeError, "List must have 2*N elements.");
- return NULL;
- }
-
- app = (nesc_app_t*)malloc(sizeof(nesc_app_t));
-
- app->numVariables = size / 3;
- app->variableNames = (char**)malloc(sizeof(char*) * app->numVariables);
- app->variableTypes = (char**)malloc(sizeof(char*) * app->numVariables);
- app->variableArray = (int*)malloc(sizeof(int) * app->numVariables);
-
- memset(app->variableNames, 0, sizeof(char*) * app->numVariables);
- memset(app->variableTypes, 0, sizeof(char*) * app->numVariables);
- memset(app->variableArray, 0, sizeof(int) * app->numVariables);
-
- for (i = 0; i < app->numVariables; i++) {
- PyObject* name = PyList_GetItem(obj0, 3 * i);
- PyObject* array = PyList_GetItem(obj0, (3 * i) + 1);
- PyObject* format = PyList_GetItem(obj0, (3 * i) + 2);
- if (PyString_Check(name) && PyString_Check(format)) {
- app->variableNames[i] = PyString_AsString(name);
- app->variableTypes[i] = PyString_AsString(format);
- if (strcmp(PyString_AsString(array), "array") == 0) {
- app->variableArray[i] = 1;
- //printf("%s is an array\n", PyString_AsString(name));
- }
- else {
- app->variableArray[i] = 0;
- //printf("%s is a scalar\n", PyString_AsString(name));
- }
- }
- else {
- app->variableNames[i] = "<bad string>";
- app->variableTypes[i] = "<bad string>";
- }
- }
-
- arg1 = app;
+ app->variableNames[i] = "<bad string>";
+ app->variableTypes[i] = "<bad string>";
}
+ }
+
+ arg1 = app;
}
- result = (Tossim *)new Tossim(arg1);
-
- resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_Tossim, 1);
- return resultobj;
- fail:
- return NULL;
+ }
+ result = (Tossim *)new Tossim(arg1);
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Tossim, SWIG_POINTER_NEW | 0 );
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_delete_Tossim(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Tossim *arg1 = (Tossim *) 0 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:delete_Tossim",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Tossim,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- delete arg1;
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_delete_Tossim(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Tossim *arg1 = (Tossim *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:delete_Tossim",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Tossim, SWIG_POINTER_DISOWN | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Tossim" "', argument " "1"" of type '" "Tossim *""'");
+ }
+ arg1 = reinterpret_cast< Tossim * >(argp1);
+ delete arg1;
+
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Tossim_init(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Tossim *arg1 = (Tossim *) 0 ;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:Tossim_init",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Tossim,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- (arg1)->init();
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Tossim_init(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Tossim *arg1 = (Tossim *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:Tossim_init",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Tossim, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tossim_init" "', argument " "1"" of type '" "Tossim *""'");
+ }
+ arg1 = reinterpret_cast< Tossim * >(argp1);
+ (arg1)->init();
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Tossim_time(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Tossim *arg1 = (Tossim *) 0 ;
- long long result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:Tossim_time",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Tossim,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (long long)(arg1)->time();
-
- resultobj = PyLong_FromLongLong(result);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Tossim_time(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Tossim *arg1 = (Tossim *) 0 ;
+ long long result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:Tossim_time",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Tossim, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tossim_time" "', argument " "1"" of type '" "Tossim *""'");
+ }
+ arg1 = reinterpret_cast< Tossim * >(argp1);
+ result = (long long)(arg1)->time();
+ resultobj = SWIG_From_long_SS_long(static_cast< long long >(result));
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Tossim_ticksPerSecond(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Tossim *arg1 = (Tossim *) 0 ;
- long long result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:Tossim_ticksPerSecond",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Tossim,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (long long)(arg1)->ticksPerSecond();
-
- resultobj = PyLong_FromLongLong(result);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Tossim_ticksPerSecond(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Tossim *arg1 = (Tossim *) 0 ;
+ long long result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:Tossim_ticksPerSecond",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Tossim, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tossim_ticksPerSecond" "', argument " "1"" of type '" "Tossim *""'");
+ }
+ arg1 = reinterpret_cast< Tossim * >(argp1);
+ result = (long long)(arg1)->ticksPerSecond();
+ resultobj = SWIG_From_long_SS_long(static_cast< long long >(result));
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Tossim_setTime(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Tossim *arg1 = (Tossim *) 0 ;
- long long arg2 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"OO:Tossim_setTime",&obj0,&obj1)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Tossim,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- arg2 = (long long) PyLong_AsLongLong(obj1);
- if (PyErr_Occurred()) SWIG_fail;
- (arg1)->setTime(arg2);
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Tossim_setTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Tossim *arg1 = (Tossim *) 0 ;
+ long long arg2 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ long long val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:Tossim_setTime",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Tossim, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tossim_setTime" "', argument " "1"" of type '" "Tossim *""'");
+ }
+ arg1 = reinterpret_cast< Tossim * >(argp1);
+ ecode2 = SWIG_AsVal_long_SS_long(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Tossim_setTime" "', argument " "2"" of type '" "long long""'");
+ }
+ arg2 = static_cast< long long >(val2);
+ (arg1)->setTime(arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Tossim_timeStr(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Tossim *arg1 = (Tossim *) 0 ;
- char *result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:Tossim_timeStr",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Tossim,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (char *)(arg1)->timeStr();
-
- resultobj = result ? PyString_FromString(result) : Py_BuildValue((char*)"");
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Tossim_timeStr(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Tossim *arg1 = (Tossim *) 0 ;
+ char *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:Tossim_timeStr",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Tossim, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tossim_timeStr" "', argument " "1"" of type '" "Tossim *""'");
+ }
+ arg1 = reinterpret_cast< Tossim * >(argp1);
+ result = (char *)(arg1)->timeStr();
+ resultobj = SWIG_FromCharPtr(result);
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Tossim_currentNode(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Tossim *arg1 = (Tossim *) 0 ;
- Mote *result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:Tossim_currentNode",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Tossim,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (Mote *)(arg1)->currentNode();
-
- resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_Mote, 0);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Tossim_currentNode(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Tossim *arg1 = (Tossim *) 0 ;
+ Mote *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:Tossim_currentNode",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Tossim, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tossim_currentNode" "', argument " "1"" of type '" "Tossim *""'");
+ }
+ arg1 = reinterpret_cast< Tossim * >(argp1);
+ result = (Mote *)(arg1)->currentNode();
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Mote, 0 | 0 );
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Tossim_getNode(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Tossim *arg1 = (Tossim *) 0 ;
- unsigned long arg2 ;
- Mote *result;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"OO:Tossim_getNode",&obj0,&obj1)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Tossim,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- arg2 = (unsigned long) PyInt_AsLong(obj1);
- if (PyErr_Occurred()) SWIG_fail;
- result = (Mote *)(arg1)->getNode(arg2);
-
- resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_Mote, 0);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Tossim_getNode(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Tossim *arg1 = (Tossim *) 0 ;
+ unsigned long arg2 ;
+ Mote *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ unsigned long val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:Tossim_getNode",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Tossim, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tossim_getNode" "', argument " "1"" of type '" "Tossim *""'");
+ }
+ arg1 = reinterpret_cast< Tossim * >(argp1);
+ ecode2 = SWIG_AsVal_unsigned_SS_long(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Tossim_getNode" "', argument " "2"" of type '" "unsigned long""'");
+ }
+ arg2 = static_cast< unsigned long >(val2);
+ result = (Mote *)(arg1)->getNode(arg2);
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Mote, 0 | 0 );
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Tossim_setCurrentNode(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Tossim *arg1 = (Tossim *) 0 ;
- unsigned long arg2 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"OO:Tossim_setCurrentNode",&obj0,&obj1)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Tossim,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- arg2 = (unsigned long) PyInt_AsLong(obj1);
- if (PyErr_Occurred()) SWIG_fail;
- (arg1)->setCurrentNode(arg2);
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Tossim_setCurrentNode(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Tossim *arg1 = (Tossim *) 0 ;
+ unsigned long arg2 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ unsigned long val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:Tossim_setCurrentNode",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Tossim, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tossim_setCurrentNode" "', argument " "1"" of type '" "Tossim *""'");
+ }
+ arg1 = reinterpret_cast< Tossim * >(argp1);
+ ecode2 = SWIG_AsVal_unsigned_SS_long(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Tossim_setCurrentNode" "', argument " "2"" of type '" "unsigned long""'");
+ }
+ arg2 = static_cast< unsigned long >(val2);
+ (arg1)->setCurrentNode(arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Tossim_addChannel(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Tossim *arg1 = (Tossim *) 0 ;
- char *arg2 ;
- FILE *arg3 = (FILE *) 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj2 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"OsO:Tossim_addChannel",&obj0,&arg2,&obj2)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Tossim,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- {
- if (!PyFile_Check(obj2)) {
- PyErr_SetString(PyExc_TypeError, "Requires a file as a parameter.");
- return NULL;
- }
- arg3 = PyFile_AsFile(obj2);
+SWIGINTERN PyObject *_wrap_Tossim_addChannel(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Tossim *arg1 = (Tossim *) 0 ;
+ char *arg2 = (char *) 0 ;
+ FILE *arg3 = (FILE *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOO:Tossim_addChannel",&obj0,&obj1,&obj2)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Tossim, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tossim_addChannel" "', argument " "1"" of type '" "Tossim *""'");
+ }
+ arg1 = reinterpret_cast< Tossim * >(argp1);
+ res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Tossim_addChannel" "', argument " "2"" of type '" "char *""'");
+ }
+ arg2 = buf2;
+ {
+ if (!PyFile_Check(obj2)) {
+ PyErr_SetString(PyExc_TypeError, "Requires a file as a parameter.");
+ return NULL;
}
- (arg1)->addChannel(arg2,arg3);
-
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
+ arg3 = PyFile_AsFile(obj2);
+ }
+ (arg1)->addChannel(arg2,arg3);
+ resultobj = SWIG_Py_Void();
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ return resultobj;
+fail:
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ return NULL;
}
-static PyObject *_wrap_Tossim_removeChannel(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Tossim *arg1 = (Tossim *) 0 ;
- char *arg2 ;
- FILE *arg3 = (FILE *) 0 ;
- bool result;
- PyObject * obj0 = 0 ;
- PyObject * obj2 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"OsO:Tossim_removeChannel",&obj0,&arg2,&obj2)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Tossim,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- {
- if (!PyFile_Check(obj2)) {
- PyErr_SetString(PyExc_TypeError, "Requires a file as a parameter.");
- return NULL;
- }
- arg3 = PyFile_AsFile(obj2);
+SWIGINTERN PyObject *_wrap_Tossim_removeChannel(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Tossim *arg1 = (Tossim *) 0 ;
+ char *arg2 = (char *) 0 ;
+ FILE *arg3 = (FILE *) 0 ;
+ bool result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOO:Tossim_removeChannel",&obj0,&obj1,&obj2)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Tossim, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tossim_removeChannel" "', argument " "1"" of type '" "Tossim *""'");
+ }
+ arg1 = reinterpret_cast< Tossim * >(argp1);
+ res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Tossim_removeChannel" "', argument " "2"" of type '" "char *""'");
+ }
+ arg2 = buf2;
+ {
+ if (!PyFile_Check(obj2)) {
+ PyErr_SetString(PyExc_TypeError, "Requires a file as a parameter.");
+ return NULL;
}
- result = (bool)(arg1)->removeChannel(arg2,arg3);
-
- resultobj = PyInt_FromLong((long)result);
- return resultobj;
- fail:
- return NULL;
+ arg3 = PyFile_AsFile(obj2);
+ }
+ result = (bool)(arg1)->removeChannel(arg2,arg3);
+ resultobj = SWIG_From_bool(static_cast< bool >(result));
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ return resultobj;
+fail:
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ return NULL;
}
-static PyObject *_wrap_Tossim_runNextEvent(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Tossim *arg1 = (Tossim *) 0 ;
- bool result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:Tossim_runNextEvent",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Tossim,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (bool)(arg1)->runNextEvent();
-
- resultobj = PyInt_FromLong((long)result);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Tossim_randomSeed(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Tossim *arg1 = (Tossim *) 0 ;
+ int arg2 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:Tossim_randomSeed",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Tossim, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tossim_randomSeed" "', argument " "1"" of type '" "Tossim *""'");
+ }
+ arg1 = reinterpret_cast< Tossim * >(argp1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Tossim_randomSeed" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ (arg1)->randomSeed(arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Tossim_mac(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Tossim *arg1 = (Tossim *) 0 ;
- MAC *result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:Tossim_mac",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Tossim,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (MAC *)(arg1)->mac();
-
- resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_MAC, 0);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Tossim_runNextEvent(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Tossim *arg1 = (Tossim *) 0 ;
+ bool result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:Tossim_runNextEvent",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Tossim, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tossim_runNextEvent" "', argument " "1"" of type '" "Tossim *""'");
+ }
+ arg1 = reinterpret_cast< Tossim * >(argp1);
+ result = (bool)(arg1)->runNextEvent();
+ resultobj = SWIG_From_bool(static_cast< bool >(result));
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Tossim_radio(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Tossim *arg1 = (Tossim *) 0 ;
- Radio *result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:Tossim_radio",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Tossim,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (Radio *)(arg1)->radio();
-
- resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_Radio, 0);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Tossim_mac(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Tossim *arg1 = (Tossim *) 0 ;
+ MAC *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:Tossim_mac",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Tossim, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tossim_mac" "', argument " "1"" of type '" "Tossim *""'");
+ }
+ arg1 = reinterpret_cast< Tossim * >(argp1);
+ result = (MAC *)(arg1)->mac();
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_MAC, 0 | 0 );
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject *_wrap_Tossim_newPacket(PyObject *self, PyObject *args) {
- PyObject *resultobj;
- Tossim *arg1 = (Tossim *) 0 ;
- Packet *result;
- PyObject * obj0 = 0 ;
-
- if(!PyArg_ParseTuple(args,(char *)"O:Tossim_newPacket",&obj0)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Tossim,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- result = (Packet *)(arg1)->newPacket();
-
- resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_Packet, 0);
- return resultobj;
- fail:
- return NULL;
+SWIGINTERN PyObject *_wrap_Tossim_radio(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Tossim *arg1 = (Tossim *) 0 ;
+ Radio *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:Tossim_radio",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Tossim, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tossim_radio" "', argument " "1"" of type '" "Tossim *""'");
+ }
+ arg1 = reinterpret_cast< Tossim * >(argp1);
+ result = (Radio *)(arg1)->radio();
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Radio, 0 | 0 );
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_Tossim_newPacket(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Tossim *arg1 = (Tossim *) 0 ;
+ Packet *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:Tossim_newPacket",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Tossim, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tossim_newPacket" "', argument " "1"" of type '" "Tossim *""'");
+ }
+ arg1 = reinterpret_cast< Tossim * >(argp1);
+ result = (Packet *)(arg1)->newPacket();
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Packet, 0 | 0 );
+ return resultobj;
+fail:
+ return NULL;
}
-static PyObject * Tossim_swigregister(PyObject *self, PyObject *args) {
- PyObject *obj;
- if (!PyArg_ParseTuple(args,(char*)"O", &obj)) return NULL;
- SWIG_TypeClientData(SWIGTYPE_p_Tossim, obj);
- Py_INCREF(obj);
- return Py_BuildValue((char *)"");
+SWIGINTERN PyObject *Tossim_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *obj;
+ if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
+ SWIG_TypeNewClientData(SWIGTYPE_p_Tossim, SWIG_NewClientData(obj));
+ return SWIG_Py_Void();
}
+
static PyMethodDef SwigMethods[] = {
- { (char *)"new_MAC", _wrap_new_MAC, METH_VARARGS },
- { (char *)"delete_MAC", _wrap_delete_MAC, METH_VARARGS },
- { (char *)"MAC_initHigh", _wrap_MAC_initHigh, METH_VARARGS },
- { (char *)"MAC_initLow", _wrap_MAC_initLow, METH_VARARGS },
- { (char *)"MAC_high", _wrap_MAC_high, METH_VARARGS },
- { (char *)"MAC_low", _wrap_MAC_low, METH_VARARGS },
- { (char *)"MAC_symbolsPerSec", _wrap_MAC_symbolsPerSec, METH_VARARGS },
- { (char *)"MAC_bitsPerSymbol", _wrap_MAC_bitsPerSymbol, METH_VARARGS },
- { (char *)"MAC_preambleLength", _wrap_MAC_preambleLength, METH_VARARGS },
- { (char *)"MAC_exponentBase", _wrap_MAC_exponentBase, METH_VARARGS },
- { (char *)"MAC_maxIterations", _wrap_MAC_maxIterations, METH_VARARGS },
- { (char *)"MAC_minFreeSamples", _wrap_MAC_minFreeSamples, METH_VARARGS },
- { (char *)"MAC_rxtxDelay", _wrap_MAC_rxtxDelay, METH_VARARGS },
- { (char *)"MAC_ackTime", _wrap_MAC_ackTime, METH_VARARGS },
- { (char *)"MAC_setInitHigh", _wrap_MAC_setInitHigh, METH_VARARGS },
- { (char *)"MAC_setInitLow", _wrap_MAC_setInitLow, METH_VARARGS },
- { (char *)"MAC_setHigh", _wrap_MAC_setHigh, METH_VARARGS },
- { (char *)"MAC_setLow", _wrap_MAC_setLow, METH_VARARGS },
- { (char *)"MAC_setSymbolsPerSec", _wrap_MAC_setSymbolsPerSec, METH_VARARGS },
- { (char *)"MAC_setBitsBerSymbol", _wrap_MAC_setBitsBerSymbol, METH_VARARGS },
- { (char *)"MAC_setPreambleLength", _wrap_MAC_setPreambleLength, METH_VARARGS },
- { (char *)"MAC_setExponentBase", _wrap_MAC_setExponentBase, METH_VARARGS },
- { (char *)"MAC_setMaxIterations", _wrap_MAC_setMaxIterations, METH_VARARGS },
- { (char *)"MAC_setMinFreeSamples", _wrap_MAC_setMinFreeSamples, METH_VARARGS },
- { (char *)"MAC_setRxtxDelay", _wrap_MAC_setRxtxDelay, METH_VARARGS },
- { (char *)"MAC_setAckTime", _wrap_MAC_setAckTime, METH_VARARGS },
- { (char *)"MAC_swigregister", MAC_swigregister, METH_VARARGS },
- { (char *)"new_Radio", _wrap_new_Radio, METH_VARARGS },
- { (char *)"delete_Radio", _wrap_delete_Radio, METH_VARARGS },
- { (char *)"Radio_add", _wrap_Radio_add, METH_VARARGS },
- { (char *)"Radio_gain", _wrap_Radio_gain, METH_VARARGS },
- { (char *)"Radio_connected", _wrap_Radio_connected, METH_VARARGS },
- { (char *)"Radio_remove", _wrap_Radio_remove, METH_VARARGS },
- { (char *)"Radio_setNoise", _wrap_Radio_setNoise, METH_VARARGS },
- { (char *)"Radio_setSensitivity", _wrap_Radio_setSensitivity, METH_VARARGS },
- { (char *)"Radio_swigregister", Radio_swigregister, METH_VARARGS },
- { (char *)"new_Packet", _wrap_new_Packet, METH_VARARGS },
- { (char *)"delete_Packet", _wrap_delete_Packet, METH_VARARGS },
- { (char *)"Packet_setDestination", _wrap_Packet_setDestination, METH_VARARGS },
- { (char *)"Packet_destination", _wrap_Packet_destination, METH_VARARGS },
- { (char *)"Packet_setLength", _wrap_Packet_setLength, METH_VARARGS },
- { (char *)"Packet_length", _wrap_Packet_length, METH_VARARGS },
- { (char *)"Packet_setType", _wrap_Packet_setType, METH_VARARGS },
- { (char *)"Packet_type", _wrap_Packet_type, METH_VARARGS },
- { (char *)"Packet_data", _wrap_Packet_data, METH_VARARGS },
- { (char *)"Packet_setData", _wrap_Packet_setData, METH_VARARGS },
- { (char *)"Packet_maxLength", _wrap_Packet_maxLength, METH_VARARGS },
- { (char *)"Packet_setStrength", _wrap_Packet_setStrength, METH_VARARGS },
- { (char *)"Packet_deliver", _wrap_Packet_deliver, METH_VARARGS },
- { (char *)"Packet_deliverNow", _wrap_Packet_deliverNow, METH_VARARGS },
- { (char *)"Packet_swigregister", Packet_swigregister, METH_VARARGS },
- { (char *)"variable_string_t_type_set", _wrap_variable_string_t_type_set, METH_VARARGS },
- { (char *)"variable_string_t_type_get", _wrap_variable_string_t_type_get, METH_VARARGS },
- { (char *)"variable_string_t_ptr_set", _wrap_variable_string_t_ptr_set, METH_VARARGS },
- { (char *)"variable_string_t_ptr_get", _wrap_variable_string_t_ptr_get, METH_VARARGS },
- { (char *)"variable_string_t_len_set", _wrap_variable_string_t_len_set, METH_VARARGS },
- { (char *)"variable_string_t_len_get", _wrap_variable_string_t_len_get, METH_VARARGS },
- { (char *)"variable_string_t_isArray_set", _wrap_variable_string_t_isArray_set, METH_VARARGS },
- { (char *)"variable_string_t_isArray_get", _wrap_variable_string_t_isArray_get, METH_VARARGS },
- { (char *)"new_variable_string_t", _wrap_new_variable_string_t, METH_VARARGS },
- { (char *)"delete_variable_string_t", _wrap_delete_variable_string_t, METH_VARARGS },
- { (char *)"variable_string_t_swigregister", variable_string_t_swigregister, METH_VARARGS },
- { (char *)"nesc_app_t_numVariables_set", _wrap_nesc_app_t_numVariables_set, METH_VARARGS },
- { (char *)"nesc_app_t_numVariables_get", _wrap_nesc_app_t_numVariables_get, METH_VARARGS },
- { (char *)"nesc_app_t_variableNames_set", _wrap_nesc_app_t_variableNames_set, METH_VARARGS },
- { (char *)"nesc_app_t_variableNames_get", _wrap_nesc_app_t_variableNames_get, METH_VARARGS },
- { (char *)"nesc_app_t_variableTypes_set", _wrap_nesc_app_t_variableTypes_set, METH_VARARGS },
- { (char *)"nesc_app_t_variableTypes_get", _wrap_nesc_app_t_variableTypes_get, METH_VARARGS },
- { (char *)"nesc_app_t_variableArray_set", _wrap_nesc_app_t_variableArray_set, METH_VARARGS },
- { (char *)"nesc_app_t_variableArray_get", _wrap_nesc_app_t_variableArray_get, METH_VARARGS },
- { (char *)"new_nesc_app_t", _wrap_new_nesc_app_t, METH_VARARGS },
- { (char *)"delete_nesc_app_t", _wrap_delete_nesc_app_t, METH_VARARGS },
- { (char *)"nesc_app_t_swigregister", nesc_app_t_swigregister, METH_VARARGS },
- { (char *)"new_Variable", _wrap_new_Variable, METH_VARARGS },
- { (char *)"delete_Variable", _wrap_delete_Variable, METH_VARARGS },
- { (char *)"Variable_getData", _wrap_Variable_getData, METH_VARARGS },
- { (char *)"Variable_swigregister", Variable_swigregister, METH_VARARGS },
- { (char *)"new_Mote", _wrap_new_Mote, METH_VARARGS },
- { (char *)"delete_Mote", _wrap_delete_Mote, METH_VARARGS },
- { (char *)"Mote_id", _wrap_Mote_id, METH_VARARGS },
- { (char *)"Mote_euid", _wrap_Mote_euid, METH_VARARGS },
- { (char *)"Mote_setEuid", _wrap_Mote_setEuid, METH_VARARGS },
- { (char *)"Mote_bootTime", _wrap_Mote_bootTime, METH_VARARGS },
- { (char *)"Mote_bootAtTime", _wrap_Mote_bootAtTime, METH_VARARGS },
- { (char *)"Mote_isOn", _wrap_Mote_isOn, METH_VARARGS },
- { (char *)"Mote_turnOff", _wrap_Mote_turnOff, METH_VARARGS },
- { (char *)"Mote_turnOn", _wrap_Mote_turnOn, METH_VARARGS },
- { (char *)"Mote_getVariable", _wrap_Mote_getVariable, METH_VARARGS },
- { (char *)"Mote_swigregister", Mote_swigregister, METH_VARARGS },
- { (char *)"new_Tossim", _wrap_new_Tossim, METH_VARARGS },
- { (char *)"delete_Tossim", _wrap_delete_Tossim, METH_VARARGS },
- { (char *)"Tossim_init", _wrap_Tossim_init, METH_VARARGS },
- { (char *)"Tossim_time", _wrap_Tossim_time, METH_VARARGS },
- { (char *)"Tossim_ticksPerSecond", _wrap_Tossim_ticksPerSecond, METH_VARARGS },
- { (char *)"Tossim_setTime", _wrap_Tossim_setTime, METH_VARARGS },
- { (char *)"Tossim_timeStr", _wrap_Tossim_timeStr, METH_VARARGS },
- { (char *)"Tossim_currentNode", _wrap_Tossim_currentNode, METH_VARARGS },
- { (char *)"Tossim_getNode", _wrap_Tossim_getNode, METH_VARARGS },
- { (char *)"Tossim_setCurrentNode", _wrap_Tossim_setCurrentNode, METH_VARARGS },
- { (char *)"Tossim_addChannel", _wrap_Tossim_addChannel, METH_VARARGS },
- { (char *)"Tossim_removeChannel", _wrap_Tossim_removeChannel, METH_VARARGS },
- { (char *)"Tossim_runNextEvent", _wrap_Tossim_runNextEvent, METH_VARARGS },
- { (char *)"Tossim_mac", _wrap_Tossim_mac, METH_VARARGS },
- { (char *)"Tossim_radio", _wrap_Tossim_radio, METH_VARARGS },
- { (char *)"Tossim_newPacket", _wrap_Tossim_newPacket, METH_VARARGS },
- { (char *)"Tossim_swigregister", Tossim_swigregister, METH_VARARGS },
- { NULL, NULL }
+ { (char *)"new_MAC", _wrap_new_MAC, METH_VARARGS, NULL},
+ { (char *)"delete_MAC", _wrap_delete_MAC, METH_VARARGS, NULL},
+ { (char *)"MAC_initHigh", _wrap_MAC_initHigh, METH_VARARGS, NULL},
+ { (char *)"MAC_initLow", _wrap_MAC_initLow, METH_VARARGS, NULL},
+ { (char *)"MAC_high", _wrap_MAC_high, METH_VARARGS, NULL},
+ { (char *)"MAC_low", _wrap_MAC_low, METH_VARARGS, NULL},
+ { (char *)"MAC_symbolsPerSec", _wrap_MAC_symbolsPerSec, METH_VARARGS, NULL},
+ { (char *)"MAC_bitsPerSymbol", _wrap_MAC_bitsPerSymbol, METH_VARARGS, NULL},
+ { (char *)"MAC_preambleLength", _wrap_MAC_preambleLength, METH_VARARGS, NULL},
+ { (char *)"MAC_exponentBase", _wrap_MAC_exponentBase, METH_VARARGS, NULL},
+ { (char *)"MAC_maxIterations", _wrap_MAC_maxIterations, METH_VARARGS, NULL},
+ { (char *)"MAC_minFreeSamples", _wrap_MAC_minFreeSamples, METH_VARARGS, NULL},
+ { (char *)"MAC_rxtxDelay", _wrap_MAC_rxtxDelay, METH_VARARGS, NULL},
+ { (char *)"MAC_ackTime", _wrap_MAC_ackTime, METH_VARARGS, NULL},
+ { (char *)"MAC_setInitHigh", _wrap_MAC_setInitHigh, METH_VARARGS, NULL},
+ { (char *)"MAC_setInitLow", _wrap_MAC_setInitLow, METH_VARARGS, NULL},
+ { (char *)"MAC_setHigh", _wrap_MAC_setHigh, METH_VARARGS, NULL},
+ { (char *)"MAC_setLow", _wrap_MAC_setLow, METH_VARARGS, NULL},
+ { (char *)"MAC_setSymbolsPerSec", _wrap_MAC_setSymbolsPerSec, METH_VARARGS, NULL},
+ { (char *)"MAC_setBitsBerSymbol", _wrap_MAC_setBitsBerSymbol, METH_VARARGS, NULL},
+ { (char *)"MAC_setPreambleLength", _wrap_MAC_setPreambleLength, METH_VARARGS, NULL},
+ { (char *)"MAC_setExponentBase", _wrap_MAC_setExponentBase, METH_VARARGS, NULL},
+ { (char *)"MAC_setMaxIterations", _wrap_MAC_setMaxIterations, METH_VARARGS, NULL},
+ { (char *)"MAC_setMinFreeSamples", _wrap_MAC_setMinFreeSamples, METH_VARARGS, NULL},
+ { (char *)"MAC_setRxtxDelay", _wrap_MAC_setRxtxDelay, METH_VARARGS, NULL},
+ { (char *)"MAC_setAckTime", _wrap_MAC_setAckTime, METH_VARARGS, NULL},
+ { (char *)"MAC_swigregister", MAC_swigregister, METH_VARARGS, NULL},
+ { (char *)"new_Radio", _wrap_new_Radio, METH_VARARGS, NULL},
+ { (char *)"delete_Radio", _wrap_delete_Radio, METH_VARARGS, NULL},
+ { (char *)"Radio_add", _wrap_Radio_add, METH_VARARGS, NULL},
+ { (char *)"Radio_gain", _wrap_Radio_gain, METH_VARARGS, NULL},
+ { (char *)"Radio_connected", _wrap_Radio_connected, METH_VARARGS, NULL},
+ { (char *)"Radio_remove", _wrap_Radio_remove, METH_VARARGS, NULL},
+ { (char *)"Radio_setNoise", _wrap_Radio_setNoise, METH_VARARGS, NULL},
+ { (char *)"Radio_setSensitivity", _wrap_Radio_setSensitivity, METH_VARARGS, NULL},
+ { (char *)"Radio_swigregister", Radio_swigregister, METH_VARARGS, NULL},
+ { (char *)"new_Packet", _wrap_new_Packet, METH_VARARGS, NULL},
+ { (char *)"delete_Packet", _wrap_delete_Packet, METH_VARARGS, NULL},
+ { (char *)"Packet_setDestination", _wrap_Packet_setDestination, METH_VARARGS, NULL},
+ { (char *)"Packet_destination", _wrap_Packet_destination, METH_VARARGS, NULL},
+ { (char *)"Packet_setLength", _wrap_Packet_setLength, METH_VARARGS, NULL},
+ { (char *)"Packet_length", _wrap_Packet_length, METH_VARARGS, NULL},
+ { (char *)"Packet_setType", _wrap_Packet_setType, METH_VARARGS, NULL},
+ { (char *)"Packet_type", _wrap_Packet_type, METH_VARARGS, NULL},
+ { (char *)"Packet_data", _wrap_Packet_data, METH_VARARGS, NULL},
+ { (char *)"Packet_setData", _wrap_Packet_setData, METH_VARARGS, NULL},
+ { (char *)"Packet_maxLength", _wrap_Packet_maxLength, METH_VARARGS, NULL},
+ { (char *)"Packet_setStrength", _wrap_Packet_setStrength, METH_VARARGS, NULL},
+ { (char *)"Packet_deliver", _wrap_Packet_deliver, METH_VARARGS, NULL},
+ { (char *)"Packet_deliverNow", _wrap_Packet_deliverNow, METH_VARARGS, NULL},
+ { (char *)"Packet_swigregister", Packet_swigregister, METH_VARARGS, NULL},
+ { (char *)"variable_string_t_type_set", _wrap_variable_string_t_type_set, METH_VARARGS, NULL},
+ { (char *)"variable_string_t_type_get", _wrap_variable_string_t_type_get, METH_VARARGS, NULL},
+ { (char *)"variable_string_t_ptr_set", _wrap_variable_string_t_ptr_set, METH_VARARGS, NULL},
+ { (char *)"variable_string_t_ptr_get", _wrap_variable_string_t_ptr_get, METH_VARARGS, NULL},
+ { (char *)"variable_string_t_len_set", _wrap_variable_string_t_len_set, METH_VARARGS, NULL},
+ { (char *)"variable_string_t_len_get", _wrap_variable_string_t_len_get, METH_VARARGS, NULL},
+ { (char *)"variable_string_t_isArray_set", _wrap_variable_string_t_isArray_set, METH_VARARGS, NULL},
+ { (char *)"variable_string_t_isArray_get", _wrap_variable_string_t_isArray_get, METH_VARARGS, NULL},
+ { (char *)"new_variable_string_t", _wrap_new_variable_string_t, METH_VARARGS, NULL},
+ { (char *)"delete_variable_string_t", _wrap_delete_variable_string_t, METH_VARARGS, NULL},
+ { (char *)"variable_string_t_swigregister", variable_string_t_swigregister, METH_VARARGS, NULL},
+ { (char *)"nesc_app_t_numVariables_set", _wrap_nesc_app_t_numVariables_set, METH_VARARGS, NULL},
+ { (char *)"nesc_app_t_numVariables_get", _wrap_nesc_app_t_numVariables_get, METH_VARARGS, NULL},
+ { (char *)"nesc_app_t_variableNames_set", _wrap_nesc_app_t_variableNames_set, METH_VARARGS, NULL},
+ { (char *)"nesc_app_t_variableNames_get", _wrap_nesc_app_t_variableNames_get, METH_VARARGS, NULL},
+ { (char *)"nesc_app_t_variableTypes_set", _wrap_nesc_app_t_variableTypes_set, METH_VARARGS, NULL},
+ { (char *)"nesc_app_t_variableTypes_get", _wrap_nesc_app_t_variableTypes_get, METH_VARARGS, NULL},
+ { (char *)"nesc_app_t_variableArray_set", _wrap_nesc_app_t_variableArray_set, METH_VARARGS, NULL},
+ { (char *)"nesc_app_t_variableArray_get", _wrap_nesc_app_t_variableArray_get, METH_VARARGS, NULL},
+ { (char *)"new_nesc_app_t", _wrap_new_nesc_app_t, METH_VARARGS, NULL},
+ { (char *)"delete_nesc_app_t", _wrap_delete_nesc_app_t, METH_VARARGS, NULL},
+ { (char *)"nesc_app_t_swigregister", nesc_app_t_swigregister, METH_VARARGS, NULL},
+ { (char *)"new_Variable", _wrap_new_Variable, METH_VARARGS, NULL},
+ { (char *)"delete_Variable", _wrap_delete_Variable, METH_VARARGS, NULL},
+ { (char *)"Variable_getData", _wrap_Variable_getData, METH_VARARGS, NULL},
+ { (char *)"Variable_swigregister", Variable_swigregister, METH_VARARGS, NULL},
+ { (char *)"new_Mote", _wrap_new_Mote, METH_VARARGS, NULL},
+ { (char *)"delete_Mote", _wrap_delete_Mote, METH_VARARGS, NULL},
+ { (char *)"Mote_id", _wrap_Mote_id, METH_VARARGS, NULL},
+ { (char *)"Mote_euid", _wrap_Mote_euid, METH_VARARGS, NULL},
+ { (char *)"Mote_setEuid", _wrap_Mote_setEuid, METH_VARARGS, NULL},
+ { (char *)"Mote_bootTime", _wrap_Mote_bootTime, METH_VARARGS, NULL},
+ { (char *)"Mote_bootAtTime", _wrap_Mote_bootAtTime, METH_VARARGS, NULL},
+ { (char *)"Mote_isOn", _wrap_Mote_isOn, METH_VARARGS, NULL},
+ { (char *)"Mote_turnOff", _wrap_Mote_turnOff, METH_VARARGS, NULL},
+ { (char *)"Mote_turnOn", _wrap_Mote_turnOn, METH_VARARGS, NULL},
+ { (char *)"Mote_getVariable", _wrap_Mote_getVariable, METH_VARARGS, NULL},
+ { (char *)"Mote_swigregister", Mote_swigregister, METH_VARARGS, NULL},
+ { (char *)"new_Tossim", _wrap_new_Tossim, METH_VARARGS, NULL},
+ { (char *)"delete_Tossim", _wrap_delete_Tossim, METH_VARARGS, NULL},
+ { (char *)"Tossim_init", _wrap_Tossim_init, METH_VARARGS, NULL},
+ { (char *)"Tossim_time", _wrap_Tossim_time, METH_VARARGS, NULL},
+ { (char *)"Tossim_ticksPerSecond", _wrap_Tossim_ticksPerSecond, METH_VARARGS, NULL},
+ { (char *)"Tossim_setTime", _wrap_Tossim_setTime, METH_VARARGS, NULL},
+ { (char *)"Tossim_timeStr", _wrap_Tossim_timeStr, METH_VARARGS, NULL},
+ { (char *)"Tossim_currentNode", _wrap_Tossim_currentNode, METH_VARARGS, NULL},
+ { (char *)"Tossim_getNode", _wrap_Tossim_getNode, METH_VARARGS, NULL},
+ { (char *)"Tossim_setCurrentNode", _wrap_Tossim_setCurrentNode, METH_VARARGS, NULL},
+ { (char *)"Tossim_addChannel", _wrap_Tossim_addChannel, METH_VARARGS, NULL},
+ { (char *)"Tossim_removeChannel", _wrap_Tossim_removeChannel, METH_VARARGS, NULL},
+ { (char *)"Tossim_randomSeed", _wrap_Tossim_randomSeed, METH_VARARGS, NULL},
+ { (char *)"Tossim_runNextEvent", _wrap_Tossim_runNextEvent, METH_VARARGS, NULL},
+ { (char *)"Tossim_mac", _wrap_Tossim_mac, METH_VARARGS, NULL},
+ { (char *)"Tossim_radio", _wrap_Tossim_radio, METH_VARARGS, NULL},
+ { (char *)"Tossim_newPacket", _wrap_Tossim_newPacket, METH_VARARGS, NULL},
+ { (char *)"Tossim_swigregister", Tossim_swigregister, METH_VARARGS, NULL},
+ { NULL, NULL, 0, NULL }
};
/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
-static swig_type_info _swigt__p_Radio[] = {{"_p_Radio", 0, "Radio *", 0},{"_p_Radio"},{0}};
-static swig_type_info _swigt__p_nesc_app_t[] = {{"_p_nesc_app_t", 0, "nesc_app_t *", 0},{"_p_nesc_app_t"},{0}};
-static swig_type_info _swigt__p_FILE[] = {{"_p_FILE", 0, "FILE *", 0},{"_p_FILE"},{0}};
-static swig_type_info _swigt__p_MAC[] = {{"_p_MAC", 0, "MAC *", 0},{"_p_MAC"},{0}};
-static swig_type_info _swigt__p_Packet[] = {{"_p_Packet", 0, "Packet *", 0},{"_p_Packet"},{0}};
-static swig_type_info _swigt__p_Variable[] = {{"_p_Variable", 0, "Variable *", 0},{"_p_Variable"},{0}};
-static swig_type_info _swigt__p_Tossim[] = {{"_p_Tossim", 0, "Tossim *", 0},{"_p_Tossim"},{0}};
-static swig_type_info _swigt__p_variable_string_t[] = {{"_p_variable_string_t", 0, "variable_string_t *", 0},{"_p_variable_string_t"},{0}};
-static swig_type_info _swigt__p_Mote[] = {{"_p_Mote", 0, "Mote *", 0},{"_p_Mote"},{0}};
-static swig_type_info _swigt__p_p_char[] = {{"_p_p_char", 0, "char **", 0},{"_p_p_char"},{0}};
-static swig_type_info _swigt__p_int[] = {{"_p_int", 0, "int *", 0},{"_p_int"},{0}};
-
-static swig_type_info *swig_types_initial[] = {
-_swigt__p_Radio,
-_swigt__p_nesc_app_t,
-_swigt__p_FILE,
-_swigt__p_MAC,
-_swigt__p_Packet,
-_swigt__p_Variable,
-_swigt__p_Tossim,
-_swigt__p_variable_string_t,
-_swigt__p_Mote,
-_swigt__p_p_char,
-_swigt__p_int,
-0
+static swig_type_info _swigt__p_FILE = {"_p_FILE", "FILE *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_MAC = {"_p_MAC", "MAC *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_Mote = {"_p_Mote", "Mote *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_Packet = {"_p_Packet", "Packet *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_Radio = {"_p_Radio", "Radio *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_Tossim = {"_p_Tossim", "Tossim *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_Variable = {"_p_Variable", "Variable *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_int = {"_p_int", "int *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_nesc_app = {"_p_nesc_app", "nesc_app *|nesc_app_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_p_char = {"_p_p_char", "char **", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_var_string = {"_p_var_string", "var_string *|variable_string_t *", 0, 0, (void*)0, 0};
+
+static swig_type_info *swig_type_initial[] = {
+ &_swigt__p_FILE,
+ &_swigt__p_MAC,
+ &_swigt__p_Mote,
+ &_swigt__p_Packet,
+ &_swigt__p_Radio,
+ &_swigt__p_Tossim,
+ &_swigt__p_Variable,
+ &_swigt__p_char,
+ &_swigt__p_int,
+ &_swigt__p_nesc_app,
+ &_swigt__p_p_char,
+ &_swigt__p_var_string,
+};
+
+static swig_cast_info _swigc__p_FILE[] = { {&_swigt__p_FILE, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_MAC[] = { {&_swigt__p_MAC, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_Mote[] = { {&_swigt__p_Mote, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_Packet[] = { {&_swigt__p_Packet, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_Radio[] = { {&_swigt__p_Radio, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_Tossim[] = { {&_swigt__p_Tossim, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_Variable[] = { {&_swigt__p_Variable, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_nesc_app[] = { {&_swigt__p_nesc_app, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_p_char[] = { {&_swigt__p_p_char, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_var_string[] = { {&_swigt__p_var_string, 0, 0, 0},{0, 0, 0, 0}};
+
+static swig_cast_info *swig_cast_initial[] = {
+ _swigc__p_FILE,
+ _swigc__p_MAC,
+ _swigc__p_Mote,
+ _swigc__p_Packet,
+ _swigc__p_Radio,
+ _swigc__p_Tossim,
+ _swigc__p_Variable,
+ _swigc__p_char,
+ _swigc__p_int,
+ _swigc__p_nesc_app,
+ _swigc__p_p_char,
+ _swigc__p_var_string,
};
/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
static swig_const_info swig_const_table[] = {
-{0}};
+{0, 0, 0, 0.0, 0, 0}};
#ifdef __cplusplus
}
#endif
+/* -----------------------------------------------------------------------------
+ * Type initialization:
+ * This problem is tough by the requirement that no dynamic
+ * memory is used. Also, since swig_type_info structures store pointers to
+ * swig_cast_info structures and swig_cast_info structures store pointers back
+ * to swig_type_info structures, we need some lookup code at initialization.
+ * The idea is that swig generates all the structures that are needed.
+ * The runtime then collects these partially filled structures.
+ * The SWIG_InitializeModule function takes these initial arrays out of
+ * swig_module, and does all the lookup, filling in the swig_module.types
+ * array with the correct data and linking the correct swig_cast_info
+ * structures together.
+ *
+ * The generated swig_type_info structures are assigned staticly to an initial
+ * array. We just loop though that array, and handle each type individually.
+ * First we lookup if this type has been already loaded, and if so, use the
+ * loaded structure instead of the generated one. Then we have to fill in the
+ * cast linked list. The cast data is initially stored in something like a
+ * two-dimensional array. Each row corresponds to a type (there are the same
+ * number of rows as there are in the swig_type_initial array). Each entry in
+ * a column is one of the swig_cast_info structures for that type.
+ * The cast_initial array is actually an array of arrays, because each row has
+ * a variable number of columns. So to actually build the cast linked list,
+ * we find the array of casts associated with the type, and loop through it
+ * adding the casts to the list. The one last trick we need to do is making
+ * sure the type pointer in the swig_cast_info struct is correct.
+ *
+ * First off, we lookup the cast->type name to see if it is already loaded.
+ * There are three cases to handle:
+ * 1) If the cast->type has already been loaded AND the type we are adding
+ * casting info to has not been loaded (it is in this module), THEN we
+ * replace the cast->type pointer with the type pointer that has already
+ * been loaded.
+ * 2) If BOTH types (the one we are adding casting info to, and the
+ * cast->type) are loaded, THEN the cast info has already been loaded by
+ * the previous module so we just ignore it.
+ * 3) Finally, if cast->type has not already been loaded, then we add that
+ * swig_cast_info to the linked list (because the cast->type) pointer will
+ * be correct.
+ * ----------------------------------------------------------------------------- */
#ifdef __cplusplus
-extern "C"
+extern "C" {
+#if 0
+} /* c-mode */
+#endif
+#endif
+
+#if 0
+#define SWIGRUNTIME_DEBUG
+#endif
+
+SWIGRUNTIME void
+SWIG_InitializeModule(void *clientdata) {
+ size_t i;
+ swig_module_info *module_head;
+ static int init_run = 0;
+
+ clientdata = clientdata;
+
+ if (init_run) return;
+ init_run = 1;
+
+ /* Initialize the swig_module */
+ swig_module.type_initial = swig_type_initial;
+ swig_module.cast_initial = swig_cast_initial;
+
+ /* Try and load any already created modules */
+ module_head = SWIG_GetModule(clientdata);
+ if (module_head) {
+ swig_module.next = module_head->next;
+ module_head->next = &swig_module;
+ } else {
+ /* This is the first module loaded */
+ swig_module.next = &swig_module;
+ SWIG_SetModule(clientdata, &swig_module);
+ }
+
+ /* Now work on filling in swig_module.types */
+#ifdef SWIGRUNTIME_DEBUG
+ printf("SWIG_InitializeModule: size %d\n", swig_module.size);
#endif
-SWIGEXPORT(void) SWIG_init(void) {
- static PyObject *SWIG_globals = 0;
- static int typeinit = 0;
- PyObject *m, *d;
- int i;
- if (!SWIG_globals) SWIG_globals = SWIG_newvarlink();
- m = Py_InitModule((char *) SWIG_name, SwigMethods);
- d = PyModule_GetDict(m);
+ for (i = 0; i < swig_module.size; ++i) {
+ swig_type_info *type = 0;
+ swig_type_info *ret;
+ swig_cast_info *cast;
- if (!typeinit) {
- for (i = 0; swig_types_initial[i]; i++) {
- swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]);
- }
- typeinit = 1;
+#ifdef SWIGRUNTIME_DEBUG
+ printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
+#endif
+
+ /* if there is another module already loaded */
+ if (swig_module.next != &swig_module) {
+ type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name);
+ }
+ if (type) {
+ /* Overwrite clientdata field */
+#ifdef SWIGRUNTIME_DEBUG
+ printf("SWIG_InitializeModule: found type %s\n", type->name);
+#endif
+ if (swig_module.type_initial[i]->clientdata) {
+ type->clientdata = swig_module.type_initial[i]->clientdata;
+#ifdef SWIGRUNTIME_DEBUG
+ printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name);
+#endif
+ }
+ } else {
+ type = swig_module.type_initial[i];
}
- SWIG_InstallConstants(d,swig_const_table);
+ /* Insert casting types */
+ cast = swig_module.cast_initial[i];
+ while (cast->type) {
+ /* Don't need to add information already in the list */
+ ret = 0;
+#ifdef SWIGRUNTIME_DEBUG
+ printf("SWIG_InitializeModule: look cast %s\n", cast->type->name);
+#endif
+ if (swig_module.next != &swig_module) {
+ ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);
+#ifdef SWIGRUNTIME_DEBUG
+ if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name);
+#endif
+ }
+ if (ret) {
+ if (type == swig_module.type_initial[i]) {
+#ifdef SWIGRUNTIME_DEBUG
+ printf("SWIG_InitializeModule: skip old type %s\n", ret->name);
+#endif
+ cast->type = ret;
+ ret = 0;
+ } else {
+ /* Check for casting already in the list */
+ swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type);
+#ifdef SWIGRUNTIME_DEBUG
+ if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name);
+#endif
+ if (!ocast) ret = 0;
+ }
+ }
+
+ if (!ret) {
+#ifdef SWIGRUNTIME_DEBUG
+ printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
+#endif
+ if (type->cast) {
+ type->cast->prev = cast;
+ cast->next = type->cast;
+ }
+ type->cast = cast;
+ }
+ cast++;
+ }
+ /* Set entry in modules->types array equal to the type */
+ swig_module.types[i] = type;
+ }
+ swig_module.types[i] = 0;
+
+#ifdef SWIGRUNTIME_DEBUG
+ printf("**** SWIG_InitializeModule: Cast List ******\n");
+ for (i = 0; i < swig_module.size; ++i) {
+ int j = 0;
+ swig_cast_info *cast = swig_module.cast_initial[i];
+ printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
+ while (cast->type) {
+ printf("SWIG_InitializeModule: cast type %s\n", cast->type->name);
+ cast++;
+ ++j;
+ }
+ printf("---- Total casts: %d\n",j);
+ }
+ printf("**** SWIG_InitializeModule: Cast List ******\n");
+#endif
+}
+
+/* This function will propagate the clientdata field of type to
+* any new swig_type_info structures that have been added into the list
+* of equivalent types. It is like calling
+* SWIG_TypeClientData(type, clientdata) a second time.
+*/
+SWIGRUNTIME void
+SWIG_PropagateClientData(void) {
+ size_t i;
+ swig_cast_info *equiv;
+ static int init_run = 0;
+
+ if (init_run) return;
+ init_run = 1;
+
+ for (i = 0; i < swig_module.size; i++) {
+ if (swig_module.types[i]->clientdata) {
+ equiv = swig_module.types[i]->cast;
+ while (equiv) {
+ if (!equiv->converter) {
+ if (equiv->type && !equiv->type->clientdata)
+ SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata);
+ }
+ equiv = equiv->next;
+ }
+ }
+ }
+}
+
+#ifdef __cplusplus
+#if 0
+{
+ /* c-mode */
+#endif
+}
+#endif
+
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /* Python-specific SWIG API */
+#define SWIG_newvarlink() SWIG_Python_newvarlink()
+#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr)
+#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants)
+
+ /* -----------------------------------------------------------------------------
+ * global variable support code.
+ * ----------------------------------------------------------------------------- */
+
+ typedef struct swig_globalvar {
+ char *name; /* Name of global variable */
+ PyObject *(*get_attr)(void); /* Return the current value */
+ int (*set_attr)(PyObject *); /* Set the value */
+ struct swig_globalvar *next;
+ } swig_globalvar;
+
+ typedef struct swig_varlinkobject {
+ PyObject_HEAD
+ swig_globalvar *vars;
+ } swig_varlinkobject;
+
+ SWIGINTERN PyObject *
+ swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) {
+ return PyString_FromString("<Swig global variables>");
+ }
+
+ SWIGINTERN PyObject *
+ swig_varlink_str(swig_varlinkobject *v) {
+ PyObject *str = PyString_FromString("(");
+ swig_globalvar *var;
+ for (var = v->vars; var; var=var->next) {
+ PyString_ConcatAndDel(&str,PyString_FromString(var->name));
+ if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", "));
+ }
+ PyString_ConcatAndDel(&str,PyString_FromString(")"));
+ return str;
+ }
+
+ SWIGINTERN int
+ swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) {
+ PyObject *str = swig_varlink_str(v);
+ fprintf(fp,"Swig global variables ");
+ fprintf(fp,"%s\n", PyString_AsString(str));
+ Py_DECREF(str);
+ return 0;
+ }
+
+ SWIGINTERN void
+ swig_varlink_dealloc(swig_varlinkobject *v) {
+ swig_globalvar *var = v->vars;
+ while (var) {
+ swig_globalvar *n = var->next;
+ free(var->name);
+ free(var);
+ var = n;
+ }
+ }
+
+ SWIGINTERN PyObject *
+ swig_varlink_getattr(swig_varlinkobject *v, char *n) {
+ PyObject *res = NULL;
+ swig_globalvar *var = v->vars;
+ while (var) {
+ if (strcmp(var->name,n) == 0) {
+ res = (*var->get_attr)();
+ break;
+ }
+ var = var->next;
+ }
+ if (res == NULL && !PyErr_Occurred()) {
+ PyErr_SetString(PyExc_NameError,"Unknown C global variable");
+ }
+ return res;
+ }
+
+ SWIGINTERN int
+ swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) {
+ int res = 1;
+ swig_globalvar *var = v->vars;
+ while (var) {
+ if (strcmp(var->name,n) == 0) {
+ res = (*var->set_attr)(p);
+ break;
+ }
+ var = var->next;
+ }
+ if (res == 1 && !PyErr_Occurred()) {
+ PyErr_SetString(PyExc_NameError,"Unknown C global variable");
+ }
+ return res;
+ }
+
+ SWIGINTERN PyTypeObject*
+ swig_varlink_type(void) {
+ static char varlink__doc__[] = "Swig var link object";
+ static PyTypeObject varlink_type;
+ static int type_init = 0;
+ if (!type_init) {
+ const PyTypeObject tmp
+ = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* Number of items in variable part (ob_size) */
+ (char *)"swigvarlink", /* Type name (tp_name) */
+ sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */
+ 0, /* Itemsize (tp_itemsize) */
+ (destructor) swig_varlink_dealloc, /* Deallocator (tp_dealloc) */
+ (printfunc) swig_varlink_print, /* Print (tp_print) */
+ (getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */
+ (setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */
+ 0, /* tp_compare */
+ (reprfunc) swig_varlink_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ (reprfunc)swig_varlink_str, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ 0, /* tp_flags */
+ varlink__doc__, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+#if PY_VERSION_HEX >= 0x02020000
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */
+#endif
+#if PY_VERSION_HEX >= 0x02030000
+ 0, /* tp_del */
+#endif
+#ifdef COUNT_ALLOCS
+ 0,0,0,0 /* tp_alloc -> tp_next */
+#endif
+ };
+ varlink_type = tmp;
+ varlink_type.ob_type = &PyType_Type;
+ type_init = 1;
+ }
+ return &varlink_type;
+ }
+
+ /* Create a variable linking object for use later */
+ SWIGINTERN PyObject *
+ SWIG_Python_newvarlink(void) {
+ swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type());
+ if (result) {
+ result->vars = 0;
+ }
+ return ((PyObject*) result);
+ }
+
+ SWIGINTERN void
+ SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) {
+ swig_varlinkobject *v = (swig_varlinkobject *) p;
+ swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar));
+ if (gv) {
+ size_t size = strlen(name)+1;
+ gv->name = (char *)malloc(size);
+ if (gv->name) {
+ strncpy(gv->name,name,size);
+ gv->get_attr = get_attr;
+ gv->set_attr = set_attr;
+ gv->next = v->vars;
+ }
+ }
+ v->vars = gv;
+ }
+
+ SWIGINTERN PyObject *
+ SWIG_globals() {
+ static PyObject *_SWIG_globals = 0;
+ if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink();
+ return _SWIG_globals;
+ }
+
+ /* -----------------------------------------------------------------------------
+ * constants/methods manipulation
+ * ----------------------------------------------------------------------------- */
+
+ /* Install Constants */
+ SWIGINTERN void
+ SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) {
+ PyObject *obj = 0;
+ size_t i;
+ for (i = 0; constants[i].type; ++i) {
+ switch(constants[i].type) {
+ case SWIG_PY_POINTER:
+ obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
+ break;
+ case SWIG_PY_BINARY:
+ obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype));
+ break;
+ default:
+ obj = 0;
+ break;
+ }
+ if (obj) {
+ PyDict_SetItemString(d, constants[i].name, obj);
+ Py_DECREF(obj);
+ }
+ }
+ }
+
+ /* -----------------------------------------------------------------------------*/
+ /* Fix SwigMethods to carry the callback ptrs when needed */
+ /* -----------------------------------------------------------------------------*/
+
+ SWIGINTERN void
+ SWIG_Python_FixMethods(PyMethodDef *methods,
+ swig_const_info *const_table,
+ swig_type_info **types,
+ swig_type_info **types_initial) {
+ size_t i;
+ for (i = 0; methods[i].ml_name; ++i) {
+ char *c = methods[i].ml_doc;
+ if (c && (c = strstr(c, "swig_ptr: "))) {
+ int j;
+ swig_const_info *ci = 0;
+ char *name = c + 10;
+ for (j = 0; const_table[j].type; ++j) {
+ if (strncmp(const_table[j].name, name,
+ strlen(const_table[j].name)) == 0) {
+ ci = &(const_table[j]);
+ break;
+ }
+ }
+ if (ci) {
+ size_t shift = (ci->ptype) - types;
+ swig_type_info *ty = types_initial[shift];
+ size_t ldoc = (c - methods[i].ml_doc);
+ size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
+ char *ndoc = (char*)malloc(ldoc + lptr + 10);
+ if (ndoc) {
+ char *buff = ndoc;
+ void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
+ if (ptr) {
+ strncpy(buff, methods[i].ml_doc, ldoc);
+ buff += ldoc;
+ strncpy(buff, "swig_ptr: ", 10);
+ buff += 10;
+ SWIG_PackVoidPtr(buff, ptr, ty->name, lptr);
+ methods[i].ml_doc = ndoc;
+ }
+ }
+ }
+ }
+ }
+ }
+
+#ifdef __cplusplus
+}
+#endif
+
+/* -----------------------------------------------------------------------------*
+ * Partial Init method
+ * -----------------------------------------------------------------------------*/
+
+#ifdef __cplusplus
+extern "C"
+#endif
+SWIGEXPORT void SWIG_init(void) {
+ PyObject *m, *d;
+
+ /* Fix SwigMethods to carry the callback ptrs when needed */
+ SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial);
+
+ m = Py_InitModule((char *) SWIG_name, SwigMethods);
+ d = PyModule_GetDict(m);
+
+ SWIG_InitializeModule(0);
+ SWIG_InstallConstants(d,swig_const_table);
+
+
}
# must be specified, otherwise its search order is last instead of first.
push( @includes, qw(
-
+# normal platform includes
%T/platforms/eyesIFX
%T/platforms/eyesIFX/chips/tda5250
%T/platforms/eyesIFX/chips/ad5200
+ %T/platforms/eyesIFX/chips/msp430
%T/platforms/eyesIFX/sensors
%T/platforms/eyesIFX/byte_radio
%T/chips/tda5250
}
}
implementation {
+ components ActiveMessageFilterC as Filter;
components Tda5250ActiveMessageC as AM;
+ AMSend = Filter;
+ Receive = Filter.Receive;
+ Snoop = Filter.Snoop;
+
+ Filter.SubAMSend -> AM;
+ Filter.SubReceive -> AM.Receive;
+ Filter.SubSnoop -> AM.Snoop;
+ //Filter.AMPacket -> AM;
+
SplitControl = AM;
- AMSend = AM;
- Receive = AM.Receive;
- Snoop = AM.Snoop;
Packet = AM;
AMPacket = AM;
configuration PlatformSerialC {
- provides interface Init;
provides interface StdControl;
- provides interface SerialByteComm;
+ provides interface UartStream;
}
implementation {
- components new Uart1C() as UartC, eyesIFXSerialP;
+ components new Msp430Uart1C() as UartC, eyesIFXSerialP;
- Init = UartC;
- StdControl = UartC;
- SerialByteComm = UartC;
+ UartStream = UartC;
StdControl = eyesIFXSerialP;
+ eyesIFXSerialP.Msp430UartConfigure <- UartC.Msp430UartConfigure;
eyesIFXSerialP.Resource -> UartC.Resource;
}
components
//Change components below as desired
Tda5250RadioC as Radio, //The actual Tda5250 radio over which data is receives/transmitted
- UartPhyC as UartPhy, //The UartPhy turns Bits into Bytes
+ Uart4b6bPhyC as UartPhy, //The UartPhy turns Bits into Bytes
PacketSerializerP as PacketSerializer, //The PacketSerializer turns Bytes into Packets
CsmaMacC as Mac, //The MAC protocol to use
- //SyncSampleMacC as Mac,
LinkLayerC as Llc; //The Link Layer Control module to use
//Don't change wirings below this point, just change which components
Send = Llc.Send;
Receive = Llc.Receive;
PacketAcknowledgements = Llc;
- Packet = PacketSerializer;
+ Packet = Mac;
Llc.SendDown->Mac.MacSend;
Llc.ReceiveLower->Mac.MacReceive;
- Llc.Packet->PacketSerializer.Packet;
+ Llc.Packet->Mac.Packet;
+ Mac.SubPacket->PacketSerializer.Packet;
Mac.PacketSend->PacketSerializer.PhySend;
Mac.PacketReceive->PacketSerializer.PhyReceive;
Mac.Tda5250Control->Radio;
Mac.UartPhyControl -> UartPhy;
-
+
+ Mac.RadioTimeStamping -> PacketSerializer.RadioTimeStamping;
PacketSerializer.RadioByteComm -> UartPhy.SerializerRadioByteComm;
PacketSerializer.PhyPacketTx -> UartPhy.PhyPacketTx;
PacketSerializer.PhyPacketRx -> UartPhy.PhyPacketRx;
* Configuration for the fixed Rssi Threshold module.
*
* @author: Kevin Klues (klues@tkn.tu-berlin.de)
+ * @author: Andreas Koepke (koepke@tkn.tu-berlin.de)
*/
configuration RssiFixedThresholdCMC
{
interface ChannelMonitorControl;
interface ChannelMonitorData;
interface BatteryLevel;
+ interface Resource as RssiAdcResource;
}
}
implementation
{
components RssiFixedThresholdCMP,
- new RssiSensorVccC() as Rssi,
+ // RssiSensorVccC as Rssi, FIXME: has no arbitration!?
+ new RssiSensorC() as Rssi,
new BatteryLevelSensorC() as Voltage,
- // PlatformLedsC,
new TimerMilliC() as Timer,
MainC;
MainC.SoftwareInit -> RssiFixedThresholdCMP;
StdControl = RssiFixedThresholdCMP;
-
+ RssiAdcResource = Rssi;
+
RssiFixedThresholdCMP.Rssi -> Rssi;
- // RssiFixedThresholdCMP.RssiAdcResource -> Rssi;
-
RssiFixedThresholdCMP.Voltage -> Voltage;
ChannelMonitor = RssiFixedThresholdCMP;
ChannelMonitorControl = RssiFixedThresholdCMP;
ChannelMonitorData = RssiFixedThresholdCMP;
BatteryLevel = RssiFixedThresholdCMP;
- // RssiFixedThresholdCMP.Led3 -> PlatformLedsC.Led3;
+
+/* components PlatformLedsC;
+ RssiFixedThresholdCMP.Led3 -> PlatformLedsC.Led3;
+ RssiFixedThresholdCMP.Led2 -> PlatformLedsC.Led2;
+*/
RssiFixedThresholdCMP.Timer -> Timer;
}
interface ChannelMonitorControl;
interface ChannelMonitorData;
interface BatteryLevel;
-
}
- uses {
- // interface ReadNow<uint16_t> as Rssi;
- interface Read<uint16_t> as Rssi;
+ uses {
+ interface ReadNow<uint16_t> as Rssi;
interface Read<uint16_t> as Voltage;
interface Timer<TMilli> as Timer;
// interface Resource as RssiAdcResource;
// interface GeneralIO as Led3;
+ // interface GeneralIO as Led2;
}
}
implementation
{
//#define CM_DEBUG // debug...
- /* Measure internal voltage every 5s */
-#define VOLTAGE_SAMPLE_INTERVALL 5000
+ /* Measure internal voltage every 20s */
+#define VOLTAGE_SAMPLE_INTERVALL 20000
/*
* Number of samples for noisefloor estimation
// mu + 3*sigma -> rare event, outlier?
#define THREE_SIGMA 145
- // 93 mV measured against 3V Vcc
-#define INITIAL_BUSY_DELTA 127
+ // 92 mV measured against 3V Vcc
+#define INITIAL_BUSY_DELTA 120
// 3000/2 mV measured against 2.5V Ref
#define INITIAL_BATTERY_LEVEL 2457
/**************** Tasks *******************/
task void UpdateNoiseFloorTask();
- task void GetChannelStateTask();
+ // task void GetChannelStateTask();
task void SnrReadyTask();
task void CalibrateNoiseFloorTask();
- task void GetSnrTask();
+ // task void GetSnrTask();
task void CalibrateTask();
task void GetVoltageTask();
- error_t ccaCheckValue();
/***************** Helper function *************/
#ifdef CM_DEBUG
};
#endif
- int16_t computeSNR() {
+ int16_t computeSNR(uint16_t r) {
uint32_t delta;
uint16_t snr;
- uint16_t r;
- atomic r = rssi;
if(r > noisefloor) {
delta = r - noisefloor;
// speedily cacluate
}
/**************** RSSI *******************/
- void rssiRead() {
- if(call Rssi.read() != SUCCESS) signalFailure();
+
+ inline void addSample(uint16_t data) {
+ if(rssiindex < NSAMPLES) rssisamples[rssiindex++] = data;
+ deadlockCounter = 0;
+ if(rssiindex >= NSAMPLES) post UpdateNoiseFloorTask();
+ }
+
+ error_t rssiRead() {
+ error_t res = call Rssi.read();
+ if(res != SUCCESS) signalFailure();
+ return res;
}
- event void Rssi.readDone(error_t result, uint16_t data) {
- if(result == SUCCESS) {
- // call Led3.clr();
- // call RssiAdcResource.release();
- rssi = data;
- atomic {
- switch(state) {
- case CCA:
- ccaCheckValue();
- break;
- case SNR:
- post SnrReadyTask();
- break;
- case CALIBRATE:
- post CalibrateNoiseFloorTask();
- break;
- default:
- break;
+ async event void Rssi.readDone(error_t result, uint16_t data) {
+ switch(state) {
+ case CCA:
+ state = IDLE;
+ if(data < noisefloor + busyDelta) {
+ signal ChannelMonitor.channelIdle();
+ addSample(data);
}
- }
- } else {
- rssiRead();
+ else {
+ signal ChannelMonitor.channelBusy();
+ if(++deadlockCounter >= DEADLOCK) addSample(data);
+ }
+ break;
+ case SNR:
+ rssi = data;
+ post SnrReadyTask();
+ break;
+ case CALIBRATE:
+ rssi = data;
+ post CalibrateNoiseFloorTask();
+ break;
+ default:
+ break;
}
}
uint16_t nbD;
uint16_t bD;
if(result == SUCCESS) {
- nbl = data;
+ nbl = (data + batteryLevel)>>1;
atomic bD = busyDelta;
d = batteryLevel - nbl;
if(d > 75 || d < -75) {
/**************** ChannelMonitor *******************/
async command error_t ChannelMonitor.start() {
- error_t res = SUCCESS;
+ error_t res = FAIL;
atomic {
- if(state != VOID) {
- if(state == IDLE) {
- state = CCA;
- res = SUCCESS;
- }
- post GetChannelStateTask();
+ if(state == IDLE) {
+ res = rssiRead();
+ if(res == SUCCESS) state = CCA;
+ }
+ else if(state == CCA) {
+ res = SUCCESS;
}
}
return res;
}
}
- task void GetChannelStateTask() {
+/* task void GetChannelStateTask() {
atomic {
if((state != IDLE) && (state != CCA)) {
post GetChannelStateTask();
}
}
}
-
- void addSample() {
- if(rssiindex < NSAMPLES) rssisamples[rssiindex++] = rssi;
- deadlockCounter = 0;
- if(rssiindex >= NSAMPLES) post UpdateNoiseFloorTask();
- }
-
-
- void channelBusy () {
- atomic {
- if(++deadlockCounter >= DEADLOCK) addSample();
- state = IDLE;
- }
- signal ChannelMonitor.channelBusy();
- }
-
- void channelIdle() {
- atomic {
- addSample();
- state = IDLE;
- }
- signal ChannelMonitor.channelIdle();
- }
-
- error_t ccaCheckValue() {
- uint16_t data;
- atomic data = rssi;
- if(data < noisefloor + busyDelta) {
- channelIdle();
- } else {
- channelBusy();
- }
- return SUCCESS;
- }
-
+*/
task void UpdateNoiseFloorTask() {
shellsort(rssisamples,NSAMPLES);
atomic {
if(s != CALIBRATE) {
readVoltage();
} else {
- rssiRead();
- // call RssiAdcResource.request();
+ rssiRead();
+ // call RssiAdcResource.request();
}
}
}
/** get SNR in dB **/
-
- async command error_t ChannelMonitorData.getSnr() {
- error_t res = SUCCESS;
- if(state != VOID) {
- post GetSnrTask();
- } else {
- res = FAIL;
+ /* task void GetSnrTask() {
+ state_t s;
+ atomic s = state;
+ if(s == SNR) {
+ if(call RssiAdcResource.immediateRequest() == SUCCESS) {
+ rssiRead();
+ } else {
+ atomic if(state == SNR) state = IDLE;
+ }
}
- return res;
- }
-
- task void GetSnrTask() {
+ }
+ */
+
+ async command error_t ChannelMonitorData.getSnr() {
+ error_t res = FAIL;
atomic {
- if(state != IDLE) {
- post GetSnrTask();
- } else {
- state = SNR;
- rssiRead();
- // if(call RssiAdcResource.request() != SUCCESS) signalFailure();
+ if(state == IDLE) {
+ res = rssiRead();
+ if(res == SUCCESS) state = SNR;
+ }
+ else if(state == SNR) {
+ res = SUCCESS;
}
}
+ return res;
}
-
+
task void SnrReadyTask() {
int16_t snr;
- snr = computeSNR();
- atomic state = IDLE;
- signal ChannelMonitorData.getSnrDone(snr);
+ state_t s;
+ uint16_t r;
+ atomic {
+ r = rssi;
+ s = state;
+ if(state == SNR) state = IDLE;
+ }
+ if(s == SNR) {
+ snr = computeSNR(r);
+ signal ChannelMonitorData.getSnrDone(snr);
+ }
}
+ async command uint16_t ChannelMonitorData.readSnr() {
+ uint16_t rval;
+ if(rssi > noisefloor) {
+ rval = (rssi-noisefloor)>>4;
+ } else {
+ rval = 3;
+ }
+ return rval;
+ }
+
default async event void ChannelMonitorData.getSnrDone(int16_t snr) {
}
atomic l = batteryLevel;
return (uint32_t)l*39>>5;
}
-
}
*/
configuration Tda5250RadioIOC
{
+ provides interface GeneralIO as Tda5250RadioPASKNFSK;
provides interface GeneralIO as Tda5250RadioBUSM;
provides interface GeneralIO as Tda5250RadioENTDA;
provides interface GeneralIO as Tda5250RadioTXRX;
implementation {
components
HplMsp430GeneralIOC as MspGeneralIO
+ , Tda5250ASKNFSKFakePinP
, new Msp430GpioC() as rBUSM
, new Msp430GpioC() as rENTDA
, new Msp430GpioC() as rTXRX
Tda5250RadioDATA = rDATA;
Tda5250RadioPWDDD = rPWDD;
+ Tda5250RadioPASKNFSK = Tda5250ASKNFSKFakePinP;
rBUSM -> MspGeneralIO.Port15;
rENTDA -> MspGeneralIO.Port16;
rTXRX -> MspGeneralIO.Port14;
* ========================================================================
*/
-#include "tda5250BusResourceId.h"
+#include "tda5250BusResourceSettings.h"
/**
* Configuration file for the registers of TDA5250 Radio on
#define TDA5250REGDEFAULTSETTINGS_H
// Default values of data registers
-#define TDA5250_REG_DEFAULT_SETTING_CONFIG 0x94F9
+
+#define TDA5250_REG_DEFAULT_SETTING_CONFIG 0x84F9
#define TDA5250_REG_DEFAULT_SETTING_FSK 0x0A0C
#define TDA5250_REG_DEFAULT_SETTING_XTAL_TUNING 0x0012
#define TDA5250_REG_DEFAULT_SETTING_LPF 0x6A
module eyesIFXSerialP {
provides interface StdControl;
+ provides interface Msp430UartConfigure;
uses interface Resource;
}
implementation {
- command error_t StdControl.start(){
- return call Resource.immediateRequest();
- }
- command error_t StdControl.stop(){
- call Resource.release();
- return SUCCESS;
- }
- event void Resource.granted(){}
+ //msp430_uart_config_t msp430_uart_eyes_config = {ubr: UBR_1MHZ_115200, umctl: UMCTL_1MHZ_115200, ssel: 0x02, pena: 0, pev: 0, spb: 0, clen: 1, listen: 0, mm: 0, ckpl: 0, urxse: 0, urxeie: 1, urxwie: 0};
+
+ // when the tda5250 is in receive mode we get problems with 115200 baud
+ // on the serial line ...
+ msp430_uart_config_t msp430_uart_eyes_config = {ubr: UBR_1MHZ_57600, umctl: UMCTL_1MHZ_57600, ssel: 0x02, pena: 0, pev: 0, spb: 0, clen: 1, listen: 0, mm: 0, ckpl: 0, urxse: 0, urxeie: 1, urxwie: 0};
+
+ command error_t StdControl.start(){
+ return call Resource.immediateRequest();
+ }
+ command error_t StdControl.stop(){
+ call Resource.release();
+ return SUCCESS;
+ }
+ event void Resource.granted(){}
+
+ async command msp430_uart_config_t* Msp430UartConfigure.getConfig() {
+ return &msp430_uart_eyes_config;
+ }
}
push( @includes, qw(
%T/platforms/eyesIFX/eyesIFXv1
- %T/platforms/eyesIFX/chips/stm25p
+ %T/platforms/eyesIFX/eyesIFXv1/chips/stm25p
%T/chips/stm25p
) );
push( @includes, qw(
%T/platforms/eyesIFX/eyesIFXv2
- %T/platforms/eyesIFX/chips/at45db
+ %T/platforms/eyesIFX/eyesIFXv2/chips/at45db
%T/chips/at45db
) );
TOSH_ASSIGN_PIN(DEBUG_1, 1, 1);
TOSH_ASSIGN_PIN(DEBUG_2, 1, 2);
-TOSH_ASSIGN_PIN(DEBUG_3, 1, 3);
+
+// Temperature sensor enable
+TOSH_ASSIGN_PIN(TEMP_EN, 5, 4);
+
+// USB power monitoring
+TOSH_ASSIGN_PIN(USB_POWER, 1, 3);
inline void uwait(uint16_t u)
{
TOSH_MAKE_POT_EN_OUTPUT();
+ //disable temperature sensor
+ TOSH_CLR_TEMP_EN_PIN();
+ TOSH_MAKE_TEMP_EN_OUTPUT();
+
+ // detect USB power
+ TOSH_SEL_USB_POWER_MODFUNC();
+ TOSH_MAKE_USB_POWER_INPUT();
+
+
// wait 12ms for the radio to start
uwait(1024*12);
components new AdcReadClientC() as AdcReadClient;
Read = AdcReadClient;
- AdcReadClient.Msp430Adc12Config -> Settings.Msp430Adc12Config[INTERNAL_VOLTAGE_REF_2_5V];
+ AdcReadClient.AdcConfigure -> Settings.AdcConfigure[INTERNAL_VOLTAGE_REF_2_5V];
components new AdcReadNowClientC() as AdcReadNowClient;
ReadNow = AdcReadNowClient;
ReadNowResource = AdcReadNowClient;
- AdcReadNowClient.Msp430Adc12Config -> Settings.Msp430Adc12Config[INTERNAL_VOLTAGE_REF_2_5V];
+ AdcReadNowClient.AdcConfigure -> Settings.AdcConfigure[INTERNAL_VOLTAGE_REF_2_5V];
}
{
components SensorSettingsC as Settings;
components new AdcReadClientC() as AdcReadClient;
- components new ReadShiftC(4) as ReadShift;
- Read = ReadShift;
- ReadShift.ReadRaw -> AdcReadClient;
- AdcReadClient.Msp430Adc12Config -> Settings.Msp430Adc12Config[PHOTO_SENSOR_DEFAULT];
+ Read = AdcReadClient;
+ AdcReadClient.AdcConfigure -> Settings.AdcConfigure[PHOTO_SENSOR_DEFAULT];
}
{
components SensorSettingsC as Settings;
components new AdcReadNowClientC() as AdcReadNowClient;
- components new ReadNowShiftC(4) as ReadNowShift;
- ReadNow = ReadNowShift;
- ReadNowShift.ReadNowRaw -> AdcReadNowClient;
Resource = AdcReadNowClient;
- AdcReadNowClient.Msp430Adc12Config -> Settings.Msp430Adc12Config[PHOTO_SENSOR_DEFAULT];
+ ReadNow = AdcReadNowClient;
+ AdcReadNowClient.AdcConfigure -> Settings.AdcConfigure[PHOTO_SENSOR_DEFAULT];
}
{
components SensorSettingsC as Settings;
components new AdcReadStreamClientC() as AdcReadStreamClient;
- components new ReadStreamShiftC(4) as ReadStreamShift;
- ReadStream = ReadStreamShift;
- ReadStreamShift.ReadStreamRaw -> AdcReadStreamClient;
- AdcReadStreamClient.Msp430Adc12Config -> Settings.Msp430Adc12Config[PHOTO_SENSOR_DEFAULT];
+ ReadStream = AdcReadStreamClient;
+ AdcReadStreamClient.AdcConfigure -> Settings.AdcConfigure[PHOTO_SENSOR_DEFAULT];
}
components new AdcReadClientC() as AdcReadClient;
Read = AdcReadClient;
- AdcReadClient.Msp430Adc12Config -> Settings.Msp430Adc12Config[PHOTO_SENSOR_DEFAULT];
+ AdcReadClient.AdcConfigure -> Settings.AdcConfigure[PHOTO_SENSOR_DEFAULT];
components new AdcReadNowClientC() as AdcReadNowClient;
ReadNow = AdcReadNowClient;
ReadNowResource = AdcReadNowClient;
- AdcReadNowClient.Msp430Adc12Config -> Settings.Msp430Adc12Config[PHOTO_SENSOR_DEFAULT];
+ AdcReadNowClient.AdcConfigure -> Settings.AdcConfigure[PHOTO_SENSOR_DEFAULT];
}
components new AdcReadClientC() as AdcReadClient;
Read = AdcReadClient;
- AdcReadClient.Msp430Adc12Config -> Settings.Msp430Adc12Config[RSSI_SENSOR_REF_1_5V];
+ AdcReadClient.AdcConfigure -> Settings.AdcConfigure[RSSI_SENSOR_REF_1_5V];
components new AdcReadNowClientC() as AdcReadNowClient;
ReadNow = AdcReadNowClient;
ReadNowResource = AdcReadNowClient;
- AdcReadNowClient.Msp430Adc12Config -> Settings.Msp430Adc12Config[RSSI_SENSOR_REF_1_5V];
+ AdcReadNowClient.AdcConfigure -> Settings.AdcConfigure[RSSI_SENSOR_REF_1_5V];
}
generic configuration RssiSensorVccC()
{
provides {
- interface Read<uint16_t> as Read;
interface ReadNow<uint16_t> as ReadNow;
interface Resource as ReadNowResource;
}
implementation
{
components SensorSettingsC as Settings;
-
- components new AdcReadClientC() as AdcReadClient;
- Read = AdcReadClient;
- AdcReadClient.Msp430Adc12Config -> Settings.Msp430Adc12Config[RSSI_SENSOR_VCC];
-
- components new AdcReadNowClientC() as AdcReadNowClient;
- ReadNow = AdcReadNowClient;
- ReadNowResource = AdcReadNowClient;
- AdcReadNowClient.Msp430Adc12Config -> Settings.Msp430Adc12Config[RSSI_SENSOR_VCC];
+ components RssiSensorVccP as RssiSensor;
+ components new Msp430Adc12ClientC() as AdcClient;
+
+ ReadNow = RssiSensor;
+ ReadNowResource = RssiSensor;
+ RssiSensor.SubResource -> AdcClient;
+ RssiSensor.SingleChannel -> AdcClient;
}
#include <sensors.h>
module SensorSettingsC {
- provides interface Msp430Adc12Config[uint8_t type];
+ provides interface AdcConfigure<const msp430adc12_channel_config_t*> as AdcConfigure[uint8_t type];
}
implementation
{
- async command msp430adc12_channel_config_t Msp430Adc12Config.getChannelSettings[uint8_t type]() {
- msp430adc12_channel_config_t config;
- if(type < SENSOR_SENTINEL) {
- config = sensorconfigurations[type];
- } else {
- config = sensorconfigurations[SENSOR_SENTINEL];
- }
- return config;
- }
+ async command const msp430adc12_channel_config_t* AdcConfigure.getConfiguration[uint8_t type]() {
+ if (type < SENSOR_SENTINEL)
+ return &sensorconfigurations[type];
+ else
+ return &sensorconfigurations[SENSOR_SENTINEL];
+ }
}
components new AdcReadClientC() as AdcReadClient;
Read = AdcReadClient;
- AdcReadClient.Msp430Adc12Config -> Settings.Msp430Adc12Config[TEMP_SENSOR_DEFAULT];
+ AdcReadClient.AdcConfigure -> Settings.AdcConfigure[TEMP_SENSOR_DEFAULT];
components new AdcReadNowClientC() as AdcReadNowClient;
ReadNow = AdcReadNowClient;
ReadNowResource = AdcReadNowClient;
- AdcReadNowClient.Msp430Adc12Config -> Settings.Msp430Adc12Config[TEMP_SENSOR_DEFAULT];
+ AdcReadNowClient.AdcConfigure -> Settings.AdcConfigure[TEMP_SENSOR_DEFAULT];
}
%T/platforms/intelmote2
%T/platforms/intelmote2/chips/cc2420
%T/platforms/intelmote2/chips/da9030
- %T/platforms/intelmote2/chips/pxa271
+ %T/platforms/intelmote2/chips/ds2745
%T/chips/cc2420
%T/chips/pxa27x
%T/chips/pxa27x/lib
%T/chips/pxa27x/ssp
%T/chips/pxa27x/i2c
%T/chips/pxa27x/uart
+ %T/chips/pxa27x/p30
+ %T/chips/pxa27x/ds2745
%T/lib/timer
%T/lib/serial
%T/lib/gpio
*/
configuration PlatformSerialC {
- provides interface Init;
provides interface StdControl;
- provides interface SerialByteComm;
+ provides interface UartByte;
+ provides interface UartStream;
}
implementation {
components HplPXA27xSTUARTC;
components HplPXA27xGPIOC;
components IM2InitSerialP;
-
- Init = HalPXA27xSerialP;
- Init = IM2InitSerialP;
- StdControl = HalPXA27xSerialP;
- SerialByteComm = HalPXA27xSerialP;
+ StdControl = HalPXA27xSerialP;
+ UartByte = HalPXA27xSerialP;
+ UartStream = HalPXA27xSerialP;
+
HalPXA27xSerialP.UARTInit -> HplPXA27xSTUARTC.Init;
HalPXA27xSerialP.UART -> HplPXA27xSTUARTC.STUART;
IM2InitSerialP.TXD -> HplPXA27xGPIOC.HplPXA27xGPIOPin[STUART_TXD];
IM2InitSerialP.RXD -> HplPXA27xGPIOC.HplPXA27xGPIOPin[STUART_RXD];
+
+ components PlatformP;
+ IM2InitSerialP.Init <- PlatformP.InitL2;
+ HalPXA27xSerialP.Init <- PlatformP.InitL3;
+
+ components new HplPXA27xDMAInfoC(19, (uint32_t) &STRBR) as DMAInfoRx;
+ components new HplPXA27xDMAInfoC(20, (uint32_t) &STTHR) as DMAInfoTx;
+ components HplPXA27xDMAC;
+ // how are these channels picked?
+ HalPXA27xSerialP.TxDMA -> HplPXA27xDMAC.HplPXA27xDMAChnl[2];
+ HalPXA27xSerialP.RxDMA -> HplPXA27xDMAC.HplPXA27xDMAChnl[3];
+ DMAInfoRx.HplPXA27xDMAInfo <- HalPXA27xSerialP.UARTRxDMAInfo;
+ DMAInfoTx.HplPXA27xDMAInfo <- HalPXA27xSerialP.UARTTxDMAInfo;
}
implementation \r
{\r
\r
- components new FcfsArbiterC("CC2420SpiClient");\r
- components new HalPXA27xSpiDMAM(0,1,0x7,FALSE) as HalPXA27xSpiM; // 6.5 Mbps, 8bit width\r
- //components new HalPXA27xSpiPioM(0,1,0x7,FALSE) as HalPXA27xSpiM; // SPI, 6.5 Mbps, 8bit width, noRWOT\r
+ components new SimpleFcfsArbiterC("CC2420SpiClient") as FcfsArbiterC;\r
+ components new HalPXA27xSpiDMAC(1,0x7,FALSE) as HalPXA27xSpiM; // 6.5 Mbps, 8bit width\r
+ //components new HalPXA27xSpiPioC(1,0x7,FALSE) as HalPXA27xSpiM; // 6.5 Mbps, 8bit width\r
components IM2CC2420InitSpiP;\r
components HplPXA27xSSP3C;\r
components HplPXA27xDMAC;\r
components PlatformP;\r
\r
Init = IM2CC2420InitSpiP;\r
- Init = FcfsArbiterC.Init;\r
Init = HalPXA27xSpiM.Init;\r
\r
SpiByte = HalPXA27xSpiM;\r
readPMIC(PMIC_EVENTS, val, 3);\r
\r
// Set default core voltage to 0.85 V\r
+#ifdef PXA27X_13M\r
call PMIC.setCoreVoltage(B2R1_TRIM_P85_V);\r
-\r
+#endif\r
startLDOs();\r
return SUCCESS;\r
}\r
* Table is indexed by the Peripheral ID (PPID). Priorities are 0 - 39
* where 0 is the highest. Priorities MUST be unique. 0XFF = invalid/unassigned
*/
-const uint8_t TOSH_IRP_TABLE[] = { 0xFF, // PPID 0 SSP_3 Service Req
+const uint8_t TOSH_IRP_TABLE[] = { 0x05, // PPID 0 SSP_3 Service Req
0xFF, // PPID 1 MSL
0xFF, // PPID 2 USBH2
0xFF, // PPID 3 USBH1
0xFF, // PPID 21 TX/RX ERROR BTUART
0x06, // PPID 22 TX/RX ERROR FFUART
0xFF, // PPID 23 Flash Card status/Error Detect
- 0x05, // PPID 24 SSP_1 Service Req
+ 0x0A, // PPID 24 SSP_1 Service Req
0x00, // PPID 25 DMA Channel Service Req
0xFF, // PPID 26 OST equals Match Register 0
0xFF, // PPID 27 OST equals Match Register 1
#define I2C_SDA (118)
#define I2C_SDA_ALTFN (1)
+#define DS2745_SLAVE_ADDR (0x48)
#if 0
TOSH_ASSIGN_PIN(CC_VREN,A,CC_VREN_PIN);
implementation
{
components CounterThree16C as Counter16,
- new TransformCounterC(TMicro, uint32_t, TMicro, uint16_t,
+ new TransformCounterC(TMicro, uint32_t, TThree, uint16_t,
MICA_DIVIDE_THREE_FOR_MICRO_LOG2,
counter_three_overflow_t) as Transform32;
-/// $Id$
-
/*
- * Copyright (c) 2004-2005 Crossbow Technology, Inc. All rights reserved.
+ * Copyright (c) 2006 Arch Rock Corporation
+ * All rights reserved.
*
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose, without fee, and without written agreement is
- * hereby granted, provided that the above copyright notice, the following
- * two paragraphs and the author appear in all copies of this software.
- *
- * IN NO EVENT SHALL CROSSBOW TECHNOLOGY OR ANY OF ITS LICENSORS BE LIABLE TO
- * ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
- * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF CROSSBOW OR ITS LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ * - Neither the name of the Arch Rock Corporation nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * CROSSBOW TECHNOLOGY AND ITS LICENSORS SPECIFICALLY DISCLAIM ALL WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND NEITHER CROSSBOW NOR ANY LICENSOR HAS ANY
- * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
- * MODIFICATIONS.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * ARCH ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE
*/
/**
- * A platform's basic UART abstraction. On a mica mote, this is UART0 of
- * the HPL.
- *
- * @author Martin Turon <mturon@xbow.com>
- * @author Philip Levis
- * @date August 7 2005
+ * @author Alec Woo <awoo@archrock.com>
+ * @author Jonathan Hui <jhui@archrock.com>
+ * @version $Revision$ $Date$
*/
configuration PlatformSerialC {
- provides interface Init;
+
provides interface StdControl;
- provides interface SerialByteComm;
+ provides interface UartStream;
+ provides interface UartByte;
+
}
implementation {
- components HplAtm128UartC as UART, PlatformC;
- SerialByteComm = UART.Uart0;
- Init = UART.Uart0Init;
- StdControl = UART.Uart0RxControl;
- StdControl = UART.Uart0TxControl;
+ components Atm128Uart0C as Uart0;
+ StdControl = Uart0;
+ UartStream = Uart0;
+ UartByte = Uart0;
+
+ components CounterMicro32C;
+ Uart0.Counter -> CounterMicro32C;
+
}
%T/chips/at45db
%T/chips/atm128
%T/chips/atm128/adc
+ %T/chips/atm128/i2c
%T/chips/atm128/pins
%T/chips/atm128/spi
%T/chips/atm128/timer
return EBUSY;
}
- async command void Resource.release() {
- call Resource1.release();
- call Resource2.release();
+ async command error_t Resource.release() {
+ if(call Resource1.release() == SUCCESS)
+ return call Resource2.release();
+ return FAIL;
}
async command uint8_t Resource.isOwner() {
"\tori %0,1<<" #n "\n" \
: "=d" (spiIn) : "0" (spiIn), "r" (spiOut))
- async command void FlashSpi.write(uint8_t spiOut, uint8_t *pspiIn) {
+ async command uint8_t FlashSpi.write(uint8_t spiOut) {
uint8_t spiIn = 0;
// This atomic ensures integrity at the hardware level...
BIT(0);
}
- *pspiIn = spiIn;
+ return spiIn;
}
task void avail() {
"\tori %0,1<<" #n "\n" \
: "=d" (spiIn) : "0" (spiIn), "r" (spiOut))
- async command void FlashSpi.write(uint8_t spiOut, uint8_t *pspiIn) {
+ async command uint8_t FlashSpi.write(uint8_t spiOut) {
uint8_t spiIn = 0;
// This atomic ensures integrity at the hardware level...
BIT(0);
}
- *pspiIn = spiIn;
+ return spiIn;
}
task void idleWait() {
}
implementation
{
- components new ConstantSensorC(uint16_t, 0xbeef) as DemoChannel;
+ components new SineSensorC() as DemoChannel;
Read = DemoChannel;
}
return SUCCESS;
}
- async command void Resource.release() {
+ async command error_t Resource.release() {
+ return SUCCESS;
}
async command uint8_t Resource.isOwner() {
+
+#ifndef HARDWARE_H
+#define HARDWARE_H
inline void __nesc_enable_interrupt() { }
inline void __nesc_disable_interrupt() { }
inline void __nesc_atomic_end(__nesc_atomic_t x) @spontaneous() { }
inline void __nesc_atomic_sleep() { }
+
+#endif
/**
* MSP430Timer32khzMapC presents as paramaterized interfaces all of
* the 32khz hardware timers on the MSP430 that are available for
- * compile time allocation by "new Alarm32khzC()", "new
- * AlarmMilliC()", and so on.
+ * compile time allocation by "new Alarm32khz16C()", "new
+ * AlarmMilli32C()", and so on.
*
* Platforms based on the MSP430 are * encouraged to copy in and
* override this file, presenting only the * hardware timers that are
+
configuration PlatformSerialC {
- provides interface Init;
+
provides interface StdControl;
- provides interface SerialByteComm;
+ provides interface UartStream;
+
}
-implementation {
- components new Uart1C() as UartC, TelosSerialP;
- Init = UartC;
- StdControl = UartC;
+implementation {
+
+ components new Msp430Uart1C() as UartC;
+ UartStream = UartC;
+
+ components TelosSerialP;
StdControl = TelosSerialP;
- SerialByteComm = UartC;
+ TelosSerialP.Msp430UartConfigure <- UartC.Msp430UartConfigure;
TelosSerialP.Resource -> UartC.Resource;
+
}
module TelosSerialP {
provides interface StdControl;
+ provides interface Msp430UartConfigure;
uses interface Resource;
}
implementation {
+
+ msp430_uart_config_t msp430_uart_telos_config = {ubr: UBR_1MHZ_115200, umctl: UMCTL_1MHZ_115200, ssel: 0x02, pena: 0, pev: 0, spb: 0, clen: 1, listen: 0, mm: 0, ckpl: 0, urxse: 0, urxeie: 1, urxwie: 0};
+
command error_t StdControl.start(){
return call Resource.immediateRequest();
}
return SUCCESS;
}
event void Resource.granted(){}
+
+ async command msp430_uart_config_t* Msp430UartConfigure.getConfig() {
+ return &msp430_uart_telos_config;
+ }
+
}
generic configuration HplCC2420AlarmC() {
provides interface Init;
- provides interface Alarm<T32khz,uint16_t> as Alarm32khz16;
provides interface Alarm<T32khz,uint32_t> as Alarm32khz32;
}
implementation {
- components new Alarm32khzC();
+ components new Alarm32khz32C();
- Init = Alarm32khzC;
- Alarm32khz16 = Alarm32khzC.Alarm32khz16;
- Alarm32khz32 = Alarm32khzC.Alarm32khz32;
+ Init = Alarm32khz32C;
+ Alarm32khz32 = Alarm32khz32C;
}
implementation {
- components Counter32khzC;
components HplMsp430GeneralIOC as GeneralIOC;
components Msp430TimerC;
components new GpioCaptureC() as CaptureSFDC;
ReadStream = AdcReadStreamClientC;
components HamamatsuS1087ParP;
- AdcReadClientC.Msp430Adc12Config -> HamamatsuS1087ParP;
- AdcReadStreamClientC.Msp430Adc12Config -> HamamatsuS1087ParP;
+ AdcReadClientC.AdcConfigure -> HamamatsuS1087ParP;
+ AdcReadStreamClientC.AdcConfigure -> HamamatsuS1087ParP;
}
*/
module HamamatsuS1087ParP {
- provides interface Msp430Adc12Config;
+ provides interface AdcConfigure<const msp430adc12_channel_config_t*>;
}
implementation {
- async command msp430adc12_channel_config_t Msp430Adc12Config.getChannelSettings() {
- msp430adc12_channel_config_t config = {
- inch: INPUT_CHANNEL_A4,
- sref: REFERENCE_VREFplus_AVss,
- ref2_5v: REFVOLT_LEVEL_1_5,
- adc12ssel: SHT_SOURCE_ACLK,
- adc12div: SHT_CLOCK_DIV_1,
- sht: SAMPLE_HOLD_4_CYCLES,
- sampcon_ssel: SAMPCON_SOURCE_SMCLK,
- sampcon_id: SAMPCON_CLOCK_DIV_1
- };
-
- return config;
+ msp430adc12_channel_config_t config = {
+ inch: INPUT_CHANNEL_A4,
+ sref: REFERENCE_VREFplus_AVss,
+ ref2_5v: REFVOLT_LEVEL_1_5,
+ adc12ssel: SHT_SOURCE_ACLK,
+ adc12div: SHT_CLOCK_DIV_1,
+ sht: SAMPLE_HOLD_4_CYCLES,
+ sampcon_ssel: SAMPCON_SOURCE_SMCLK,
+ sampcon_id: SAMPCON_CLOCK_DIV_1
+ };
+
+ async command const msp430adc12_channel_config_t* AdcConfigure.getConfiguration() {
+ return &config;
}
}
ReadStream = AdcReadStreamClientC;
components HamamatsuS10871TsrP;
- AdcReadClientC.Msp430Adc12Config -> HamamatsuS10871TsrP;
- AdcReadStreamClientC.Msp430Adc12Config -> HamamatsuS10871TsrP;
+ AdcReadClientC.AdcConfigure -> HamamatsuS10871TsrP;
+ AdcReadStreamClientC.AdcConfigure -> HamamatsuS10871TsrP;
}
*/
module HamamatsuS10871TsrP {
- provides interface Msp430Adc12Config;
+ provides interface AdcConfigure<const msp430adc12_channel_config_t*>;
}
implementation {
- async command msp430adc12_channel_config_t Msp430Adc12Config.getChannelSettings() {
- msp430adc12_channel_config_t config = {
- inch: INPUT_CHANNEL_A5,
- sref: REFERENCE_VREFplus_AVss,
- ref2_5v: REFVOLT_LEVEL_1_5,
- adc12ssel: SHT_SOURCE_ACLK,
- adc12div: SHT_CLOCK_DIV_1,
- sht: SAMPLE_HOLD_4_CYCLES,
- sampcon_ssel: SAMPCON_SOURCE_SMCLK,
- sampcon_id: SAMPCON_CLOCK_DIV_1
- };
-
- return config;
+ msp430adc12_channel_config_t config = {
+ inch: INPUT_CHANNEL_A5,
+ sref: REFERENCE_VREFplus_AVss,
+ ref2_5v: REFVOLT_LEVEL_1_5,
+ adc12ssel: SHT_SOURCE_ACLK,
+ adc12div: SHT_CLOCK_DIV_1,
+ sht: SAMPLE_HOLD_4_CYCLES,
+ sampcon_ssel: SAMPCON_SOURCE_SMCLK,
+ sampcon_id: SAMPCON_CLOCK_DIV_1
+ };
+
+ async command const msp430adc12_channel_config_t* AdcConfigure.getConfiguration() {
+ return &config;
}
}
components new SensirionSht11LogicP();
SensirionSht11 = SensirionSht11LogicP;
- components MainC;
- MainC.SoftwareInit -> HplSensirionSht11C;
-
components HplSensirionSht11C;
Resource = HplSensirionSht11C.Resource;
SensirionSht11LogicP.DATA -> HplSensirionSht11C.DATA;
*/
configuration HplSensirionSht11C {
- provides interface Init;
provides interface Resource[ uint8_t id ];
provides interface GeneralIO as DATA;
provides interface GeneralIO as SCK;
InterruptDATA = InterruptDATAC.Interrupt;
components new FcfsArbiterC( "Sht11.Resource" ) as Arbiter;
- Init = Arbiter;
Resource = Arbiter;
components new SplitControlPowerManagerC();
- Init = SplitControlPowerManagerC;
SplitControlPowerManagerC.SplitControl -> HplSensirionSht11P;
SplitControlPowerManagerC.ArbiterInit -> Arbiter.Init;
SplitControlPowerManagerC.ArbiterInfo -> Arbiter.ArbiterInfo;
%T/platforms/tinynode/chips/xe1205
%T/platforms/tinynode/chips/mm74hc595
+ %T/platforms/tinynode/chips/at45db
%T/chips/xe1205/conf
%T/chips/xe1205/phy
%T/chips/xe1205/mac
%T/chips/xe1205
- %T/../beta/tos/chips/mm74hc595
+ %T/chips/mm74hc595
%T/chips/msp430
%T/chips/msp430/adc12
%T/chips/msp430/timer
%T/chips/msp430/usart
%T/chips/msp430/sensors
- %T/chips/stm25p
+ %T/chips/at45db
%T/lib/timer
%T/lib/serial
%T/lib/adc
configuration PlatformSerialC {
- provides interface Init;
provides interface StdControl;
- provides interface SerialByteComm;
+ provides interface UartStream;
}
+
implementation {
- components new Uart1C() as UartC, TinyNodeSerialP;
+ components new Msp430Uart1C() as UartC;
+ UartStream = UartC;
- Init = UartC;
- StdControl = UartC;
+ components TinyNodeSerialP;
StdControl = TinyNodeSerialP;
- SerialByteComm = UartC;
+ TinyNodeSerialP.Msp430UartConfigure <- UartC.Msp430UartConfigure;
TinyNodeSerialP.Resource -> UartC.Resource;
}
+
module TinyNodeSerialP {
provides interface StdControl;
+ provides interface Msp430UartConfigure;
uses interface Resource;
}
implementation {
+
+ msp430_uart_config_t msp430_uart_tinynode_config = {ubr: UBR_1MHZ_115200, umctl: UMCTL_1MHZ_115200, ssel: 0x02, pena: 0, pev: 0, spb: 0, clen: 1, listen: 0, mm: 0, ckpl: 0, urxse: 0, urxeie: 1, urxwie: 0};
+
+
command error_t StdControl.start(){
return call Resource.immediateRequest();
}
+
command error_t StdControl.stop(){
call Resource.release();
return SUCCESS;
}
+
event void Resource.granted(){}
+
+ async command msp430_uart_config_t* Msp430UartConfigure.getConfig() {
+ return &msp430_uart_tinynode_config;
+ }
+
}
+
components new SensirionSht11LogicP();
SensirionSht11 = SensirionSht11LogicP;
- components MainC;
- MainC.SoftwareInit -> HplSensirionSht11C;
-
components HplSensirionSht11C;
Resource = HplSensirionSht11C.Resource;
SensirionSht11LogicP.DATA -> HplSensirionSht11C.DATA;
#include <im2sb.h>
configuration HplSensirionSht11C {
- provides interface Init;
provides interface Resource[ uint8_t id ];
provides interface GeneralIO as DATA;
provides interface GeneralIO as SCK;
SCK = GeneralIOC.GeneralIO[GPIO_SHT11_CLK];
InterruptDATA = GeneralIOC.GpioInterrupt[GPIO_SHT11_DATA];
- components new FcfsArbiterC( "Sht11.Resource" ) as Arbiter;
- Init = Arbiter;
+ components new SimpleFcfsArbiterC( "Sht11.Resource" ) as Arbiter;
Resource = Arbiter;
}
}
implementation {
- components new FcfsArbiterC( "LIS3L02DQ.Resource" ) as Arbiter;
+ components LIS3L02DQInternalP as InternalP;
+ components new SimpleFcfsArbiterC( "LIS3L02DQ.Resource" ) as Arbiter;
components MainC;
- Resource = Arbiter;
- MainC.SoftwareInit -> Arbiter;
- components HplLIS3L02DQLogicSPIP as Logic;
- MainC.SoftwareInit -> Logic;
+ Resource = Arbiter;
+ HplLIS3L02DQ = InternalP;
+ SplitControl = InternalP;
+ MainC.SoftwareInit -> InternalP;
+ components HplLIS3L02DQLogicSPIP as LogicSPIP;
+ components HalLIS3L02DQControlP as ControlP;
+ components new HalPXA27xSpiPioC(128, 7, FALSE) as HalSpi;
components HplPXA27xSSP1C;
- // 0: Motorola SPI
- // 3: random guess what SSP Clock Rate should be
- // 7: 8 bit data size OR 15: 16 bit data size?
- // FALSE: No "Receive without transmit"
- components new HalPXA27xSpiPioM(0, 128, 7, FALSE) as HalSpi;
- HalSpi.SSP -> HplPXA27xSSP1C;
- MainC.SoftwareInit -> HalSpi;
- Logic.SpiPacket -> HalSpi.SpiPacket[unique("SPIInstance")];
+ components GeneralIOC;
+ components HplPXA27xGPIOC;
- components LIS3L02DQInternalP as Internal;
- HplLIS3L02DQ = Internal;
- Internal.ToHPLC -> Logic.HplLIS3L02DQ;
-
- SplitControl = Logic;
+ InternalP.ToHPLC -> LogicSPIP.HplLIS3L02DQ;
+ InternalP.SubControl -> LogicSPIP.SplitControl;
+ InternalP.SPICLK -> HplPXA27xGPIOC.HplPXA27xGPIOPin[SSP1_SCLK];
+ InternalP.SPIRxD -> HplPXA27xGPIOC.HplPXA27xGPIOPin[SSP1_RXD];
+ InternalP.SPITxD -> HplPXA27xGPIOC.HplPXA27xGPIOPin[SSP1_TXD];
+ InternalP.HPWRCntl -> HplPXA27xGPIOC.HplPXA27xGPIOPin[GPIO_PWR_ADC_NSHDWN];
- components HplPXA27xGPIOC;
- Logic.SPICLK -> HplPXA27xGPIOC.HplPXA27xGPIOPin[SSP1_SCLK];
- Logic.SPIFRM -> HplPXA27xGPIOC.HplPXA27xGPIOPin[SSP1_SFRM];
- Logic.SPIRxD -> HplPXA27xGPIOC.HplPXA27xGPIOPin[SSP1_RXD];
- Logic.SPITxD -> HplPXA27xGPIOC.HplPXA27xGPIOPin[SSP1_TXD];
+ LogicSPIP.SpiPacket -> HalSpi.SpiPacket[unique("SPIInstance")];
+ LogicSPIP.SPIFRM -> GeneralIOC.GeneralIO[SSP1_SFRM];
+ LogicSPIP.InterruptAlert -> GeneralIOC.GpioInterrupt[GPIO_LIS3L02DQ_RDY_INT];
+
+ ControlP.Hpl -> LogicSPIP;
- components HalLIS3L02DQControlP as Control;
- Control.Hpl -> Logic;
+ MainC.SoftwareInit -> HalSpi;
+ MainC.SoftwareInit -> LogicSPIP;
+
+ HalSpi.SSP -> HplPXA27xSSP1C;
}
*/
module LIS3L02DQInternalP {
+ provides interface Init;
+ provides interface SplitControl;
provides interface HplLIS3L02DQ[uint8_t id];
+
+ uses interface SplitControl as SubControl;
uses interface HplLIS3L02DQ as ToHPLC;
+ uses interface HplPXA27xGPIOPin as SPIRxD;
+ uses interface HplPXA27xGPIOPin as SPITxD;
+ uses interface HplPXA27xGPIOPin as SPICLK;
+ uses interface HplPXA27xGPIOPin as HPWRCntl;
}
implementation {
uint8_t currentId;
+
+ command error_t Init.init() {
+ // Initialize Pin Directions
+ call SPICLK.setGAFRpin(SSP1_SCLK_ALTFN);
+ call SPICLK.setGPDRbit(TRUE);
+ call SPIRxD.setGAFRpin(SSP1_RXD_ALTFN);
+ call SPIRxD.setGPDRbit(FALSE);
+ call SPITxD.setGAFRpin(SSP1_TXD_ALTFN);
+ call SPITxD.setGPDRbit(TRUE);
+
+ call HPWRCntl.setGPDRbit(TRUE);
+ call HPWRCntl.setGPSRbit();
+ return SUCCESS;
+ }
+
+ command error_t SplitControl.start() {
+ error_t error = SUCCESS;
+ error = call SubControl.start();
+ return error;
+ }
+
+ command error_t SplitControl.stop() {
+ error_t error = SUCCESS;
+ error = call SubControl.stop();
+ return error;
+ }
+
command error_t HplLIS3L02DQ.getReg[uint8_t id](uint8_t regAddr) {
currentId = id;
return call ToHPLC.getReg(regAddr);
currentId = id;
return call ToHPLC.setReg(regAddr, val);
}
+
+ event void SubControl.startDone(error_t error) {
+ signal SplitControl.startDone(error);
+ return;
+ }
+ event void SubControl.stopDone(error_t error) {
+ signal SplitControl.stopDone(error);
+ return;
+ }
+
async event void ToHPLC.getRegDone(error_t error, uint8_t regAddr, uint8_t val) {
signal HplLIS3L02DQ.getRegDone[currentId](error, regAddr, val);
}
async event void ToHPLC.alertThreshold() {
signal HplLIS3L02DQ.alertThreshold[currentId]();
}
+
+ async event void SPITxD.interruptGPIOPin() {}
+ async event void SPIRxD.interruptGPIOPin() {}
+ async event void SPICLK.interruptGPIOPin() {}
+ async event void HPWRCntl.interruptGPIOPin() {}
+
+ default event void SplitControl.startDone(error_t error) { return; }
+ default event void SplitControl.stopDone(error_t error) { return; }
default async event void HplLIS3L02DQ.getRegDone[uint8_t id](error_t error, uint8_t regAddr, uint8_t val) { }
default async event void HplLIS3L02DQ.setRegDone[uint8_t id](error_t error, uint8_t regAddr, uint8_t val) { }
+ default async event void HplLIS3L02DQ.alertThreshold[uint8_t id]() { }
}
}
implementation {
- components new FcfsArbiterC( "MAX136x.Resource" )as Arbiter;
+ components new SimpleFcfsArbiterC( "MAX136x.Resource" )as Arbiter;
components MainC;
Resource = Arbiter;
- MainC.SoftwareInit -> Arbiter;
components new HplMAX136xLogicP(MAX136_SLAVE_ADDR) as Logic;
MainC.SoftwareInit -> Logic;
- components HalPXA27xI2CMasterC as I2CC;
+ components new HalPXA27xI2CMasterC(TRUE) as I2CC;
Logic.I2CPacket -> I2CC;
components MAX136xInternalP as Internal;
currentId = id;
return call ToHPLC.setConfig(cfgbuf, len);
}
+ command error_t HplMAX136x.readStatus[uint8_t id](uint8_t *buf, uint8_t len) {
+ currentId = id;
+ return call ToHPLC.readStatus(buf, len);
+ }
async event void ToHPLC.measureChannelsDone(error_t error, uint8_t *buf, uint8_t len) {
signal HplMAX136x.measureChannelsDone[currentId](error, buf, len);
}
async event void ToHPLC.alertThreshold() {
signal HplMAX136x.alertThreshold[currentId]();
}
-
+ async event void ToHPLC.readStatusDone(error_t error, uint8_t * buf) {
+ signal HplMAX136x.readStatusDone[currentId](error, buf);
+ }
default async event void HplMAX136x.measureChannelsDone[uint8_t id]( error_t error, uint8_t *buf, uint8_t len ) {}
default async event void HplMAX136x.setConfigDone[uint8_t id]( error_t error , uint8_t *cfgbuf, uint8_t len) {}
default async event void HplMAX136x.alertThreshold[uint8_t id]() {}
+ default async event void HplMAX136x.readStatusDone[uint8_t id](error_t error, uint8_t *buf) { }
}
generic configuration SensirionSht11C() {
provides interface Read<uint16_t> as Temperature;
provides interface Read<uint16_t> as Humidity;
+ //provides interface HalSht11Advanced;
}
implementation {
components new SensirionSht11ReaderP();
SensirionSht11ReaderP.Sht11Temp -> HalSensirionSht11C.SensirionSht11[ TEMP_KEY ];
SensirionSht11ReaderP.HumResource -> HalSensirionSht11C.Resource[ HUM_KEY ];
SensirionSht11ReaderP.Sht11Hum -> HalSensirionSht11C.SensirionSht11[ HUM_KEY ];
+
+ //enum { ADV_KEY = unique("Sht11.Resource") };
+ //components HalSht11ControlP;
+ //HalSht11Advanced = HalSht11ControlP;
+ //HalSht11ControlP.Resource -> HalSensirionSht11C.Resource[ ADV_KEY ];
+ //HalSht11ControlP.SensirionSht11 -> HalSensirionSht11C.SensirionSht11[ ADV_KEY ];
}
ADV_ID = unique("TMP175.HplAccess"),
};
- components new FcfsArbiterC( "TMP175.Resource" ) as Arbiter;
+ components new SimpleFcfsArbiterC( "TMP175.Resource" ) as Arbiter;
components MainC;
Resource = Arbiter;
- MainC.SoftwareInit -> Arbiter;
components new HplTMP175LogicP(TMP175_SLAVE_ADDR) as Logic;
MainC.SoftwareInit -> Logic;
Logic.AlertInterrupt -> GeneralIOC.GpioInterrupt[GPIO_TMP175_TEMP_ALERT];
Logic.InterruptPin -> GeneralIOC.GeneralIO[GPIO_TMP175_TEMP_ALERT];
- components HalPXA27xI2CMasterC as I2CC;
+ components new HalPXA27xI2CMasterC(TRUE) as I2CC;
Logic.I2CPacket -> I2CC;
components TMP175InternalP as Internal;
};
- components new FcfsArbiterC( "Tsl2561.Resource" ) as Arbiter;
+ components new SimpleFcfsArbiterC( "Tsl2561.Resource" ) as Arbiter;
components MainC;
Resource = Arbiter;
- MainC.SoftwareInit -> Arbiter;
components new HplTSL2561LogicP(TSL2561_SLAVE_ADDR) as Logic;
- MainC.SoftwareInit -> Logic;
+ //MainC.SoftwareInit -> Logic;
+ components LedsC;
+ Logic.Leds -> LedsC;
components GeneralIOC;
Logic.InterruptAlert -> GeneralIOC.GpioInterrupt[GPIO_TSL2561_LIGHT_INT];
Logic.InterruptPin -> GeneralIOC.GeneralIO[GPIO_TSL2561_LIGHT_INT];
- components HalPXA27xI2CMasterC as I2CC;
+ components new HalPXA27xI2CMasterC(TRUE) as I2CC;
Logic.I2CPacket -> I2CC;
components Tsl2561InternalP as Internal;
HplTSL256x = Internal.HplTSL256x;
Internal.ToHPLC -> Logic.HplTSL256x;
-
+ Internal.SubInit -> Logic.Init;
SplitControl = Logic;
+ MainC.SoftwareInit -> Internal;
components HplPXA27xGPIOC;
I2CC.I2CSCL -> HplPXA27xGPIOC.HplPXA27xGPIOPin[I2C_SCL];
* @author Phil Buonadonna
*/
module Tsl2561InternalP {
+ provides interface Init;
provides interface HplTSL256x[uint8_t id];
+ uses interface Init as SubInit;
uses interface HplTSL256x as ToHPLC;
+ uses interface GpioInterrupt as InterruptAlert;
}
implementation {
uint8_t currentId;
+ command error_t Init.init() {
+ call SubInit.init();
+ // The Intel Mote 2 Sensorboard multiplexes the TSL interrupt through a NAND
+ // gate. Need to overrid the edge trigger from the driver default
+ call InterruptAlert.enableRisingEdge();
+ return SUCCESS;
+ }
+
command error_t HplTSL256x.measureCh0[uint8_t id]() {
currentId = id;
return call ToHPLC.measureCh0();
signal HplTSL256x.alertThreshold[currentId]();
}
+ async event InterruptAlert.fired() {}
+
default async event void HplTSL256x.measureCh0Done[uint8_t id]( error_t error, uint16_t val ){ return; }
default async event void HplTSL256x.measureCh1Done[uint8_t id]( error_t error, uint16_t val ){ return; }
default async event void HplTSL256x.setCONTROLDone[uint8_t id]( error_t error ){ return; }
#define GPIO_LIS3L02DQ_RDY_INT (96)\r
#define GPIO_TMP175_TEMP_ALERT (96)\r
\r
+#define GPIO_PWR_ADC_NSHDWN (93)\r
+\r
#define TSL2561_SLAVE_ADDR (0x49)\r
#define TMP175_SLAVE_ADDR (0x48)\r
#define MAX136_SLAVE_ADDR (0x35)\r
* THE POSSIBILITY OF SUCH DAMAGE.\r
*\r
* @author Martin Turon <mturon@xbow.com>\r
+ * @author Miguel Freitas\r
*\r
* $Id$\r
*/\r
provides {\r
interface Init; //!< Standard Initialization\r
interface StdControl; //!< Start/Stop for Power Management\r
- interface AcquireData as Temp; //!< Thermister\r
- interface AcquireData as Light; //!< Photo sensor\r
+ interface Read<uint16_t> as Temp; //!< Thermister\r
+ interface Read<uint16_t> as Light; //!< Photo sensor\r
}\r
}\r
implementation \r
{\r
components \r
SensorMts300P,\r
- HplGeneralIOC as IO,\r
- new AdcChannelC(1) as SensorADC,\r
- new OskiTimerMilliC() as WarmUpTimer\r
+ SensorMts300DeviceP,\r
+ HplAtm128GeneralIOC as IO,\r
+ new AdcReadClientC() as SensorADC,\r
+ new TimerMilliC() as WarmUpTimer\r
;\r
\r
Init = SensorMts300P.Init;\r
Temp = SensorMts300P.Temp;\r
Light = SensorMts300P.Light;\r
\r
+ SensorADC.Atm128AdcConfig -> SensorMts300DeviceP;\r
+ SensorADC.ResourceConfigure -> SensorMts300DeviceP;\r
+\r
SensorMts300P.SensorADC -> SensorADC;\r
SensorMts300P.TempPower -> IO.PortE6;\r
SensorMts300P.LightPower -> IO.PortE5;\r
* THE POSSIBILITY OF SUCH DAMAGE.\r
*\r
* @author Martin Turon <mturon@xbow.com>\r
+ * @author Miguel Freitas\r
*\r
* $Id$\r
*/\r
provides {\r
interface Init; //!< Standard Initialization\r
interface StdControl; //!< Start/Stop for Power Management\r
- interface AcquireData as Temp; //!< Thermister\r
- interface AcquireData as Light; //!< Photo sensor\r
+ interface Read<uint16_t> as Temp; //!< Thermister\r
+ interface Read<uint16_t> as Light; //!< Photo sensor\r
}\r
\r
uses {\r
interface GeneralIO as TempPower;\r
interface GeneralIO as LightPower;\r
- interface AcquireData as SensorADC;\r
+ interface Read<uint16_t> as SensorADC;\r
interface Timer<TMilli> as WarmUpTimer;\r
}\r
}\r
*/\r
command error_t Init.init() {\r
g_flags.flat = STATE_IDLE;\r
+ return SUCCESS;\r
}\r
\r
/**\r
* @return SUCCESS if the component was successfully started.\r
*/\r
command error_t StdControl.start() {\r
+ return SUCCESS;\r
}\r
\r
/**\r
call TempPower.makeInput();\r
call LightPower.makeInput();\r
atomic g_flags.bits.state = STATE_IDLE;\r
+ return SUCCESS;\r
}\r
\r
/** Turns on the light sensor and turns the thermistor off. */\r
case STATE_LIGHT_READY:\r
// Start the sample.\r
atomic { g_flags.bits.state = STATE_LIGHT_SAMPLING; }\r
- call SensorADC.getData();\r
+ call SensorADC.read();\r
return;\r
\r
case STATE_LIGHT_SAMPLING:\r
case STATE_LIGHT_SAMPLING:\r
// If Temperature is busy, repost and try again later.\r
// This will not let the CPU sleep. Add delay timer.\r
- post getLightSample();\r
+ post getTempSample();\r
return;\r
\r
case STATE_IDLE: \r
case STATE_TEMP_READY:\r
// Start the sample.\r
atomic { g_flags.bits.state = STATE_TEMP_SAMPLING; }\r
- call SensorADC.getData();\r
+ call SensorADC.read();\r
return;\r
\r
case STATE_TEMP_SAMPLING:\r
* @return SUCCESS if request accepted, EBUSY if it is refused\r
* 'dataReady' or 'error' will be signaled if SUCCESS is returned\r
*/\r
- command error_t Temp.getData() {\r
+ command error_t Temp.read() {\r
post getTempSample(); \r
return SUCCESS;\r
}\r
* @return SUCCESS if request accepted, EBUSY if it is refused\r
* 'dataReady' or 'error' will be signaled if SUCCESS is returned\r
*/\r
- command error_t Light.getData() {\r
+ command error_t Light.read() {\r
post getLightSample(); \r
return SUCCESS;\r
}\r
\r
default:\r
//ERROR!!!\r
- signal Light.error(-1);\r
- signal Temp.error(-1);\r
+ signal Light.readDone( FAIL, 0 );\r
+ signal Temp.readDone( FAIL, 0 );\r
}\r
// Worst case -- return to the IDLE state so next task can progress !!\r
atomic { g_flags.bits.state = STATE_IDLE; }\r
* the data is acquired with n bits of precision, each value is \r
* shifted left by 16-n bits.\r
*/\r
- event void SensorADC.dataReady(uint16_t data) {\r
+ event void SensorADC.readDone( error_t result, uint16_t data ) {\r
switch (g_flags.bits.state) {\r
case STATE_LIGHT_SAMPLING:\r
- signal Light.dataReady(data);\r
+ signal Light.readDone(result, data);\r
break;\r
\r
case STATE_TEMP_SAMPLING:\r
- signal Temp.dataReady(data);\r
+ signal Temp.readDone(result, data);\r
break;\r
\r
default:\r
//ERROR!!!\r
- signal Light.error(data);\r
- signal Temp.error(data);\r
+ signal Light.readDone( FAIL, 0 );\r
+ signal Temp.readDone( FAIL, 0 );\r
}\r
// ADC.dataReady must return to IDLE state so next task can progress !!\r
atomic { g_flags.bits.state = STATE_IDLE; }\r
}\r
\r
-\r
- /** \r
- * Signal that the data acquisition failed\r
- * @param info error information\r
- */\r
- event void SensorADC.error(uint16_t info) {\r
- switch (g_flags.bits.state) {\r
- case STATE_LIGHT_SAMPLING:\r
- signal Light.error(info);\r
- break;\r
-\r
- case STATE_TEMP_SAMPLING:\r
- signal Temp.error(info);\r
- break;\r
-\r
- default:\r
- //ERROR!!!\r
- signal Light.error(info);\r
- signal Temp.error(info);\r
- }\r
- // ADC.dataReady must return to IDLE state so next task can progress !!\r
- atomic { g_flags.bits.state = STATE_IDLE; }\r
- }\r
}\r
\r
\r
\r
-\r
-\r
default async command error_t Resource.request[uint8_t client]() {
return FAIL;
}
- default async command void Resource.release[uint8_t client]() { }
+ default async command error_t Resource.release[uint8_t client]() { return FAIL; }
default event void Read.readDone[uint8_t client](error_t result, width_t data) { }
default command error_t Service.read[uint8_t client]() {
return SUCCESS;
default async command error_t Resource.immediateRequest[uint8_t client]() {
return FAIL;
}
- default async command void Resource.release[uint8_t client]() { }
+ default async command error_t Resource.release[uint8_t client]() { return FAIL; }
default async event void ReadNow.readDone[uint8_t client](error_t result, width_t data) { }
default async command error_t Service.read[uint8_t client]() {
return SUCCESS;
default async command error_t Resource.request[uint8_t client]() {
return SUCCESS;
}
- default async command void Resource.release[uint8_t client]() { }
+ default async command error_t Resource.release[uint8_t client]() { return FAIL; }
default command error_t Service.postBuffer[uint8_t client](val_t* buf, uint16_t count)
{
* @param <b>resourceName</b> -- The name of the Resource being shared
*
* @author Kevin Klues (klues@tkn.tu-berlin.de)
- * @author Philip Levis
*/
-generic module FcfsArbiterC(char resourceName[]) {
+generic configuration FcfsArbiterC(char resourceName[]) {
provides {
- interface Init;
interface Resource[uint8_t id];
+ interface ResourceRequested[uint8_t id];
interface ResourceController;
interface ArbiterInfo;
}
- uses {
- interface ResourceConfigure[uint8_t id];
- }
+ uses interface ResourceConfigure[uint8_t id];
}
implementation {
+ components MainC;
+ components new FcfsResourceQueueC(uniqueCount(resourceName)) as Queue;
+ components new ArbiterP(uniqueCount(resourceName)) as Arbiter;
- enum {RES_IDLE, RES_GRANTING, RES_BUSY};
- enum {NO_RES = 0xFF};
- enum {CONTROLLER_ID = uniqueCount(resourceName) + 1};
-
- uint8_t state = RES_IDLE;
- uint8_t resId = NO_RES;
- uint8_t reqResId = NO_RES;
- uint8_t resQ[uniqueCount(resourceName)];
- uint8_t qHead = NO_RES;
- uint8_t qTail = NO_RES;
- bool irp = FALSE;
-
- task void grantedTask();
- task void requestedTask();
- error_t queueRequest(uint8_t id);
- void grantNextRequest();
-
- bool requested(uint8_t id) {
- return resQ[id] != NO_RES || qTail == id;
- }
-
- /**
- Initialize the Arbiter to the idle state
- */
- command error_t Init.init() {
- memset( resQ, NO_RES, sizeof( resQ ) );
- return SUCCESS;
- }
-
- /**
- Request the use of the shared resource
-
- If the user has not already requested access to the
- resource, the request will be either served immediately
- or queued for later service in an FCFS fashion.
- A SUCCESS value will be returned and the user will receive
- the granted() event in synchronous context once it has
- been given access to the resource.
-
- Whenever requests are queued, the current owner of the bus
- will receive a requested() event, notifying him that another
- user would like to have access to the resource.
-
- If the user has already requested access to the resource and
- is waiting on a pending granted() event, an EBUSY value will
- be returned to the caller.
- */
- async command error_t Resource.request[uint8_t id]() {
- atomic {
- if( state == RES_IDLE ) {
- state = RES_GRANTING;
- reqResId = id;
- post grantedTask();
- return SUCCESS;
- }
- if(resId == CONTROLLER_ID)
- post requestedTask();
- return queueRequest( id );
- }
- }
-
- async command error_t ResourceController.request() {
- return call Resource.request[CONTROLLER_ID]();
- }
-
- /**
- * Request immediate access to the shared resource. Requests are
- * not queued, and no granted event is returned. A return value
- * of SUCCESS signifies that the resource has been granted to you,
- * while a return value of EBUSY signifies that the resource is
- * currently being used.
- */
- uint8_t tryImmediateRequest(uint8_t id) {
- atomic {
- if( state == RES_IDLE ) {
- state = RES_BUSY;
- resId = id;
- return id;
- }
- return resId;
- }
- }
- async command error_t Resource.immediateRequest[uint8_t id]() {
- uint8_t ownerId = tryImmediateRequest(id);
-
- if(ownerId == id) {
- call ResourceConfigure.configure[id]();
- return SUCCESS;
- }
- else if(ownerId == CONTROLLER_ID){
- atomic {
- irp = TRUE; //indicate that immediateRequest is pending
- reqResId = id; //Id to grant resource to if can
- }
- signal ResourceController.requested();
- atomic {
- ownerId = resId; //See if I have been granted the resource
- irp = FALSE; //Indicate that immediate request no longer pending
- }
- if(ownerId == id) {
- call ResourceConfigure.configure[id]();
- return SUCCESS;
- }
- return EBUSY;
- }
- else return EBUSY;
- }
- async command error_t ResourceController.immediateRequest() {
- return call Resource.immediateRequest[CONTROLLER_ID]();
- }
-
- /**
- Release the use of the shared resource
-
- The resource will only actually be released if
- there are no pending requests for the resource.
- If requests are pending, then the next pending request
- will be serviced, according to a Fist come first serve
- arbitration scheme. If no requests are currently
- pending, then the resource is released, and any
- users can put in a request for immediate access to
- the resource.
- */
- async command void Resource.release[uint8_t id]() {
- uint8_t currentState;
- atomic {
- if (state == RES_BUSY && resId == id) {
- if (irp)
- resId = reqResId;
- else grantNextRequest();
- call ResourceConfigure.unconfigure[id]();
- }
- currentState = state;
- }
- if(currentState == RES_IDLE)
- signal ResourceController.idle();
- }
- async command void ResourceController.release() {
- call Resource.release[CONTROLLER_ID]();
- }
-
- /**
- Check if the Resource is currently in use
- */
- async command bool ArbiterInfo.inUse() {
- atomic {
- if ( state == RES_IDLE )
- return FALSE;
- }
- return TRUE;
- }
-
- /**
- Returns the current user of the Resource.
- If there is no current user, the return value
- will be 0xFF
- */
- async command uint8_t ArbiterInfo.userId() {
- atomic return resId;
- }
+ MainC.SoftwareInit -> Queue;
- /**
- * Returns my user id.
- */
- async command uint8_t Resource.isOwner[uint8_t id]() {
- atomic {
- if(resId == id) return TRUE;
- else return FALSE;
- }
- }
- async command uint8_t ResourceController.isOwner() {
- return call Resource.isOwner[CONTROLLER_ID]();
- }
-
- //Grant a request to the next Pending user
- //in FCFS order
- void grantNextRequest() {
- resId = NO_RES;
- if(qHead != NO_RES) {
- uint8_t id = qHead;
- qHead = resQ[qHead];
- if(qHead == NO_RES)
- qTail = NO_RES;
- resQ[id] = NO_RES;
- reqResId = id;
- state = RES_GRANTING;
- post grantedTask();
- }
- else {
- state = RES_IDLE;
- }
- }
-
- //Queue the requests so that they can be granted
- //in FCFS order after release of the resource
- error_t queueRequest(uint8_t id) {
- atomic {
- if( !requested( id ) ) {
- if(qHead == NO_RES )
- qHead = id;
- else
- resQ[qTail] = id;
- qTail = id;
- return SUCCESS;
- }
- return EBUSY;
- }
- }
-
- //Task for pulling the Resource.granted() signal
- //into synchronous context
- task void grantedTask() {
- uint8_t tmpId;
- atomic {
- tmpId = resId = reqResId;
- state = RES_BUSY;
- }
- call ResourceConfigure.configure[tmpId]();
- signal Resource.granted[tmpId]();
- }
+ Resource = Arbiter;
+ ResourceRequested = Arbiter;
+ ResourceController = Arbiter;
+ ArbiterInfo = Arbiter;
+ ResourceConfigure = Arbiter;
- //Task for pulling the ResourceController.requested() signal
- //into synchronous context
- task void requestedTask() {
- uint8_t tmpId;
- atomic {
- tmpId = resId;
- }
- if(tmpId == CONTROLLER_ID)
- signal ResourceController.requested();
- }
-
- //Default event/command handlers for all of the other
- //potential users/providers of the parameterized interfaces
- //that have not been connected to.
- default event void Resource.granted[uint8_t id]() {
- signal ResourceController.granted();
- }
- default event void ResourceController.granted() {
- }
- default async event void ResourceController.requested() {
- }
- default async event void ResourceController.idle() {
- }
- default async command void ResourceConfigure.configure[uint8_t id]() {
- }
- default async command void ResourceConfigure.unconfigure[uint8_t id]() {
- }
+ Arbiter.Queue -> Queue;
}
* checking. Does still call ResourceConfigure at the right time.
*
* @author David Gay
+ * @author Kevin Klues
*/
generic module NoArbiterC() {
return SUCCESS;
}
- async command void Resource.release() {
+ async command error_t Resource.release() {
call ResourceConfigure.unconfigure();
+ return SUCCESS;
}
async command uint8_t Resource.isOwner() {
async command void GeneralIO.toggle() { }
async command void GeneralIO.makeInput() { }
async command void GeneralIO.makeOutput() { }
+ async command bool GeneralIO.isInput() { }
+ async command bool GeneralIO.isOutput() { }
}
* A general dynamic memory pool component.
*
* @author Philip Levis
+ * @author Geoffrey Mainland
* @date $Date$
*/
*
* @author Philip Levis
* @author Kyle Jamieson
+ * @author Geoffrey Mainland
* @date $Date$
*/
pool_t* rval = queue[index];
queue[index] = NULL;
free--;
- index = (index + 1) % size;
+ index++;
+ if (index == size) {
+ index = 0;
+ }
return rval;
}
return NULL;
return FAIL;
}
else {
- uint8_t emptyIndex = (index + free) % size;
+ uint8_t emptyIndex = (index + free);
+ if (emptyIndex >= size) {
+ emptyIndex -= size;
+ }
queue[emptyIndex] = newVal;
free++;
return SUCCESS;
* A general FIFO queue component, whose queue has a bounded size.
*
* @author Philip Levis
+ * @author Geoffrey Mainland
* @date $Date$
*/
*
* This component provides the Resource, ArbiterInfo, and Resource
* Controller interfaces and uses the ResourceConfigure interface as
- * described in TEP 108. It provides arbitration to a shared resource in a
- * round robin fashion. An array is used to keep track of which users have
- * put in requests for the resource. Upon the release of the resource by
- * one of these users, the array is checked and the next user (in round
- * robin order) that has a pending request will ge granted control of the
- * resource. If there are no pending requests, then the resource becomes
- * idle and any user can put in a request and immediately receive access to
- * the round robin order * Resource.
+ * described in TEP 108. It provides arbitration to a shared resource in
+ * an FCFS fashion. An array is used to keep track of which users have put
+ * in requests for the resource. Upon the release of the resource by one
+ * of these users, the array is checked and the next user (in FCFS order)
+ * that has a pending request will ge granted control of the resource. If
+ * there are no pending requests, then the resource becomes idle and any
+ * user can put in a request and immediately receive access to the
+ * Resource.
*
* @param <b>resourceName</b> -- The name of the Resource being shared
*
* @author Kevin Klues (klues@tkn.tu-berlin.de)
- * @author Philip Levis
*/
-generic module RoundRobinArbiterC(char resourceName[]) {
+generic configuration RoundRobinArbiterC(char resourceName[]) {
provides {
- interface Init @atleastonce();
interface Resource[uint8_t id];
+ interface ResourceRequested[uint8_t id];
interface ResourceController;
interface ArbiterInfo;
}
- uses {
- interface ResourceConfigure[uint8_t id];
- }
+ uses interface ResourceConfigure[uint8_t id];
}
implementation {
- enum {RES_IDLE, RES_GRANTING, RES_BUSY};
- enum {NO_RES = 0xFF};
- enum {CONTROLLER_ID = uniqueCount(resourceName) + 1};
-
- uint8_t state = RES_IDLE;
- uint8_t resId = NO_RES;
- uint8_t reqResId;
- uint8_t request[(uniqueCount(resourceName)-1)/8 + 1];
- bool irp = FALSE;
-
- task void grantedTask();
- task void requestedTask();
- void grantNextRequest();
-
- /**
- Initialize the Arbiter to the idle state
- */
- command error_t Init.init() {
- return SUCCESS;
- }
-
- uint8_t requested(uint8_t id) {
- return request[id / 8] & (1 << (id % 8));
- }
-
- void clearRequest(uint8_t id) {
- request[id / 8] &= ~(1 << (id % 8));
- }
-
- error_t queueRequest(uint8_t id) {
- if (!requested(id)){
- request[id / 8] |= 1 << (id % 8);
- return SUCCESS;
- }
- return EBUSY;
- }
-
- /**
- Request the use of the shared resource
-
- If the user has not already requested access to the
- resource, the request will be either served immediately
- or queued for later service in a round robin fashion.
- A SUCCESS value will be returned and the user will receive
- the granted() event in synchronous context once it has
- been given access to the resource.
-
- Whenever requests are queued, the current owner of the bus
- will receive a requested() event, notifying him that another
- user would like to have access to the resource.
-
- If the user has already requested access to the resource and
- is waiting on a pending granted() event, an EBUSY value will
- be returned to the caller.
- */
- async command error_t Resource.request[uint8_t id]() {
- atomic {
- if( state == RES_IDLE ) {
- state = RES_GRANTING;
- reqResId = id;
- post grantedTask();
- return SUCCESS;
- }
- if(resId == CONTROLLER_ID)
- post requestedTask();
- return queueRequest( id );
- }
- }
-
- async command error_t ResourceController.request() {
- return call Resource.request[CONTROLLER_ID]();
- }
-
- /**
- * Request immediate access to the shared resource. Requests are
- * not queued, and no granted event is returned. A return value
- * of SUCCESS signifies that the resource has been granted to you,
- * while a return value of EBUSY signifies that the resource is
- * currently being used.
- */
- uint8_t tryImmediateRequest(uint8_t id) {
- atomic {
- if( state == RES_IDLE ) {
- state = RES_BUSY;
- resId = id;
- return id;
- }
- return resId;
- }
- }
- async command error_t Resource.immediateRequest[uint8_t id]() {
- uint8_t ownerId = tryImmediateRequest(id);
-
- if(ownerId == id) {
- call ResourceConfigure.configure[id]();
- return SUCCESS;
- }
- else if(ownerId == CONTROLLER_ID){
- atomic {
- irp = TRUE; //indicate that immediateRequest is pending
- reqResId = id; //Id to grant resource to if can
- }
- signal ResourceController.requested();
- atomic {
- ownerId = resId; //See if I have been granted the resource
- irp = FALSE; //Indicate that immediate request no longer pending
- }
- if(ownerId == id) {
- call ResourceConfigure.configure[id]();
- return SUCCESS;
- }
- return EBUSY;
- }
- else return EBUSY;
- }
-
- async command error_t ResourceController.immediateRequest() {
- return call Resource.immediateRequest[CONTROLLER_ID]();
- }
-
- /**
- Release the use of the shared resource
-
- The resource will only actually be released if
- there are no pending requests for the resource.
- If requests are pending, then the next pending request
- will be serviced, according to a round robin arbitration
- scheme. If no requests are currently pending, then the
- resource is released, and any users can put in a request
- for immediate access to the resource.
- */
- async command void Resource.release[uint8_t id]() {
- uint8_t currentState;
- atomic {
- if (state == RES_BUSY && resId == id) {
- if(irp)
- resId = reqResId;
- else grantNextRequest();
- call ResourceConfigure.unconfigure[id]();
- }
- currentState = state;
- }
- if(currentState == RES_IDLE)
- signal ResourceController.idle();
- }
+ components MainC;
+ components new RoundRobinResourceQueueC(uniqueCount(resourceName)) as Queue;
+ components new ArbiterP(uniqueCount(resourceName)) as Arbiter;
- async command void ResourceController.release() {
- call Resource.release[CONTROLLER_ID]();
- }
-
- /**
- Check if the Resource is currently in use
- */
- async command bool ArbiterInfo.inUse() {
- atomic {
- if ( state == RES_IDLE )
- return FALSE;
- }
- return TRUE;
- }
-
- /**
- Returns the current user of the Resource.
- If there is no current user, the return value
- will be 0xFF
- */
- async command uint8_t ArbiterInfo.userId() {
- atomic return resId;
- }
+ MainC.SoftwareInit -> Queue;
- /**
- * Returns my user id.
- */
- async command uint8_t Resource.isOwner[uint8_t id]() {
- atomic {
- if(resId == id) return TRUE;
- else return FALSE;
- }
- }
- async command uint8_t ResourceController.isOwner() {
- return call Resource.isOwner[CONTROLLER_ID]();
- }
-
- //Grant a request to the next Pending user
- //in Round-Robin order
- void grantNextRequest() {
- int i;
-
- for (i = resId + 1; ; i++) {
- if (i >= (uniqueCount(resourceName) + 1))
- i = 0;
- if (i == resId)
- break;
- if (requested(i)) {
- reqResId = i;
- clearRequest(i);
- resId = NO_RES;
- state = RES_GRANTING;
- post grantedTask();
- return;
- }
- }
- resId = NO_RES;
- state = RES_IDLE;
- }
-
- //Task for pulling the Resource.granted() signal
- //into synchronous context
- task void grantedTask() {
- uint8_t tmpId;
- atomic {
- tmpId = resId = reqResId;
- state = RES_BUSY;
- }
- call ResourceConfigure.configure[tmpId]();
- signal Resource.granted[tmpId]();
- }
+ Resource = Arbiter;
+ ResourceRequested = Arbiter;
+ ResourceController = Arbiter;
+ ArbiterInfo = Arbiter;
+ ResourceConfigure = Arbiter;
- //Task for pulling the ResourceController.requested() signal
- //into synchronous context
- task void requestedTask() {
- uint8_t tmpId;
- atomic {
- tmpId = resId;
- }
- if(tmpId == CONTROLLER_ID)
- signal ResourceController.requested();
- }
-
- //Default event/command handlers for all of the other
- //potential users/providers of the parameterized interfaces
- //that have not been connected to.
- default event void Resource.granted[uint8_t id]() {
- signal ResourceController.granted();
- }
- default event void ResourceController.granted() {
- }
- default async event void ResourceController.requested() {
- }
- default async event void ResourceController.idle() {
- }
- default async command void ResourceConfigure.configure[uint8_t id]() {
- }
- default async command void ResourceConfigure.unconfigure[uint8_t id]() {
- }
+ Arbiter.Queue -> Queue;
}