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

조회 수: 16 (최근 30일)
Julio Magro Sastre
Julio Magro Sastre 2024년 10월 22일
댓글: Mark McBroom 2024년 11월 11일 10:55
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