Hello! What's on tos/lib/net/ctp is the default that comes with tos 2.0.1, i havent touched it. The applications is basically TestNetwork:
#include <Timer.h> #include "TestNetwork.h" #include "CtpDebugMsg.h" module TestNetworkC { uses interface Boot; uses interface SplitControl as RadioControl; uses interface SplitControl as SerialControl; uses interface StdControl as RoutingControl; uses interface DisseminationValue<uint16_t> as DisseminationPeriod; uses interface Send; uses interface Leds; uses interface Read<uint16_t> as ReadSensor; uses interface Timer<TMilli> as Timer0; uses interface Timer<TMilli> as Timer1; uses interface RootControl; uses interface Receive; uses interface Packet; uses interface AMSend as UARTSend; uses interface CollectionPacket; uses interface CtpInfo; uses interface CtpCongestion; uses interface Random; uses interface Queue<message_t*>; uses interface Pool<message_t>; uses interface CollectionDebug; uses interface GeneralIO as Pins; } implementation { task void uartEchoTask(); message_t packet; message_t uartpacket; message_t* recvPtr = &uartpacket; message_t pkt; uint8_t msglen; bool alarm = 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(); } event void SerialControl.startDone(error_t err) { call RadioControl.start(); } event void RadioControl.startDone(error_t err) { if (err != SUCCESS) { call RadioControl.start(); } else { call RoutingControl.start(); if (TOS_NODE_ID % 500 == 0) { call RootControl.setRoot(); } else{ if(IS_FFD) call Timer0.startPeriodic(TIMER_PERIOD_MILLI); call Timer1.startPeriodic(TIMER_PERIOD_KEEP_ALIVE); call Pins.makeInput(); } seqno = 0; call Leds.led1Toggle(); //call Timer.startOneShot(call Random.rand16() & 0x1ff); } } event void RadioControl.stopDone(error_t err) {} event void SerialControl.stopDone(error_t err) {} void failedSend() { dbg("App", "%s: Send failed.\n", __FUNCTION__); call CollectionDebug.logEvent(NET_C_DBG_1); } task void sendMessage() { TestNetworkMsg* msg = (TestNetworkMsg*)call Send.getPayload(&packet); uint16_t metric; am_addr_t parent; call CtpInfo.getParent(&parent); call CtpInfo.getEtx(&metric); msg->source = TOS_NODE_ID; msg->seqno = seqno; msg->datah = 0x10; msg->datal = 0x10; msg->parent = parent; msg->hopcount = 0; msg->metric = metric; if (call Send.send(&packet, sizeof(TestNetworkMsg)) != SUCCESS) { failedSend(); dbg("TestNetworkC", "%s: Transmission failed.\n", __FUNCTION__); } else { sendBusy = TRUE; seqno++; call Leds.led0Toggle(); dbg("TestNetworkC", "%s: Transmission succeeded.\n", __FUNCTION__); } } task void sendKeepAlive() { TestNetworkMsg* msg = (TestNetworkMsg*)call Send.getPayload(&packet); uint16_t metric; am_addr_t parent; call CtpInfo.getParent(&parent); call CtpInfo.getEtx(&metric); msg->source = TOS_NODE_ID; msg->seqno = seqno; msg->datah = 0x20; if(IS_FFD == 1) { msg->datal = 0x0A; } else { msg->datal = 0x12; } msg->parent = parent; msg->hopcount = 0; msg->metric = metric; if (call Send.send(&packet, sizeof(TestNetworkMsg)) != SUCCESS) { failedSend(); dbg("TestNetworkC", "%s: Transmission failed.\n", __FUNCTION__); } else { sendBusy = TRUE; seqno++; call Leds.led2Toggle(); dbg("TestNetworkC", "%s: Transmission succeeded.\n", __FUNCTION__); } } event void Timer0.fired() { if (call Pins.get()==FALSE && alarm == FALSE) { if(!sendBusy) post sendMessage(); alarm = TRUE; } else { call Pins.clr(); alarm = FALSE; } call Pins.clr(); } event void Timer1.fired(){ if (!sendBusy) { //TestNetworkMsg* btrpkt = (TestNetworkMsg*)(call Packet.getPayload(&pkt, NULL)); post sendKeepAlive(); } } event void Send.sendDone(message_t* msg, error_t err) { if (err != SUCCESS) { } sendBusy = FALSE; dbg("TestNetworkC", "Send completed.\n"); } event void DisseminationPeriod.changed() { const uint16_t* newVal = call DisseminationPeriod.get(); call Timer1.stop(); call Timer1.startPeriodic(*newVal); } event message_t* 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.led0Toggle(); /*if (len == sizeof(TestNetworkMsg)) { TestNetworkMsg* btrpkt = (TestNetworkMsg*)payload; setLeds(btrpkt->counter); }*/ 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() { dbg("Traffic", "Sending packet to UART.\n"); 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; } } The debug defines are commented on AppC.nc. On 7/16/07, Omprakash Gnawali <[EMAIL PROTECTED]> wrote:
Could you also post the tarball of tos/lib/net/ctp and the application you are using? - om_p > > Well, > > It's this 14 times,one message every time a node sends a data packet (the > CRC bytes there are wrong, i just put 0's in the middle using a normal > message as a starting point): > > 7E 45 00 FF FF 00 00 13 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > 00 00 00 00 53 63 7E > > the node id's are 0 (sink), 1 , 7, 20, 80 > after 14 of those (and always 14, regardless of sending interval by the > other nodes), i start collecting regular messages, like this one: > > 7E 45 00 FF FF 00 00 13 00 EE 00 01 00 00 00 07 80 EE 00 07 00 80 00 00 00 > 00 20 00 00 53 63 7E >
_______________________________________________ Tinyos-help mailing list Tinyos-help@Millennium.Berkeley.EDU https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help