About legacy code: can you go from labview to simulink via dlls?

23 次查看(过去 30 天)
Hello,
I am having a problem here generating dlls from LabView to test models in Simulink.
LabView only generates a .h file in addition to the .dll file (SharedLib.dll). My .h file looks like this (SharedLib.h):
#include "extcode.h"
#pragma pack(push)
#pragma pack(1)
#ifdef __cplusplus
extern "C" {
#endif
typedef uint16_t Enum;
#define Enum_Inicio 0
#define Enum_Suma 1
#define Enum_Resta 2
#define Enum_Fin 3
/*!
* DLL_Example
*/
double __cdecl DLL_Example(Enum Enum, double Numero1, double Numero2);
MgErr __cdecl LVDLLStatus(char *errStr, int errStrLen, void *module);
void __cdecl SetExecuteVIsInPrivateExecutionSystem(Bool32 value);
#ifdef __cplusplus
} // extern "C"
#endif
#pragma pack(pop)
My MATLAB code to generate the Simulink block is this one:
def = legacy_code('initialize');
def.SFunctionName = 'DLL_Example';
def.SourceFiles = {'SharedLib.h'};
def.OutputFcnSpec = 'double DLL_Example(Enum Enum, double Numero1, double Numero2)'; %Ver si fallo enum con int32
def.SourceFiles = {'SharedLib.dll'};
legacy_code('generate_for_sim', def)
legacy_code('slblock_generate', def)
The errors I get are these:
Error using legacycode.LCT/generatesimfiles
Cannot find a valid lhs expression in the function specification (only scalar output can be specified as the return of the function):
--> double DLL_Example(Enum Enum, double Numero1, double Numero2)
Error in legacycode.LCT.legacyCodeImpl
Error in legacy_code (line 103)
[varargout{1:nargout}] = legacycode.LCT.legacyCodeImpl(action, varargin{1:end});
Error in dll_example (line 17)
legacy_code('generate_for_sim', def)
Please, if you know how to resolve this issue I would be glad to hear it.
Thank you in advance!

回答(1 个)

Mark McBroom
Mark McBroom 2024-11-2,20:38
  2 个评论
Julio Magro
Julio Magro 2024-11-11,5:44
Thank you but this is not what I would like to do. I want to take the path LabView->Simulink and not the other way around.
Mark McBroom
Mark McBroom 2024-11-11,10:55
Sorry I misread your question. legacy code tool requires that you use the terms "u", "y" and "d" to help it figure out if an argument in your function prototype is an input, output or state. So, change to this.
'double y1 = DLL_Example(int16 u1, double u2, double u3)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Programmatic Model Editing 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by