Adding new module, class to INET framework

611 views
Skip to first unread message

JS

unread,
Jul 13, 2009, 8:51:16 AM7/13/09
to omnetpp
I have roblem in adding new module to INETManet. I don't know where
why is it shown. This is my second simple module, which I add to
framework - there is everything OK with first one. Now I wan to add
second in the same way and I have problem which I can't fix.

My code is:
header:
#ifndef __RESOURCEPROTOCOL_H__
#define __RESOURCEPROTOCOL_H__

#include <omnetpp.h>

class INET_API ResourceProtocol : public cSimpleModule
{
protected:
virtual void initialize();
virtual void handleMessage(cMessage *msg);
};

#endif

code:
#include "ResourceProtocol.h"

Define_Module(ResourceProtocol);

void ResourceProtocol::initialize()
{
// TODO - Generated method body
}

void ResourceProtocol::handleMessage(cMessage *msg)
{
// TODO - Generated method body
}

And I have error "function definition does not declare parameters"
in .h file at line:
class INET_API ResourceProtocol : public cSimpleModule
These files are in src/experimental/resources directory

Please help me with this problem.
Maybe there is a simple instruction how to ass new modules to
INETMANET in Omnet 4.0 IDE?

JS

unread,
Jul 15, 2009, 6:28:12 AM7/15/09
to omnetpp
I tried one more time and now I have the same error "function
definition does not declare parameters" when I have declaration:
class INET_API ResourceProtocol : public cSimpleModule

but when I delete from this line INET_API:
class ResourceProtocol : public cSimpleModule

it compiles, but when it starts running there is error:
<!> Error during startup: Cannot load library '/home/jasiek/Omnet/
inetmanet-new/src//libinet.so': /home/jasiek/Omnet/inetmanet-new/src//
libinet.so: undefined symbol: _ZTI16ResourceProtocol.

I think that INET_API is needed there, but I don't know why it's not
working. It seems that there isn't seen INET_API macro from this class
- I have no idea why.

Please help

Rudolf Hornig

unread,
Jul 15, 2009, 6:44:49 AM7/15/09
to omn...@googlegroups.com
Sure you need INET_API, but it is defined in INETDefs.h
add

#include "INETDefs.h"

to your header file, as any other modules in INET do.
Rudolf

JS

unread,
Jul 15, 2009, 8:35:16 AM7/15/09
to omnetpp
it's strange beacuse I don't have #include "INETDefs.h" in my first
module
but I added it to this and everything is now compile, but at startup
there is a error:

<!> Error during startup: Cannot load library '/home/jasiek/Omnet/
inetmanet-new/src//libinet.so': /home/jasiek/Omnet/inetmanet-new/src//
libinet.so: undefined symbol: _ZTI16ResourceProtocol.

where ResourceProtocol is the name of my new class/module

what should I do now?

Rudolf Hornig

unread,
Jul 15, 2009, 9:24:12 AM7/15/09
to omn...@googlegroups.com
I'm guessing that you are not linking in the corresponding ResourceProtocol.o file.
You should recreate the makefiles if you have added a new file to INET (run "make makefiles")
If you are building from the IDE, you dont have to do anything. The IDE always regenerates the makefiles.

I would "make clean", and would try to recompile after this.

JS

unread,
Jul 15, 2009, 9:46:22 AM7/15/09
to omnetpp
I found answer: I need to define blank constructor and destructor and
now its working fine :)

Thank You Rudolf

rakez

unread,
Sep 22, 2015, 10:35:01 PM9/22/15
to OMNeT++ Users
Hi Rudolf;
                       I want to send an extra message like wsm message which contains the reputation values of the neighbour nodes. I want to send (broad) this message as soon as the vehicle encounters the accident. 
I tried to modify the veins TraCIDemo11p.cc and other related files but I can not send both the wsm data message and the new message data_rakez message at the same time. Is it possible to send two messages within the TracIDemo11p.cc?
I have attach the code ; Please help me on this issue. Also i would like to know how to know what is inside the data packet. Do i need to install win cap to trace the messages.

I am using omnet++4.4 and veins 3.0 with correspondig SUMO ... 

void TraCIDemo11p::onBeacon(WaveShortMessage* wsm) {
}

void TraCIDemo11p::onData(WaveShortMessage* wsm) {
findHost()->getDisplayString().updateWith("r=8,green"); //Modified=> r=16
annotations->scheduleErase(1, annotations->drawLine(wsm->getSenderPos(), traci->getPositionAt(simTime()), "blue"));

if (traci->getRoadId()[0] != ':') traci->commandChangeRoute(wsm->getWsmData(), 9999);
if (!sentMessage) sendMessage(wsm->getWsmData());
}


    void TraCIDemo11p::sendMessage(std::string blockedRoadId) {
sentMessage = true;
t_channel channel = dataOnSch ? type_SCH : type_CCH;
WaveShortMessage* wsm = prepareWSM("data", dataLengthBits, channel, dataPriority, -1,2);
wsm->setWsmData(blockedRoadId.c_str());
sendWSM(wsm);
}


// ---------------//added data_rakez----------------------------------------------------------
      void TraCIDemo11p::onData1(WaveShortMessage* wsm) {
        findHost()->getDisplayString().updateWith("r=24,green"); //Modified=> r=16
        annotations->scheduleErase(1, annotations->drawLine(wsm->getSenderPos(), traci->getPositionAt(simTime()), "blue"));

        if (traci->getRoadId()[0] != ':') traci->commandChangeRoute(wsm->getWsmData(), 9999);
        if (!sentMessage) sendMessage1(wsm->getWsmData());
      }
      //-------------------------
void TraCIDemo11p::sendMessage1(std::string data_rakezz) {
    sentMessage = true;
    t_channel channel = dataOnSch ? type_SCH : type_CCH;
    WaveShortMessage* wsm = prepareWSM("data_rakezshre", dataLengthBits, channel, dataPriority, -1,2); //data_rakez
    wsm->setWsmData(data_rakezz.c_str());
    sendWSM(wsm);
}
void TraCIDemo11p::receiveSignal(cComponent* source, simsignal_t signalID, cObject* obj) {
    Enter_Method_Silent();
    if (signalID == mobilityStateChangedSignal) {
        handlePositionUpdate1(obj);
    }
    else if (signalID == parkingStateChangedSignal) {
        handleParkingUpdate(obj);
    }
}
//added--------------
void TraCIDemo11p::handlePositionUpdate1(cObject* obj) {
    BaseWaveApplLayer::handlePositionUpdate(obj);

    // stopped for for at least 10s?
    if (traci->getSpeed() < 1) {
        if (simTime() - lastDroveAt >= 10) {
            findHost()->getDisplayString().updateWith("r=16,red");
            if (!sentMessage) sendMessage1(traci->getRoadId());
        }
    }
    else {
        lastDroveAt = simTime();
    }
}

void TraCIDemo11p::sendWSM1(WaveShortMessage* wsm) {
    if (isParking && !sendWhileParking) return;
    sendDelayedDown(wsm,individualOffset);
}


Thank you.
Reply all
Reply to author
Forward
0 new messages