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

Unable to export S-Function model to FMU with release 2.8 #203

Closed
benplay2 opened this issue Aug 15, 2020 · 4 comments
Closed

Unable to export S-Function model to FMU with release 2.8 #203

benplay2 opened this issue Aug 15, 2020 · 4 comments
Labels
bug Something isn't working RTWSFCN This issue is related to the S-Function based FMU export

Comments

@benplay2
Copy link

benplay2 commented Aug 15, 2020

I was able to export S-Function Simulink models to FMU using release 2.7, but I am no longer able to with 2.8.

Environment details:

  • Operating system: Windows 10 64bit
  • MATLAB 2016b 64bit
  • For 2.8, I am using cmake as installed by grtfmi_install_cmake. (cmake-3.15.2-win64-x64.zip)

I have been able to reproduce the issue generically with a few simple steps:
(Follow these instructions for both versions 2.7 and 2.8)

  1. Copy required files to a working directory
copyfile(which('sfcndemo_sfun_atol'), pwd);
copyfile(which('sfun_atol.mexw64'), pwd);
  1. Initialize FMIKit
    FMIKit.initialize
  2. Open the model and update build settings
  • open_system('sfcndemo_sfun_atol.slx')
  • Edit model configuration parameters:
    • Solver:
      • Change solver to fixed-step
    • Code Generation:
      • System target file: rtwsfcnfmi.tlc
      • FMI
        • FMI Type: CoSimulation
        • Load S-Functions from binary MEX files: YES
    • Apply and ok
  1. Build the model
    • 2.7 succeeds, but 2.8 fails

Here's the main error message:

Creating library C:/testFMUExport/matlabSfunction2.8/sfcndemo_sfun_atol_sfcn_rtw_fmi/Release/sfcndemo_sfun_atol.lib and object C:/testFMUExport/matlabSfunction2.8/sfcndemo_sfun_atol_sfcn_rtw_fmi/Release/sfcndemo_sfun_atol.exp
sfcn_fmi.obj : error LNK2019: unresolved external symbol sfun_atol referenced in function sfcndemo_sfun_atol_malloc [C:\testFMUExport\matlabSfunction2.8\sfcndemo_sfun_atol_sfcn_rtw_fmi\sfcndemo_sfun_atol.vcxproj]
C:\testFMUExport\matlabSfunction2.8\sfcndemo_sfun_atol_sfcn_rtw_fmi\Release\sfcndemo_sfun_atol.dll : fatal error LNK1120: 1 unresolved externals [C:\testFMUExport\matlabSfunction2.8\sfcndemo_sfun_atol_sfcn_rtw_fmi\sfcndemo_sfun_atol.vcxproj]
@t-sommer t-sommer added bug Something isn't working RTWSFCN This issue is related to the S-Function based FMU export labels Aug 15, 2020
t-sommer added a commit that referenced this issue Aug 17, 2020
@t-sommer
Copy link
Contributor

@benplay2, can you give f0e7963 a try?

@krishnashukla201
Copy link

I got a new issue when trying to export simple model through s-function target for Model Exchange.
I simply create a new enum type BOOL_TYPE and some other typedef to use in my model. So during creation of model_interface.c file it create 2 time case with same value 8 and create 3 time case with value 0.

size_t getCGTypeSize(int typeIndex)
{
switch (typeIndex) {
case 0:
return 8; /* real_T */

case 1:
return 4; /* real32_T */

case 2:
return 1; /* int8_T */

case 3:
return 1; /* uint8_T */

case 4:
return 2; /* int16_T */

case 5:
return 2; /* uint16_T */

case 6:
return 4; /* int32_T */

case 7:
return 4; /* uint32_T */

case 8:
return 1; /* boolean_T */

case 9:
return 0; /* fcn_call_T */

case 10:
return 4; /* int_T */

case 11:
return 8; /* pointer_T */

case 12:
return 8; /* action_T */

case 13:
return 8; /* timer_uint32_pair_T */

case 8:
return 1; /* BOOL_TYPE */

case 0:
return 8; /* TemperatureType */

case 0:
return 8; /* Q16_15_TYPE */

default:
return 0; /* unknown type */
}
}

Error given in Matlab is

model_interface.c
D:\Manmohan\REF\Ref_V6\work\test_func_sfcn_rtw_fmi\model_interface.c(49): error C2196: case value '8' already used [D:\Manmohan\REF\Ref_V6\work\test_func_sfcn_rtw_fmi\test_func.vcxproj]
D:\Manmohan\REF\Ref_V6\work\test_func_sfcn_rtw_fmi\model_interface.c(52): error C2196: case value '0' already used [D:\Manmohan\REF\Ref_V6\work\test_func_sfcn_rtw_fmi\test_func.vcxproj]
D:\Manmohan\REF\Ref_V6\work\test_func_sfcn_rtw_fmi\model_interface.c(55): error C2196: case value '0' already used [D:\Manmohan\REF\Ref_V6\work\test_func_sfcn_rtw_fmi\test_func.vcxproj].

please let me know the solution.

@t-sommer
Copy link
Contributor

I simply create a new enum type BOOL_TYPE and some other typedef to use in my model. So during creation of model_interface.c file it create 2 time case with same value 8 and create 3 time case with value 0.

@krishnashukla201, this problem seems unrelated to #203. Please open a new issue and provide steps to reproduce it.

@benplay2
Copy link
Author

Yes @t-sommer, f0e7963 fixed the issue. Thanks for the quick work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working RTWSFCN This issue is related to the S-Function based FMU export
Projects
None yet
Development

No branches or pull requests

3 participants