Unknown hook 'FMUExportTestingMode'. Either no such hook is registered or the module registering the hook is currently not loaded.

I'm trying to run a script that generates FMUs using the MATLAB function exportToFMU. I ran it successfully many times yesterday. When I started MATLAB today and ran my script I got this error message:
Error using GenerateFMUs (line 12)
Unknown hook 'FMUExportTestingMode'. Either no such hook is registered or the module registering the hook is currently not loaded.
The code I use to generate the FMUs:
exportToFMU(modelName,'FMIVersion','2.0','FMUType','CS', 'CreateModelAfterGeneratingFMU', 'off', 'supportMultiInstance', 'on', 'SaveDirectory', outputFolder, 'FMUName', fmuName64Bit)
exportToFMU(modelName,'FMIVersion','2.0','FMUType','CS', 'CreateModelAfterGeneratingFMU', 'off', 'supportMultiInstance', 'on', 'SaveDirectory', outputFolder, 'Generate32BitDLL', 'on', 'FMUName', fmuName32Bit)
UPDATE 1:
If I open and close Simulink once, the error goes away and I am able to generate FMUs.
UPDATE 2:
Added code example.

2 Comments

Sorry, can't share the model. It's a simple model containing a single 'MATLAB Function' block and some input- and output-ports.
I'm pretty sure that the model doesn't matter. It looks like something is beeing initialized when Simulink is started. Probably something in the ' FMU Builder for Simulink® support package'.

Sign in to comment.

 Accepted Answer

The solution is to call load_system() before calling exportToFMU():
load_system(modelName);
exportToFMU(modelName,'FMIVersion','2.0','FMUType','CS', 'CreateModelAfterGeneratingFMU', 'off', 'supportMultiInstance', 'on', 'SaveDirectory', outputFolder, 'FMUName', fmuName64Bit)
exportToFMU(modelName,'FMIVersion','2.0','FMUType','CS', 'CreateModelAfterGeneratingFMU', 'off', 'supportMultiInstance', 'on', 'SaveDirectory', outputFolder, 'Generate32BitDLL', 'on', 'FMUName', fmuName32Bit)

More Answers (0)

Categories

Products

Release

R2024b

Asked:

on 21 Nov 2024

Answered:

on 21 Nov 2024

Community Treasure Hunt

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

Start Hunting!