Can Simulink access data that was written by an imported FMU?

4 views (last 30 days)
Hi folks,
I have a very specific problem involving an imported FMU in Simulink (Version 9.0, Matlab R2017B). I am not new to Matlab but that topic is pretty new to me. The FMU works as intended and I am not allowed to share the source code or any library files but I can provide a short explanation. The FMU takes information provided by a CAN Bus and calculates data about some detected objects. Let's say speed and dimensions of a car, bike and so on. This data is obviously stored somewhere. The output of the FMU delivers 3 integer values. Two of them can be decoded into the memory address of the written data and the third integer symbolises the number of bytes that were written.
So I included an S-Function which executes C++ Code to calculate the address (I used the legacy code tool for that). The code was already compiled and tested. A simple display block confirms the right value of the address. So I guess I can eliminate this as possible error. Obviously I would like to read the stored data in the memory via the given address. Therefore I set up another S-Function block with C++ Code to read data from the address. But at this point my model crashes. I am thinking it's a problem with permission to read/write memory that is reserved by other processes. Meaning that calling and executing C++ Code (or an FMU block) is treated as a separate process and therefore these processes are not sharing the same allocated memory during a simulation. Is my understanding about that right? So I was looking for a possibility to catch any data that is written during a simulation in Simulink. I even looked into methods to create pointers that access memory allocated by other processes running on a windows system. But I think that is a little over the top and not really a good solution. Especially when trying to create a solution for different environments. In reality this program would run on a embedded controller, where accessing memory like this is pretty common.
Right now I think the only way to get the data is to change the FMU and direct the information to an output. Unfortunately that is not an option -.- I am sorry about my english as i am not a native.
Thank you for your time and help!
Michael

Answers (0)

Products


Release

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!