Clear Filters
Clear Filters

Why am I getting plugin failure while debugging Can Receive Block's generated C code?

5 views (last 30 days)
Hi,
I'm trying to implement a CAN Unpack code to my C++ based ROS project and I'm using Vehicle Netwotk Toolbox to receive CAN msg from kvaser device. Following blocks are basicly simulink side of my project and the extract message subsytem block only include the CAN Unpack block.
I generated C code of this block and integrated the code to my project. When the code run it gives "Failure to load the requested plugin: libmwlibmwcanslconverter.so." error and doesn't start the CAN Receive functions. I found source of the error at the following line of code in the initializing function. It gives the error after "LibCreate_CANReceive" is called. I didn't change anything on the generated code just added some printf to find where it gives error.
* Model initialize function */
void can_reciever_initialize(void)
{
/* Registration code */
/* initialize real-time model */
(void) memset((void *)can_reciever_M, 0,
sizeof(RT_MODEL_can_reciever_T));
/* block I/O */
(void) memset(((void *) &can_reciever_B), 0,
sizeof(B_can_reciever_T));
/* states (dwork) */
(void) memset((void *)&can_reciever_DW, 0,
sizeof(DW_can_reciever_T));
{
real_T stdIDsEnd;
real_T stdIDsStart;
int32_T bitParams[4];
int32_T idMaskParams[4];
uint32_T extIDs;
uint32_T stdIDs;
char_T *sErr;
/* SystemInitialize for Atomic SubSystem: '<Root>/Can Message' */
/* Start for S-Function (svntcanreceive): '<S1>/CAN Receive' */
sErr = GetErrorBuffer(&can_reciever_DW.CANReceive_CANReceive[0U]);
CreateHostLibrary("libmwslhostlibcanreceive.so",
&can_reciever_DW.CANReceive_CANReceive[0U]);
if (*sErr == 0) {
bitParams[0U] = 1;
bitParams[1U] = 5;
bitParams[2U] = 2;
bitParams[3U] = 1;
stdIDs = MAX_uint32_T;
extIDs = MAX_uint32_T;
stdIDsStart = 0.0;
stdIDsEnd = 0.0;
idMaskParams[0U] = 0;
idMaskParams[1U] = 2047;
idMaskParams[2U] = 0;
idMaskParams[3U] = 536870911;
LibCreate_CANReceive(&can_reciever_DW.CANReceive_CANReceive[0U], "kvaser",
"libmwslkvaserwrapper.so", "Kvaser Leaf Light v2",
88054, 48, 1, 1, "libmwcanslconverter",
"libmwkvasercanlibplugin", 500000.0, &bitParams[0U],
0, 0, &stdIDs, 1, 0, &extIDs, 1, &stdIDsStart,
&stdIDsEnd, 1, &idMaskParams[0U], 0);
// printf(sErr);
}
if (*sErr == 0) {
LibStart(&can_reciever_DW.CANReceive_CANReceive[0U]);
// printf(sErr);
}
if (*sErr != 0) {
rtmSetErrorStatus(can_reciever_M, sErr);
rtmSetStopRequested(can_reciever_M, 1);
printf(sErr); // It gives the error here.
}
/* End of Start for S-Function (svntcanreceive): '<S1>/CAN Receive' */
/* End of SystemInitialize for SubSystem: '<Root>/Can Message' */
}
}
I also checked entire matlab and project's files there is "libmwcanslconverter.so" instead of "libmwlibmwcanslconverter.so" and I added that shared library's file path to project's cmake file. Even so nothing changed still gives same exact error.
target_link_libraries(c_simulink_can ~/catkin_ws/src/c_simulink_can/include/can_kvaser/R2021a/toolbox/vnt/vnt/private/glnxa64/libmwcanslconverter.so)
Lastly, I use a Linux device and MATLAB R2021A to build up and VS code to compile my project.
Thanks in advance.
  1 Comment
Celil Sincanli
Celil Sincanli on 1 Mar 2022
Edited: Celil Sincanli on 1 Mar 2022
I tried to solve the problem by adding following line to cmake.list but it didn't also work.
FIND_LIBRARY(MY_LIB NAMES library
PATHS /path/to)
TARGET_LINK_LIBRARIES(program ${MY_LIB})
I solved the problem just adding .so files with their full path:
LibCreate_CANReceive(&can_reciever_DW.CANReceive_CANReceive[0U], "kvaser",
"libmwslkvaserwrapper.so", "Kvaser Leaf Light v2",
88054, 48, 1, 1, "~/catkin_ws/src/c_simulink_can/include/can_kvaser/R2021a/toolbox/vnt/vnt/private/glnxa64/libmwcanslconverter.so",
"~/catkin_ws/src/c_simulink_can/include/can_kvaser/R2021a/toolbox/vnt/vnt/private/glnxa64/libmwkvasercanlibplugin.so", 500000.0, &bitParams[0U],
0, 0, &stdIDs, 1, 0, &extIDs, 1, &stdIDsStart,
&stdIDsEnd, 1, &idMaskParams[0U], 0);

Sign in to comment.

Answers (0)

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!