0

I am using sockets for communications in my simulation and for the vehicles, I use the handlePositionUpdate method to check for the received message, since it's a method that it's called a bunch of times. Howerver, once I try to do this in my RSU module, the handlePositionUpdate only runs in the beginning of the simulation and never again, contrary to the vehicle modules which run throughout the simulation. So I'm trying to find a method that works similarly to the handlePositionUpdate on the vehicle modules, but on the RSU side. Thanks for the attention!

1 Answers1

2

If I am not wrong, handlePositionUpdate is called every time a node's position changes. This function cannot be called in your RSU application as its position does not change. Code that reacts to received messages should go in appropriate functions. As an example, the function bellow from the RSU application is called everytime a Basic Safety Message is received.

In TraCIDemoRSU11p.h

virtual void onBSM(BasicSafetyMessage* bsm);

In TraCIDemoRSU11p.cc

// The application has received a message from another car or RSU.
void TraCIDemoRSU11p::onBSM(BasicSafetyMessage* bsm) {
    // Code for handling the message goes here.
}
000102
  • 120
  • 1
  • 8
  • Yes, I understand that. However I'm trying to send messages through sockets, so how could I adapt the onBSM method to something similar that works with any kind of event that I wish? Thanks for the response! – precisoDeTirarDuvidas Aug 12 '19 at 08:43