LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling a shared library from a VI on a NI Linux RT target (cRIO 9068)

Solved!
Go to solution
Hi, I wrote a very small shared library (.so) with Eclipse (2014 toolchain), that basically acts as a wrapper for a more complex one, but I'm encountering problems with calling in from within LabVIEW RT on a Linux RT target - specifically, the cRIO 9068. First of all: the library has been copied to /usr/local/lib, and ldconfig has been properly set up. Most important, I also wrote a C program (using Eclipse as well) that calls the only function currently implemented in the shared library: this work flawlessly both under Eclipse and by logging directly on the cRIO with a Putty terminal. So I assume the shared library itself is ok and can be called from external code/programs. Now, going back to LabVIEW (2014 here btw). Here's where things get tricky, I guess. At first I had the problems listed here --> http://forums.ni.com/t5/LabVIEW/How-to-create-a-c-shared-library-so-for-linux-real-time-for/td-p/302... that prevented me from actually running any code on the RT target. Then I modified the Call Library Function Node: various tutorials suggest putting name_of_library.* in the library name or path text box, but this unfortunately doesn't seem to work so I had to put the actual name and extension, too. But this still produced the error below ("the function name cannot be found" etc.) So I check the "Specify path on diagram" box, and add /usr/local/lib as a parameter to the Call Library Function Node: now the VI can run and is actually transferred to the RT target... but the output error cluster returns error 7, which is a "File not found" kind of error. However, I believe this error message is misleading: indeed, if I try to remotely debug this shared library under Eclipse, I am actually able to pause it... and when I press the Pause button on the debugger, the RT target VI suspends execution, then it continue as soon as I press the Resume button, I'm stuck... I tried searching NI forums and Google as well, but I haven't still found a solution. Any ideas on what's going on? By the way, I can add more details if needed.
0 Kudos
Message 1 of 11
(6,476 Views)

Sorry for the awful, awful formatting. Reposting, hoping this one is more readable (I tried to edit the original message, but I didn't find any "modify" function?!)

 

================================

 

Hi, I wrote a very small shared library (.so) with Eclipse (2014 toolchain), that basically acts as a wrapper for a more complex one, but I'm encountering problems with calling in from within LabVIEW RT on a Linux RT target - specifically, the cRIO 9068.

 

First of all: the library has been copied to /usr/local/lib, and ldconfig has been properly set up.

Most important, I also wrote a C program (using Eclipse as well) that calls the only function currently implemented in the shared library: this work flawlessly both under Eclipse and by logging directly on the cRIO with a Putty terminal.

 

So I assume the shared library itself is ok and can be called from external code/programs.

 

Now, going back to LabVIEW (2014 here btw).

Here's where things get tricky, I guess. At first I had the problems listed here --> http://forums.ni.com/t5/LabVIEW/How-to-create-a-c-shared-library-so-for-linux-real-time-for/td-p/302... that prevented me from actually running any code on the RT target.

 

Then I modified the Call Library Function Node: various tutorials suggest putting name_of_library.* in the library name or path text box, but this unfortunately doesn't seem to work so I had to put the actual name and extension, too. But this still produced the error mentioned above ("the function name cannot be found" etc.)

 

So I check the "Specify path on diagram" box, and add /usr/local/lib as a parameter to the Call Library Function Node: now the VI can run and is actually transferred to the RT target... but the output error cluster returns error 7, which is a "File not found" kind of error.

 

However, I believe this error message is misleading: indeed, if I try to remotely debug this shared library under Eclipse, I am actually able to pause it... and when I press the Pause button on the debugger, the RT target VI suspends execution, then it continues as soon as I press the Resume button.

 

I'm stuck... I tried searching NI forums and Google as well, but I haven't still found a solution. Any ideas on what's going on?

By the way, I can add more details if needed.

0 Kudos
Message 2 of 11
(6,438 Views)
Solution
Accepted by topic author BFD_LNS

Problem solved, it was misconfiguration of the Call Library Function Node that prevented the actual libray (.so) from being called.

0 Kudos
Message 3 of 11
(6,288 Views)

Hello,

 

I have having the same problem.  Can you share you code so that I can use it as a starting point?

 

Thanks.

0 Kudos
Message 4 of 11
(6,004 Views)
Hi Jaggs, which code do you need? The C one, the LabVIEW RT one or both?
0 Kudos
Message 5 of 11
(5,972 Views)

Hello,

 

Can I have both?

 

Thanks.

0 Kudos
Message 6 of 11
(5,954 Views)

Hi guys, sorry for the delay but as usual I am extremely busy at work.

I'm posting two attachments here, in compressed ZIP format: an Eclipse project, written in C, for an extremely simple (simple being an understatement) shared library and a LabVIEW 2014 project that includes a very very simple - again - VI that uses the aforementioned shared library to demonstrate it is actually working.

 

Inside the Debug directory of the Eclipse project file you will find the shared library (.so) already compiled for ARM, you must copy it to the RT target/cRIO (or recompile it if your cRIO has an Intel processor).
I chose /usr/local/lib/ on the RT target as the destination directory for the .so, I don't know if there are strict rules in place about this... just make sure - obviously - that you put it in the same path specified on the VI Call Library Function Node.

Needless to say, you'll have to to edit the IP address of the cRIO to match the one in your current configuration.

Hope this helps.

Best regards

Download All
Message 7 of 11
(5,926 Views)

thankyou for the files.  Do we need to manually copy the .so file to /usr/local/lib directory?

 

 

0 Kudos
Message 8 of 11
(5,907 Views)

If I recall correctly you should be able to configure Eclipse to put the compiled .so in a directory of your choice on the target (provided you have the right permissions obviously), but since there is a precompiled .so in the archive I posted you might not need to worry about this.

 

Just copy it to /usr/local/lib, reconfigure the LabVIEW project to comply with the IP of your chassis and the RT VI will, hopefully, work as expected.


As I said though, the .so is meant to be used for ARM-equipped cRIO so make sure the one you own has the same kind of processor.

Message 9 of 11
(5,899 Views)

Thankyou very much.  It works now.

0 Kudos
Message 10 of 11
(5,870 Views)