Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simulink Compiler FMU crashes #158

Open
haeuszler opened this issue Feb 11, 2025 · 6 comments
Open

Simulink Compiler FMU crashes #158

haeuszler opened this issue Feb 11, 2025 · 6 comments
Assignees
Labels
question Further information is requested

Comments

@haeuszler
Copy link

Hi everyone,

I'm using the importer example (fmi2_import_cs_test) with an FMU exported from Simulink (R2023a) for co-simulation. Initialization completes successfully, but when I call the step function, a read access violation error occurs. FMUs from other tools work fine, so it appears the problem is specific to FMUs generated by the Simulink compiler.

I've attached a minimal FMU (from a simple Simulink model) for reference.
New_Model_FMU.zip

Has anyone encountered this issue or found a workaround?

Thanks in advance!

@PeterMeisrimelModelon PeterMeisrimelModelon self-assigned this Feb 11, 2025
@PeterMeisrimelModelon PeterMeisrimelModelon added the question Further information is requested label Feb 11, 2025
@PeterMeisrimelModelon
Copy link
Contributor

Hi haeuszler,

I recommend contacting Simulink support instead since you seem to have narrowed it down to be a Simulink exclusive issue?

/Peter

@haeuszler
Copy link
Author

It appears that the issue is specific to the combination of this fmi-library with the Simulink FMU. The same FMU works fine in Hopsan. Notably, Hopsan uses the fmi4c library(https://github.com/robbr48/fmi4c) for FMU import.

@PeterMeisrimelModelon
Copy link
Contributor

Can you share some log output?

If the issue happens within the doStep() call, it is still an issue of the FMU generating tool.

/Peter

@haeuszler
Copy link
Author

haeuszler commented Feb 11, 2025

This is the oputputlog and the access violation

module = FMILIB, log level = VERBOSE: Allocating FMIL context
module = FMILIB, log level = VERBOSE: Detecting FMI standard version
module = FMIZIP, log level = VERBOSE: Unpacking FMU into D:\fmi-library-3.0a4\build\Testing\FmuUnpack\fmila29080
module = FMIXML, log level = VERBOSE: Parsing XML to detect FMI standard version
module = FMIXML, log level = VERBOSE: XML specifies FMI 2.0
module = FMILIB, log level = INFO: XML specifies FMI standard version 2.0
module = FMILIB, log level = VERBOSE: Parsing model description XML
module = FMI2XML, log level = VERBOSE: Parsing XML element fmiModelDescription
module = FMI2XML, log level = VERBOSE: Parsing XML element CoSimulation
module = FMI2XML, log level = VERBOSE: Parsing XML element VendorAnnotations
module = FMI2XML, log level = VERBOSE: Parsing XML element ModelVariables
module = FMI2XML, log level = VERBOSE: Building alias index
module = FMI2XML, log level = VERBOSE: Parsing XML element ModelStructure
module = FMI2XML, log level = VERBOSE: Parsing XML element Outputs
module = FMI2XML, log level = VERBOSE: Parsing XML element InitialUnknowns
module = FMILIB, log level = VERBOSE: Parsing finished successfully
module = FMILIB, log level = INFO: Loading 'win64' binary with 'default' platform types
module = FMICAPI, log level = VERBOSE: Loaded FMU binary from D:\fmi-library-3.0a4\build\Testing\FmuUnpack\fmila29080\binaries\win64\New_Model_FMU.dll
module = FMICAPI, log level = VERBOSE: Loading functions for the co-simulation interface
module = FMILIB, log level = VERBOSE: Successfully loaded all the interface functions
Version returned from FMU: 2.0
module = FMICAPI, log level = VERBOSE: Calling fmi2GetModelTypesPlatform
Platform type returned: default
GUID: {38d05ae2-9ea9-e6b2-11db-89765691047a}
module = FMICAPI, log level = VERBOSE: Calling fmi2SetupExperiment
module = FMICAPI, log level = VERBOSE: Calling fmi2EnterInitializationMode
module = FMICAPI, log level = VERBOSE: Calling fmi2ExitInitializationMode
Ball height Ball speed
module = New_Model_FMU, log level = INFO: [info][FMU status:OK] CommunicationStepSize=0.2, LocalSolverStepSize=0.2
module = New_Model_FMU, log level = INFO: [info][FMU status:OK] Local solver will do 1 steps from t = 0.

Image

In parallel, I'm also trying to get in touch with someone from MATLAB support.

@haeuszler
Copy link
Author

haeuszler commented Feb 19, 2025

@PeterMeisrimelModelon I noticed that the value references in the model desciption are not unique. Might that be part of the problem?

Image

@PeterMeisrimelModelon
Copy link
Contributor

PeterMeisrimelModelon commented Feb 20, 2025

valueReferences are not required to be unique in FMI2, particularly not for variables of different types, here Integer and Real.
At least with respect to the specification, this is not an issue.

/Peter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants