Hello,

I wrote a small simulation in Python for TinyOS. I am just sending a packet
from one mote to another. Packets are received, but after the simulation is
over I get a core dumped message and I have no clue why.

This is my TOSSIM python file:

#! /usr/bin/python
from TOSSIM import *
import sys

t = Tossim([])
r = t.radio()
f = open("topo.txt", "r")

for line in f:
  s = line.split()
  if s:
    print " ", s[0], " ", s[1], " ", s[2];
    r.add(int(s[0]), int(s[1]), float(s[2]))

t.addChannel("XFER", sys.stdout)

noise = open("meyer-heavy.txt", "r")
for line in noise:
  str1 = line.strip()
  if str1:
    val = int(str1)
    for i in range(1, 4):
      t.getNode(i).addNoiseTraceReading(val)

for i in range(1, 4):
  print "Creating noise model for ",i;
  t.getNode(i).createNoiseModel()

t.getNode(1).bootAtTime(100001);
t.getNode(2).bootAtTime(800008);
t.getNode(3).bootAtTime(1800009);

for i in range(108):
  status = t.runNextEvent();
  print status;

This is my ..C.nc file

#include "Timer.h"
#include "SafeMots.h"

module SafeMotsC {
    uses {
        interface Boot;
        interface Timer<TMilli> as MilliTimer;
        interface Random;
        interface Init as RandomInit;
        interface ParameterInit<uint16_t> as RandomSeedInit;
        interface Receive;
            interface AMSend;
            interface SplitControl as AMControl;
            interface Packet;
        interface AMPacket;
    }
}

implementation {

    message_t pkt;

    bool busy = FALSE;

    typedef nx_struct payload_msg {
          nx_uint16_t value;
        nx_uint16_t cntr;
    } payload_msg_t;

    payload_msg_t* payload;

    /**
    * @brief Boot signal event
    */
    event void Boot.booted() {
        dbg("XFER","MOT BOOTED!\n");
        //call RandomSeedInit.init(41);
        //call MilliTimer.startPeriodic(25);
        call AMControl.start();
    }

    /**
    * @brief Timer fired event
    */
    event void MilliTimer.fired() {
        //uint16_t randNumber = call Random.rand16();
        dbg("XFER","Mot Timer fired!\n");

        if(!busy) {

            payload = (payload_msg_t*)call Packet.getPayload(&pkt,
sizeof(payload_msg_t));

            payload->value = 8;

            payload->cntr = 0;

              if (call AMSend.send(AM_BROADCAST_ADDR, &pkt,
sizeof(payload_msg_t)) == SUCCESS) {
                dbg("XFER","PKT SENT\n");
                busy = TRUE;
              }
          }
    }

    event void AMControl.startDone(error_t err) {
        if(err == SUCCESS) {
            dbg("XFER","AM CONTROL START DONE\n");
            call MilliTimer.startPeriodic(3000);
        }
        else {
            call AMControl.start();
        }
    }

    event void AMControl.stopDone(error_t err) {
        dbg("XFER","AM CONTROL STOP DONE\n");
    }

    event message_t* Receive.receive(message_t* bufPtr,void*
payload,uint8_t len) {
        payload_msg_t* payload_msg = (payload_msg_t*) payload;
        dbg("XFER","RECEIVE%d\n",payload_msg->value);
    }

    event void AMSend.sendDone(message_t* bufPtr,error_t error) {
        dbg("XFER","SEND DONE ENTERED\n");
        if(&pkt == bufPtr) {
            dbg("XFER","SEND DONE\n");
            busy = FALSE;
        }
    }
}


This is my ..AppC.nc file
#include "SafeMots.h"

configuration SafeMotsAppC {
}

implementation {

    components MainC, SafeMotsC as App,new
TimerMilliC(),RandomC,ActiveMessageC,new AMSenderC(AM_BLINKTORADIO),new
AMReceiverC(AM_BLINKTORADIO);

    // Boot wire
    App.Boot->MainC.Boot;

    // Timer wire
    App.MilliTimer->TimerMilliC;

    // Random
    App.Random->RandomC;

    // Random init
    App.RandomInit->RandomC;

    // Random seed init
    App.RandomSeedInit->RandomC;

    // Receive
    App.Receive->AMReceiverC;

    // Send
    App.AMSend->AMSenderC;

    // Packet
    App.Packet->AMSenderC;

    // Active message
    App.AMControl->ActiveMessageC;

    App.AMPacket->AMSenderC;
}


Any help would be appreciated.

With friendship,
Bogdan Chifor
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to