2

I have been struggling to integrate the Fuzzylite to my simulator Castalia, so far there is an error related to the Console.cpp under Fuzzylite src folder. In order to link the Fuzzylite to my simulator Castalia, I have added the EXTOPTS in the makemake file under Castalia,

#!/bin/bash

ROOT=`pwd`

# The following options are used by OMNeT's opp_makemake tool
# For explanation and a complete list of options run: opp_makemake -h
OPTS=" -f -r --deep -o CastaliaBin -u Cmdenv -P $ROOT -M release"

# -X excludes a directory from being considered
EXCLUDEDIRS=" -X Simulations -X out -X bin"

# Use options -I -L -l to include external header files or libraries    

EXTOPTS="-I /home/utar/Desktop/HY/fuzzylite-6.0/fuzzylite/ -L /home/utar/Desktop/HY/fuzzylite-6.0/fuzzylite/release/bin/ -lfuzzylite"



# Run OMNeT's opp_makemake tool with the above options
opp_makemake $OPTS $EXCLUDEDIRS $EXTOPTS

Then while the compilation runs smoothly, the simulation simply cannot be run. After tracing the file, I am able to trace the source of problem which results from Castalia bin file that is written in Python. The following is the snippet of code that concerns me :

r_castalia = re.compile("^Castalia\|\s+(.+)$")
r_scenario = re.compile("Scenario:\s(.*)\$repetition=(\d+)$")
r_progress = re.compile("^\*\* Event \#\d+\s+T=(\S+)\s+Elapsed: (\S+)s.+\s(\d+)\% completed")
r_newrun = re.compile("Preparing for running configuration General, run #(\d+)")
r_totalrun = re.compile("Number of runs: (\d+)")

for ini in iniList:
    ini_num += 1
    baselabel = label = labelList.pop(0) 

    f = open("omnetpp.tmp","w")
    f.write("[General]\n")
    f.write("repeat = " + str(options.repeat) + "\n")
    for k in sorted(ini.keys()):
        f.write(k + " = " + ini[k] + "\n")
    f.close();
    has_output = 0

    print "path to CastaliaBint is : " +  pathToCastaliaBin 

    if sys.version_info > (2,7):
        data = subprocess.check_output([pathToCastaliaBin, '-f', 'omnetpp.tmp', '-x', 'General']).split("\n")

        #data = subprocess.check_output(["/home/utar/Desktop/Castalia/CastaliaBin", '-f', 'omnetpp.tmp', '-x', 'General']).split("\n")

    else:
        data = subprocess.Popen([pathToCastaliaBin, '-f', 'omnetpp.tmp', '-x', 'General'], stdout=subprocess.PIPE).communicate()[0].split("\n")

    if len(data) > 6: data = data[6]
    else: 
        data = ""

    m = r_totalrun.match(data)

    print "r_totalrun is : " + str(r_totalrun) 
    if (m):
        runs = "/" + m.group(1)
    else:
        print "WARNING: unable to determine total simulation runs"
        runs = ""

As a result, the output shows me this :

WARNING: unable to determine total simulation runs

The point of focus is here :

if sys.version_info > (2,7):
    data = subprocess.check_output([pathToCastaliaBin, '-f', 'omnetpp.tmp', '-x', 'General']).split("\n")

Having spent some time figuring out the problem, it is learnt that the variable data shows the following output by using print function:

data is [‘[option error] option <-f> not recognized’, ‘{at /src/Console.cpp::parse() [line:134]}’, ”, ”]

I come to realize that CastaliaBin somehow execute the Console.cpp which is located under the src file of Fuzzylite !!!

The variable pathToCastaliaBin is actually a path to /home/utar/Desktop/Castalia/CastaliaBin where CastaliaBin is an executable.

For normal condition which the Fuzzylite library is not included in the Castalia Simulator, when I type CastaliaBin in the command line, it will show as follows: Before Fuzzylite is included

After I link the Fuzzylite with Castalia, it shows : After Fuzzylite is included

As you can see, CastaliaBin somehow executes the code in the Fuzzylite !!!

So I wish somebody can lend me a helping hand. I would appreciate it very much. Thanks in advance !!!

Yeon Tan
  • 21
  • 1

2 Answers2

0

Good work explaining your problem in full, and investigating it yourself.

From the output you get, it seems that when you run makemake to built Castalia, it builts fuzzylite and CastaliaBin basically runs a command line tool for the fuzzylite library. Obviously this is not what you want.

Make sure that:

  • Before building Castalia, you built fuzzylite according to the installation instruction of this library. If done successfully you should be able to find a file name libfuzzylite.a or libfuzzylite.so in the fuzzylite directory (or wherever else the installation process places it.

  • Notice where this library file is located (which dir) and use this dir with the -L switch. Maybe the library is not in release/bin/

  • Find the header-files directory and use this with the -I switch. Do not include the whole fuzzylite directory. Looking at Fyzzylite's Github repo it seems that the header directory is fuzzylite/fuzzylite/fl/

Finally here's general info about compiling static libraries in C, so you can get a better perspective. I suspect Fuzzylite's installation process hides most of this, but it's good to know the general principles.

Thanassis
  • 604
  • 7
  • 16
0

double check the Fuzzylite project you include (.cc and .h) Make sure the include files don't have main() function. The main function will conflict with Castalia or Omnetpp project setting