Minwoo Kim
Minwoo Kim

Reputation: 510

APP: Error: Got Self Message of unknown kind

I'm using Veins 5.0 framework version. Each node sends a self-message to send its own defined message to other nodes.

However, the following error log is output on the node. The error is output, but the following code seems to run fine.

APP: Error: Got Self Message of unknown kind! Name: mR_TQ Event

The code part of each file is structured as follows.

RSU.h

...
enum ApplMessageKinds
{
     SEND_FRTQ_EVT,
     SEND_ENTP_EVT,
     SEND_ENTC_EVT, 
     SEND_MRTQ_EVT
};
...

RSU.cc

...
void RSU::initialize(int stage)
{
    if(stage == 0)
    {
         ...
         frtqMsg = new cMessage("FR_TQ MSG", SEND_FRTQ_EVT);
         entpMsg = new cMessage("EN_TP MSG", SEND_ENTP_EVT);
         mrtqMsg = new cMessage("mR_TQ MSG", SEND_MRTQ_EVT);
    }
    else if(stage == 1)
    {
         if(frtqMsg -> isScheduled()) { cancelEvent(frtqMsg); }
         else { scheduleAt(simTime() + 3.0, frtqMsg);

         if(entpMsg -> isScheduled()) { cancelEvent(entpMsg); }
         else { scheduleAt(simTime() + 2.0, entpMsg);

         if(mrtqMsg -> isScheduled()) { cancelEvent(mrtqMsg); }
         else { scheduleAt(simTime(), mrtqMsg);
    }
}

void RSU::handleSelfMsg(cMessage* msg)
{
    DemoBaseApplLayer::handleSelfMsg(msg);
    switch(msg -> getKind())
    {
         case SEND_FRTQ_EVT:
         {
              ...
              break;
         }
         case SEND_ENTP_EVT:
         {
              ...
              break;
         }
         case SEND_MRTQ_EVT:
         {
              ...
              break;
         }
    }
}

Many nodes send and receive messages at the same time, but is this relevant? I think there is no grammatical problem, but I don't understand why the problem occurs.

Upvotes: 1

Views: 87

Answers (1)

Jerzy D.
Jerzy D.

Reputation: 7002

The mentioned error comes from DemoBaseApplLayer::handleSelfMsg(msg). Involving this method must be done only when in your switch the matched kind is not found, i.e.:

void RSU::handleSelfMsg(cMessage* msg)
{
    switch(msg -> getKind())
    {
         case SEND_FRTQ_EVT:
         {
              ...
              break;
         }
         case SEND_ENTP_EVT:
         {
              ...
              break;
         }
         case SEND_MRTQ_EVT:
         {
              ...
              break;
         }
         default: {
            DemoBaseApplLayer::handleSelfMsg(msg);
            break;
         }

    }
}

Upvotes: 2

Related Questions