CATIA-Systems / FMIKit-Simulink

Import and export Functional Mock-up Units with Simulink
Other
161 stars 54 forks source link

Unable to generate FMU from matlab simulink model with FMIKit 3.1 #433

Open naveenjeevanantham opened 1 year ago

naveenjeevanantham commented 1 year ago

I was trying to generate an FMU from an Matlab Simulink model. I am getting an error in S-function

I assigned Code generation target as rtwsfcnfmi.tlc and the fmu type as CoSimulation.

Environment Details:

Error Details :

In addition to that, The same thing I also tried with FMIKit 2.7 version, By this time FMU was generated but the fmu was not working, I checked with FMU checker I got the Below error

      -  Error in S-function (mdlInitializeSizes): Name for parameter file should be a character string
      There is  44 percent of memory in use.
      There are 3764584 total KB of physical memory.
      There are 1716028 free  KB of physical memory.
      There are 356712 total KB of paging file.
      There are 3923160 free  KB of paging file.
      There are 4194176 total KB of virtual memory.
      There are 2096996 free  KB of virtual memory.
      There are 0 free  KB of extended memory.

      Initialised ZFLS-SimStruct with identifier 0
      LibZFLSInterface_setXML_MainParFile: Tried to set NotSet

      ************************************************
      **** Fatal error in BoschAS-CAE-Subfunction ****
      ****** Error Message was written           *****
      ****** Terminating the program             *****
      ************************************************
      Failed to instantiate FMU. The FMU crashed (exception code: UNKOWN_EXEPTION_CODE).
      Error in '[testfmucheck/FMU](matlab:open_and_hilite_hyperlink ('testfmucheck/FMU','error'))' while executing C MEX S-function                            
                 'sfun_fmurun', (mdlStart), at time 0.0.
      Caused by:
      Unexpected Standard exception from MEX file.
      What() is:Failed to instantiate FMU. The FMU crashed (exception code: UNKOWN_EXEPTION_CODE).
chrbertsch commented 1 year ago

We experience an error with ML/SL 2018b and FMI-Kit 3.1 Error: File: rtwsfcnfmi_make_rtw_hook.m Line: 59 Column: 30 Functions cannot be indexed using {} or . indexing.

The problem is, that version = str2double(ver('MATLAB').Version); creates an error in 2018b In 2022b, all works fine.

jbernalr commented 1 year ago

The same error with MATLAB 2022b FMI-Kit 3.1

naveenjeevanantham commented 1 year ago

The issue is related to code generation of s-function parameters. I think the issue is FMIKit is not exporting the s-function input parameters into FMU.

Inputs for ECU_sfun -> 'ZFLSECUEPS50DEV', 'ZFLSECUEPS50DEV.par'. The first param is just the name of file, and the second param is a xml file. So the generated FMU should consist of this file in it.

And also when I checked the generated code, I saw that sfunc params are ZERO. That means It is taking NULL value as input and followed by the error when I tried to run it.

Matlab Version: 2022b FMIKit: 3.1 and the s-function is a binary file of *.mexw64 with no associated source files with us.

Ultimately our requirement would be to include the parameters also with the FMU.

SFunction parameters function :

taking Null parameter.

Figure 2: Generated code from FMIKit