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';endcalllib(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!
Best Answer