07-08-2025 10:58 AM
Hello NI community,
I’m working with a cRIO-9040 running NI Linux Real-Time. Following the steps in the links below, I generated a shared library (.so
) from a simple MATLAB script and uploaded it to the cRIO via PowerShell. In LabVIEW, I’m calling it through the Import Shared Library Wizard, but the VI hangs at run time and the cRIO then disconnects. After that, I have to reformat the controller before LabVIEW can connect again.
Hardware: cRIO-9040
OS: NI Linux Real-Time
LabVIEW version: 2023 Q3
.so
As described here:
and
My MATLAB function is:
I want A, x, and y all to be double
1D arrays.
The generated untitled.h is attached below.
scp "C:\path\to\untitled.so" `
admin@IP:/home/lvuser/untitled.so
On the cRIO I verified that the file is at the desired place
ls -l /home/lvuser/untitled.so
gave me
so I imported (I am very unsure which header files I am looking for, but I found these in the matlab and CVI2020 folders)
In the next step I defined my parameters as Arrays as shown:
After generating the VI I get the following report that I can't quite make sense of.
Can anyone do more with the report or already see errors in my execution of the previous steps?
Could the reason be that labview cannot do anything with the parameter types emxArrays? if so, how do I change this?
Thank you in advance for any advice!
—
Best regards,
TCNI
07-08-2025 12:21 PM - edited 07-08-2025 12:29 PM
Those arrays are Matlab managed arrays as you can see in your last image. They are really pointers to a structure that contains the array data pointer, and additional management information. You can't just treat them like C array pointers and neither as LabVIEW arrays. Your Matlab .so should also export functions to manage these arrays, creating them, accessing their information and deallocating them. It's a long time that I looked at it and most likely there are differences between your Matlab Coder version and what was used in the Knowledge article.
What they suggest in there that you can just call it with C arrays as parameters was not possible at the time I looked at it without writing your own wrapper C code that translated the C parameters to Matlap Mex arrays through the additionally exported helper functions.