meghs94 / tinyos-main

Automatically exported from code.google.com/p/tinyos-main
1 stars 0 forks source link

Segmentation Fault #154

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hello everybody,

maybe someone of you can help me 

What steps will reproduce the problem?
1. My Code:

#!/bin/sh
from TOSSIM import *
#from tinyos.tossim.TossimApp import *
from random import *
import sys

NODECOUNT=53
tossim = Tossim([])
radio = tossim.radio()

def addNetworkTopology():
    file = open("sparse-grid.txt", "r")
    lines = file.readlines()
    for line in lines:
        str = line.split()
        if (len(str) > 0):
            if str[0] == "gain":
                radio.add(int(str[1]), int(str[2]), float(str[3]))

def addNoise():               
    file = open("meyer-short.txt", "r")
    lines = file.readlines()
    for i in range(0, NODECOUNT):
        str = lines[i].strip()
        if (str != ""):
            value = int(str)
            mote = tossim.getNode(i);
            mote.addNoiseTraceReading(value)

def bootNodes():
    for i in range(0, NODECOUNT):
        mote = tossim.getNode(i);
        mote.createNoiseModel();
        time = randint(tossim.ticksPerSecond(), 10 * tossim.ticksPerSecond())
        mote.bootAtTime(time)
        print "Booting Mote ", i, " at time ", time

def setDebugging():
    logfile=open("log.txt","w") 
    #tossim.addChannel("AM", sys.stdout)
    #tossimt.addChannel("TreeRouting", sys.stdout)
    tossim.addChannel("TestNetworkC", sys.stdout)
    #tossim.addChannel("Route", sys.stdout)
    #tossim.addChannel("PointerBug", sys.stdout)
    #tossim.addChannel("QueueC", sys.stdout)
    #tossim.addChannel("Gain", sys.stdout)
    #tossim.addChannel("Forwarder", sys.stdout)
    #tossim.addChannel("TestNetworkC", sys.stdout)
    #tossim.addChannel("App", sys.stdout)
    #tossim.addChannel("Traffic", sys.stdout)
    #tossim.addChannel("Acks", sys.stdout)
    tossim.addChannel("Thomas",logfile)
    tossim.addChannel("Thomas",sys.stdout)

addNetworkTopology()
#addNoise()
#setDebugging()
bootNodes()    

print "Starting simulation."
counter=0
while (tossim.time() < 1000 * tossim.ticksPerSecond()):
    print counter
    tossim.runNextEvent()
    counter+=1

print "Completed simulation."

2. I use a modify code from tinyos-2.1.2/app/test/TestNetwork

3. it runs a few steps and the I get a Segmentation fault

What version of the product are you using? On what operating system?
-Tinyos runs on linuxmint 13 - x64

can someone help me?

Original issue reported on code.google.com by thomas9...@yahoo.de on 16 Nov 2012 at 4:04

GoogleCodeExporter commented 8 years ago
problem found: 
def setDebugging():
  logfile=open("log.txt","w") 
  ...
  tossim.addChannel("Thomas",logfile)

logfile has to be a global variable. Otherwise tossim try to write on an Object 
that dose note exist anymore --> segmentation fault 

Original comment by thomas9...@yahoo.de on 16 Nov 2012 at 5:12