Correct way to obtain memory map in a real time bundle.

Hello Community,

as the topic says: Correct way to obtain memory map in a real time bundle.
How can we do this?

Is there a way to use something like this?:
member = std::shared_ptr<comm::datalayer::IMemoryUser>();
DatalayerFactory->openMemory(member , "fieldbuses/ethercat/master/instances/ethercatmaster/realtime_data/output");
member ->getMemoryMap(data);

Or do we need to use readAsync(...)

What's the best practice?

Sincerely Elleshar

 

Best reply by nickH

Hi, 

be aware of the moment when you call:

result = output_led->getMemoryMap(data_led);

When you call this code when the scheduler is still in config-mode, the EtherCat Data may not be valid.

 

For a quick and dirty workaround you can try to read it in until you get a valid memory map (when your scheduler is running). 

 

do
{
    std::this_thread::sleep_for(std::chrono::milliseconds(100));
    result = output_led->getMemoryMap(data_led);
} while (comm::datalayer::STATUS_FAILED(result));

 

But be sure you have deactivated your watchdog before you try this. 

 

Best regards

Nick

View original
3 replies