I want to create an inet packet and the packet content needs to be of c++ type struct which is defined outside the message file. I have done this earlier to define a .msg file derived from cMessages in OMNeT like this:
cplusplus{{
#include "util/DataTypes/StateDataTypes.h"
}};
struct StateWithCovariance;
message WirelessMsg
{
StateWithCovariance VehicleLocation;
}
Now I am working with simu5g and want to send the same msg content as an inet packet. I know the inet Packet data structure builds on top of the data structure chunks. Thus I followed how it's done in inet and when I try to create the packet I can't use the same above format to define the packet because then
cplusplus{{
#include "inet/common/INETDefs"
#include "inet/common/packet/chunk/chunk"
}}
class WirelessAppPacket extends inet::FieldsChunk
{
simtime_t payloadTimestamp;
StateWithCovariance VehicleLocation;
}
wouldn't work and gives me the error:
modules/communication/NR/App/WirelessAppPacket.msg:34: Error: 'WirelessAppPacket': unknown base class 'inet::FieldsChunk',
available classes' (inet::StateWithCovariance:1)' ,'(omnetpp::cMessage:4)', '(omnetpp::cNamedObject:5)','(omnetpp::cObject:3)','(omnetpp::cOwnedObject:4)','(omnetpp::cPacket:4)'
if I give it as
import inet.common.INETDefs;
import inet.common.packet.chunk.Chunk;
class WirelessAppPacket extends inet::FieldsChunk
{
simtime_t payloadTimestamp;
StateWithCovariance VehicleLocation;
}
it wouldn't give any error with regards to chunks, if I change the message complier to --msg6 in project properties as follows
MSGC:=$(MSGC) --msg6
But it gives me an error with respect to the data type definition as:
modules/communication/NR/App/WirelessAppPacket.msg:28: Error: Type declarations are not needed with imports, try invoking the message compiler in legacy (4.x) mode using the --msg4 option
modules/communication/NR/App/WirelessAppPacket.msg:32: Error: unknown type 'StateWithCovariance' for field 'VehicleLocation' in 'WirelessAppPacket'
The entire code I used look like this
import inet.common.INETDefs;
import inet.common.packet.chunk.Chunk;
cplusplus{{
#include "util/DataTypes/StateDataTypes.h"
#include "modules/vehicle/CommunicationCoordinator.h"
}};
struct StateWithCovariance;
class WirelessAppPacket extends inet::FieldsChunk
{
simtime_t payloadTimestamp;
StateWithCovariance VehicleLocation;
}
If I change the message compiler to --msg4 then I can't define my packet from chunk base class in INET framework and with --msg6 I can't use the data type I want to use.
Is there a way to rectify this issue?
I use OMNeT++ version 5.6.2, INET version 4.2.2 and Simu5G version 1.1.0
This thread explains what to do. Basically you need to change the line
struct StateWithCovariance;
from your last code snippet into
struct StateWithCovariance {
@existingClass;
}
This works with the --msg6
message compiler, so that you can still import INET classes.