Using calllib inside MATLAB Function
이전 댓글 표시
Hello together,
previously, I included an external C libary via callib. As a result, I can call the external commands from there in usual MATLAB scripts.
Now, I want to call the external commands from the C libaray periodically with every time step of my Simulink model. So I have tried to call these commands within a MATLAB function. Unfortunately, I get the following error message:
Function 'calllib' not supported for code generation. Function 'write2ByteTxRx.m' (#70.1182.1264), line 35, column 1: "calllib(lib_name, 'write2ByteTxRx', port_num, protocol_version, id, address, dat" Launch diagnostic report.
From my perspective, the problem is the usage of calllib inside the external function I want to call from the C library:
function [] = write2ByteTxRx( port_num, protocol_version, id, address, data )
lib_name = '';
if strcmp(computer, 'PCWIN')
lib_name = 'dxl_x86_c';
elseif strcmp(computer, 'PCWIN64')
lib_name = 'dxl_x64_c';
elseif strcmp(computer, 'GLNX86')
lib_name = 'libdxl_x86_c';
elseif strcmp(computer, 'GLNXA64')
lib_name = 'libdxl_x64_c';
elseif strcmp(computer, 'MACI64')
lib_name = 'libdxl_mac_c';
end
calllib(lib_name, 'write2ByteTxRx', port_num, protocol_version, id, address, data);
end
Does anyone know how I could avoid this problem? Actually, I don't want to create code. Basically, I would like to use external C functions periodically inside a Simulink model. That's why I have tried to use a MATLAB Function. I already thougth about MATLAB Systems - but they also use functions inside which may cause the same problem I have right now.
Thank you very much in advance!
댓글 수: 3
Walter Roberson
2020년 1월 23일
coder.ceval
https://www.mathworks.com/help/simulink/slref/coder.ceval.html
Jonas Walter
2020년 1월 23일
Ryan Livingston
2020년 1월 23일
Also the C caller block could be of interest:
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 C Shared Library Integration에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!