From e5f5acc93512bfa37aab270b00f1c3e8f7fddb4f Mon Sep 17 00:00:00 2001
From: Cristian Galperti <cristian.galperti@epfl.ch>
Date: Fri, 17 May 2019 16:06:46 +0200
Subject: [PATCH] Reusable function shared objet target ok for CAPI

With reusable function ERT target,
found the right code to expose the CAPI mmi data\
structure on the .so interface.
Number of parameters, root inputs and outputs
correctly read in MARTe2 from the generated .so
via CAPI
---
 .../confsettingsmodformmi.txt                     | 15 +++++++++++++++
 .../export_shrlib_def_scd.tlc                     |  2 ++
 2 files changed, 17 insertions(+)
 create mode 100644 test/simulink_codegen_tests/confsettingsmodformmi.txt

diff --git a/test/simulink_codegen_tests/confsettingsmodformmi.txt b/test/simulink_codegen_tests/confsettingsmodformmi.txt
new file mode 100644
index 0000000..557e074
--- /dev/null
+++ b/test/simulink_codegen_tests/confsettingsmodformmi.txt
@@ -0,0 +1,15 @@
+In header file:
+
+#ifndef SCDMACROS
+#define SCDMACROS
+#define UTSTRUCTNAME(NAME) RT_MODEL_##NAME##_T
+#define TSTRUCTNAME(NAME) UTSTRUCTNAME(NAME)
+#define UGETMMIFCN(NAME) NAME##_GetCAPImmi
+#define GETMMIFCN(NAME) UGETMMIFCN(NAME)
+#endif 
+
+In source file:
+rtwCAPI_ModelMappingInfo* GETMMIFCN(MODEL) ( TSTRUCTNAME(MODEL) *rtm )
+{
+  return &(rtmGetDataMapInfo(rtm).mmi);
+}
diff --git a/test/simulink_codegen_tests/export_shrlib_def_scd.tlc b/test/simulink_codegen_tests/export_shrlib_def_scd.tlc
index bc8aa62..4111b8a 100644
--- a/test/simulink_codegen_tests/export_shrlib_def_scd.tlc
+++ b/test/simulink_codegen_tests/export_shrlib_def_scd.tlc
@@ -196,6 +196,8 @@ global:
 %<leadingUs>%<Name>_GetCAPIStaticMap%<trailingSc>
 %endif
 %if FEVAL("isunix")==TLC_TRUE && FEVAL("ismac")==TLC_FALSE
+%<Name>;
+%<Name>_GetCAPImmi;
 mydef;
 local:
 		*;
-- 
GitLab