Hey Victor,
Your code looks mostly correct for making a ReportLidarDataMessage. I'll assume for now that your definition of that message is correct (one gotcha is to make sure you are allocating memory for the ranges member which you are memcpy'ing into!). One thing that I see missing is that you are not setting the values of the message->source and message->destination fields. These JAUS address fields are necessary to properly route your message to the proper receiving component. You can see examples of how this is done in the
Sending & Receiving Messages Tutorial.
With respect to your other question, you will need some function in your receiving component which is designed to receive your ReportLidarDataMessage. OpenJAUS provides two methodologies for this. The first is the callback function specifically attuned to a particular message command code. This is setup using the function:
| Code: |
void ojCmptSetMessageCallback(OjCmpt ojCmpt, unsigned short commandCode, void (*messageFunction)(OjCmpt, JausMessage));
|
The other method which can be used is to setup a single function which will be called whenever a callback function without the specified command code is found. This is setup using the function:
| Code: |
void ojCmptSetMessageProcessorCallback(OjCmpt ojCmpt, void (*processMessageFunction)(OjCmpt, JausMessage));
|
You can see a good example of this kind of callback function in the pd.c file which is included in the ojVehicleSim project. This function uses a large switch statement to determine behavior based on the message's command code.
Hopefully that information helps!
~Danny