FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
Dear Community User! We have started the migration process.
This community is now in READ ONLY mode.
Read more: Important
information on the platform change.
11-25-2021 11:45 AM
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
Solved! Go to Solution.
11-25-2021 02:28 PM
Hello Elleshar,
If you want to access the data layer out of a realtime bundle, you have to access the data in the ctrlX Data Layer like it is shown in the datalayer.realtime example. Therefore you use the service provided by the ctrlX Data Layer itself. But you have to register a ServiceDependency to the Data Layer Service in the activator.cpp first.
Please have a look at this thread.
Best regards,
Nick
11-25-2021 02:40 PM - edited 11-25-2021 02:49 PM
Hi Nick,
we are already doing like in the thread you posted.
Exactly like this: https://developer.community.boschrexroth.com/t5/SDK/How-to-access-RT-Data-from-Scheduler-app/m-p/205...
But we are using a node from the Ethercatmaster-App.
Our primary problem is that when we call
result = output_led->getMemoryMap(data_led);
we get an invalid memory map. (DL_RT_INVALIDMEMORYMAP)
our address: std::string ethercatNode = "fieldbuses/ethercat/master/instances/ethercatmaster/realtime_data/output";
Sincerely Elleshar
11-29-2021 02:17 PM - edited 11-29-2021 02:27 PM
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