0

I'm trying to create a new thread in my Veins simulation that can use the Veins::TraCICommandInterface::Vehicle*, however I'm not able to achieve this goal.

I use a class EVData that should be able to use the functionality, however it gives an error in SUMO about not implemented commands.

Here is the class that has access to the Veins::TraCICommandInterface::Vehicle*:

class EVData : public BaseWaveApplLayer
{
    public:
        simtime_t lastDroveAt;
        bool sentMessage;
        TraCIMobility::Statistics statistics;
        simtime_t stoppedAt, startedAt, lastUpdate;
        bool isOver;
        void printSomething()
        {
            std::cout<< "data que eu quero: " << traciVehicle->getLaneId() << "\n";
        }

};

and here is the thread code:

void socketThread(EVData* evD/*, Veins::TraCICommandInterface::Vehicle* tv*/)
{
    std::cout << "sou uma thread nova \n";
    while(!evD->isOver)
    {
        //std::cout << "";
         evD->printSomething();
    }
}

The threading works so I have no clue how to solve this issue, can anyone help me?

  • Most likely, your code is wrong. You can try running your program on Linux using a memory access debugger like `valgrind` or you can try running your source code through a static code analysis tool like clang's `scan-build`. – Christoph Sommer May 15 '19 at 10:44
  • As a second comment, if you are really using multiple threads of execution in your simulation (rather than merely simulating a multi-threaded system), I can only warn against attempting to so without good reason. – Christoph Sommer May 15 '19 at 10:45
  • Thanks for the quick answer! :) Do you have any idea on how to access the traciVehicle through a new thread, created from the one that has access to it? Regarding your comment, I need to use external software to create new communications, so I need sockets and a thread that is constantly listening for those messages – precisoDeTirarDuvidas May 15 '19 at 10:55
  • @ChristophSommer, I don't know how SO works, so forgive me if you received the notification and I'm tagging you again – precisoDeTirarDuvidas May 15 '19 at 12:20

0 Answers0