0

I am working on a project where an RSU sends beacons to the cars in its range .When this beacon is received by the car it should send its id back to the RSU.I made a custom message file with just the vehicle id in it.This is how i am handling the beacons now.

  void MyVeinsApp::onBSM(DemoSafetyMessage* bsm)
{

  findHost()->getDisplayString().setTagArg("i", 1, "green");
  if(sentMessage==false){
       sendDown(bsm);
       //scheduleAt(simTime() + 2 + uniform(0.01, 0.2), wsm->dup());
        sentMessage=true;
  }

} This does not work for me at all.Is there any way I can send messages from cars to RSU?

Sreeram M
  • 140
  • 10

1 Answers1

1

I am not an expert but i recently started working on a similar project with yours. So your message includes a parameter like, let say, vehicle_id and upon receiving a beacon you have to send the message to the RSU with the id include. To do such thing you have to first of all fill the message with the vehicle id like

bsm->setVehicle_id(findHost()->getIndex());

When you create a new message file with variables inside it and then building it the program also creates the get() and set() functions in order to handle those parameters.

Now for the RSU to simply acquire the message variable you have sent it must call the get() function like:

RSU_vehicle_id=wsm->getVehicle_id();

So now you have a variable that includes the received vehicle node id. I highly suggest you to offer a couple of day just to understand the principles behind the Veins tutorial and how it handles all its aspects.

TZerK44
  • 28
  • 4
  • Thank you for your reply.I am working with the default MyVeinsApp.cc.The onBSM function responds to the beacons.So if design a new message lets say `testmsg.msg` with the `vehicle_id` in it should i also change the argument to `(testmsg* bsm)` and then do it.I understand the .h files also needs changing.Also how do i send the message.There is no animation shown when i used the `sendDown()` method.Please do help.Thanks again – Sreeram M Jan 05 '21 at 04:50
  • To get arguments from your message file you firstly invoke the message file like: `testmsg* bsm = new testmsg();` To make it work dont forget to include your msg file in your MyVeinsApp like: `#include "veins/testmsg_m.h" `make sure to put the correct root. Also you have to prepare the message to be filled by using the `populateWSM(bsm);` So by doing that you can get information or add to your message file in order to sent it by using the `set()` and `get()` functions. So to send a message you have to use the `sendDown();` function, or the `scheduleAt();` which postpones the message. – TZerK44 Jan 05 '21 at 17:31
  • Thank You very much for your help – Sreeram M Jan 05 '21 at 17:45
  • Do you use the omnet++ IDE??? Because by Ctr+click on all the functions it will prompt you to the origin file which may include description about it. Also makes it much easier to edit your code. – TZerK44 Jan 05 '21 at 18:04
  • I was not aware about this feature .I am a newbie in omnet++.Thanks a lot for your time. – Sreeram M Jan 05 '21 at 18:25