I'm simulating network in Omnet++, with INET framework. I want to get the position (coordination x & y) of node. So I do this code:
cModule *host = getContainingNode(this);
IMobility *mobility = check_and_cast<IMobility *>(host->getSubmodule("mobility"));
... = mobility -> getCurrentPosition();
But, when I ran the simulation, I got this error
check_and_cast(): cannot cast nullptr to type 'inet::IMobility *'
Can you explain to me this error? As I see, if the simulator notify that, so host->getSubmodule("mobility") is nullptr?
By the way, I have define mobilityType in the NED file and include IMobility.h
mobilitysubmodule in your host. Could you show ned file of your host? - Jerzy D.simple Txc like IMobility{parameters:bool isSource = default(false);bool isDest = default(false);string mobilityType = default("StationaryMobility");@display("i=device/hub_vs");@networkNode;gates:inout gate[];}- Khanh LêSubmodule. ButIMobilityis an interface module, it has no gate - Khanh Lê