-1

I have to build a bit different message set. Thus I had to drift away from DemoBaseAppLayer and had to use directly BaseApplLayer. My ned files are almost sane, as provided by Vienes. I have to build App ned, used Car and Scenario from Viens. I subscribe to BaseMobility::mobilityStateChangedSignal. Methods like handlePositionUpdate and handleSelfMessage work fine. They work fine. They build a message and send it down.

However, handleLowerMessage does not get activated even once. What could I have missing? Your thoughts will be appreciated.

Minimal Reproducibale code

`
#ifndef BSMAPP_H_
#define BSMAPP_H_

#include <map>
#include "veins/modules/world/annotations/AnnotationManager.h"
#include "veins/base/modules/BaseApplLayer.h"
#include "veins/modules/utility/Consts80211p.h"
#include "veins/modules/messages/BaseFrame1609_4_m.h"
#include "veins/base/connectionManager/ChannelAccess.h"#include"veins/modules/mac/ieee80211p/DemoBaseApplLayerToMac1609_4Interface.h"
#include "veins/modules/mobility/traci/TraCIMobility.h"
#include "veins/modules/mobility/traci/TraCICommandInterface.h"
namespace veins {

using veins::AnnotationManager;
using veins::AnnotationManagerAccess;
using veins::TraCICommandInterface;
using veins::TraCIMobility;
using veins::TraCIMobilityAccess;
//using namespace Veins;

class BSMApp: public BaseApplLayer {

public:

    BSMApp();
    virtual ~BSMApp() override;

    void initialize(int stage) override;
    void finish() override;
    void receiveSignal(cComponent* source, simsignal_t signalID, cObject* obj,
            cObject* details) override;
    enum BaseApplMessageKinds {
        SEND_BEACON_EVT,
        //SEND_WSA_EVT
    };
protected:
bool isSelfMsgSent;
void handleSelfMsg(cMessage* msg) override;
virtual void handleLowerMsg(cMessage* msg) override;
virtual simtime_t computeAsynchronousSendingTime(simtime_t interval, ChannelType chantype);
cMessage* sendBeaconEvt;
virtual void handlePositionUpdate(cObject* obj) ;
TraCIMobility* mobility;
    TraCICommandInterface* traci;
    TraCICommandInterface::Vehicle* traciVehicle;

    AnnotationManager* annotations;
    DemoBaseApplLayerToMac1609_4Interface* mac;
}`

and cc file

  `using namespace veins;
    Define_Module(veins::BSMApp);
    void BSMApp::receiveSignal(cComponent* source, simsignal_t signalID, cObject* obj,
                cObject* details){
        //EV_DEBUG << "BSMApp::receiveSignal start " << endl;
        EV << "BSMApp::receiveSignal start " << endl;
        cout<< "BSMApp::receiveSignal start"<<endl;
        Enter_Method_Silent();
            if (signalID == BaseMobility::mobilityStateChangedSignal) {
                handlePositionUpdate(obj);
                EV_DEBUG << "BSMApp::receiveSignal updated position " << endl;
            }else{
                EV_DEBUG << "BSMApp::receiveSignal NOT of type mobility state change signal " << endl;
            }
            EV_DEBUG << "BSMApp::receiveSignal end " << endl;
    }
    void BSMApp::initialize(int stage){
    //Almost same as Demo App
    }

    void BSMApp::handleLowerMsg(cMessage* msg) {
    cout << "BSMApp::handleLowerMsg start " << endl;
    }
    void BSMApp::handleSelfMsg(cMessage* msg) {
    cout << "BSMApp::handleSelfMsg start " << endla
    isSelfMsgSent=true;;
    }
    void BSMApp::handlePositionUpdate(cObject* obj) {
    if(!isSelfMsgSent){
            cout<<"Trying to set isSelfMsgSent"<<endl;
           this->handleSelfMsg(sendBeaconEvt);
    }
    }`

Thank you. Regards, sj

gmusjha
  • 39
  • 5
  • 1
    Might be a simple issue of getting method overloading of C++ classes wrong. Can you provide a ? – Christoph Sommer Jan 31 '20 at 15:04
  • @ChristophSommer I updated the question with a minimal example. One observation is when I test sumo configuration with sumo individually it works. When it is loaded with veins, it does not load all vehicles it just loads one vehicle. Is there some thing that I shoud do – gmusjha Jan 31 '20 at 17:00
  • This is highly unlikely. You might be loading a different configuration file than you think. Also: Which version of Veins are you using? – Christoph Sommer Jan 31 '20 at 17:27
  • I am using veins 5.0. I use launch d file that is referenced to omnet.ini. Due to this I can see 'Got CMD_FILE_SEND with data " ' on output of sumo-launchd.py. This configuration file is the one which I used to run on sumo without using viens and it run fine. – gmusjha Jan 31 '20 at 18:19
  • From the log file you sent me it seems like you are only simulating a little bit more than the first two seconds. Maybe no more cars are starting in this short interval. – Christoph Sommer Jan 31 '20 at 18:53
  • I think I just sent a small piece of log. As such in my omnetpp.ini file, it is limit is specified as sim-time-limit = 20000s. Do you think it is very small? – gmusjha Jan 31 '20 at 19:11
  • Seems like I cannot help you. I give up. – Christoph Sommer Jan 31 '20 at 19:16
  • You are the most knowledgeable in this area. I am learning. We might have to find a cause of it beneficial to everyone. – gmusjha Jan 31 '20 at 19:28

1 Answers1

1

I guess the answer to the question lies in the first answer my @Christoph Sommer . I realized the sendDown method in handleSelfMsg does not get called due to previous boolean expression. I fixed this issue, and things start to work.

gmusjha
  • 39
  • 5