Device Driver Block BUS output from C++ map

2 ビュー (過去 30 日間)
Lino
Lino 2023 年 7 月 13 日
編集済み: Lino 2023 年 7 月 26 日
Hi.
We developed a device driver following the guidelines at https://nl.mathworks.com/help/supportpkg/raspberrypi/device-driver-blocks.html
We developed the C function to be called which, after querying the device, returns a map<string, double> (basically a bus with signal names and values).
The function has been tested (on a standalone program built on the RPI) and it works correctly.
What it's not clear is how to invoke correctly the function that we wrote so that matlab can correctly interpret the returned data.
In other words: if my function returns a map can it be called through coder.ceval? Do I need to use easier types?
Any help appreciated.
Thanks in advance.

回答 (1 件)

Supraja
Supraja 2023 年 7 月 26 日
When using coder.ceval in MATLAB, the function being called should have a C-compatible signature and return type. If your function returns a MATLAB containers.Map object, which is not a C-compatible type, you cannot directly call it using coder.ceval.
You can refer to the below documentation link of “container.Map” for further reference.
https://www.mathworks.com/help/matlab/ref/containers.map.html?s_tid=doc_ta
  1 件のコメント
Lino
Lino 2023 年 7 月 26 日
編集済み: Lino 2023 年 7 月 26 日
Hi Supraja. Thanks for your reply.
Actually the function being called returns a std::map (C++ type) which is the conceptually equivalent of a matlab dictionary ( https://nl.mathworks.com/help/matlab/ref/dictionary.html )
It's not completely clear to me what C++ types are automatically mapped to something native in Matlab and which do not.
For example I saw that the webread (from a .json file) maps automagically the json content to a matlab structure. In the same way I would expect that standard C++ types (like std::map, std::vector, std::array) would be mapped automatically to something useful in matlab.
Is there some sort of guide somewhere which tells the user which types are supported and into which matlab types are they converted?
(If the dictionary/map can't be used out of the box I'll rather build a json, return it as string and convert it to a structure inside matlab)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMATLAB Support Package for Raspberry Pi Hardware についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by