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
Walter Roberson 2020년 1월 23일
coder.ceval
https://www.mathworks.com/help/simulink/slref/coder.ceval.html
Jonas Walter
Jonas Walter 2020년 1월 23일
Thank you for your answer, Walter!
Ryan Livingston
Ryan Livingston 2020년 1월 23일

댓글을 달려면 로그인하십시오.

 채택된 답변

Jonas Walter
Jonas Walter 2020년 1월 23일

0 개 추천

I solved the problem by using coder.entrinsic. According to my example above, I set:
coder.extrinsic('write2ByteTxRx');
Now, the Simulink model is compling.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 C Shared Library Integration에 대해 자세히 알아보기

질문:

2020년 1월 23일

댓글:

2020년 1월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by