Linux Users

Highlighted

Import linux nanosleep() function to Labview

Linux C function nanosleep() is declared in time.h header file, but Labview -> Tools-> Import-> shared library (.so) can't import it.

Simple C example with nanosleep() function works.

I don't know why.

Linux kernel 3.3.6

Thank you for any ideia.

0 Kudos
Message 1 of 10
(4,721 Views)
9 REPLIES 9

Re: Import linux nanosleep() function to Labview

I'm not sure, I haven't played around with the Import Shared Library functionality, but my naïve guess would be that it may have difficulty with more complex structure/object arguments (e.g. the timespec_t argument)

0 Kudos
Message 2 of 10
(2,937 Views)

Re: Import linux nanosleep() function to Labview

Does Call Library Function Library Node.vi work on Linux?

0 Kudos
Message 3 of 10
(2,937 Views)

Re: Import linux nanosleep() function to Labview

Sure it does. But importing system APIs may be a little more complicated. Do you know from which .so it is exported? Just pointing the shared library importer to the header file is not enough. Also the struct timespec parameters may indeed form a problem for the import shared library wizard. Especially since time_t is not a fixed size parameter (can vary depending on your platform). However creating a cluster in LabVIEW with the correctly sized elements (probably an uInt32 or uInt64 followed by an int32) and then configuring both parameters in the Call Library node configuration dialog to "Adapt to Type" and wiring the two clusters to the two parameters should work.

You will have to find out what size your system uses for time_t.

Rolf Kalbermatter
Averna BV
LabVIEW ArchitectLabVIEW ChampionLabVIEW Instructor
Message 4 of 10
(2,937 Views)

Re: Import linux nanosleep() function to Labview

It does indeed, I simply assumed that the Wizard would map the function entrypoint signatures to CLFN argument types. When an argument type is a composite type, that is something that's not universally supported, only specific types of more complex types are supported (e.g. arrays, waveform data, etc.). In other words, it wouldn't know how to handle the struct timespec arguments. You can write a simple wrapper that takes the requested seconds and nanoseconds, constructs the timespec, and calls nanosleep().

LabVIEW<======>Wrapper C/C++<========>glibc nanosleep()

Seconds------------------Timespec struct----------------

Nanoseconds----------------/

0 Kudos
Message 5 of 10
(2,937 Views)

Re: Import linux nanosleep() function to Labview

Ah, beat me to it with more information, thanks rolfk

0 Kudos
Message 6 of 10
(2,937 Views)

Re: Import linux nanosleep() function to Labview

I think using of wrapper is a good idea.

0 Kudos
Message 7 of 10
(2,937 Views)

Re: Import linux nanosleep() function to Labview

Sounds good to me. Let us know if you run into other issues and, more importantly, note that the resolution of nanosleep() is completely at the mercy of whatever clock source you've configured to fit into the high-resolution timing system of your kernel (and heaven forbid you're still on a kernel that only supports jiffy-level resolution...)

0 Kudos
Message 8 of 10
(2,937 Views)

Re: Import linux nanosleep() function to Labview

One more tidbit. Under Linux it seems the Linux guys put just about everything from the basic Linux kernel into the libc.so. Personally I find that a bit ... well unmodularized, but I guess it is just a consistent implementation for a monolithic kernel architecture.

Rolf Kalbermatter
Averna BV
LabVIEW ArchitectLabVIEW ChampionLabVIEW Instructor
0 Kudos
Message 9 of 10
(2,937 Views)

Re: Import linux nanosleep() function to Labview


@rolfk wrote:

One more tidbit. Under Linux it seems the Linux guys put just about everything from the basic Linux kernel into the libc.so. Personally I find that a bit ... well unmodularized, but I guess it is just a consistent implementation for a monolithic kernel architecture.


No, we don't. glibc only contains basic stuff, usually posix interfaces, rarely linux specific stuff (that are mostly relics). Specific subsystems (eg. nf, usb, can, iio, dri, alsa, ...) have their own libraries.

 

nanosleep() is a core function - it naturally belongs into libc.

 

Linux Embedded / Kernel Hacker / BSP / Driver development / Systems engineering
0 Kudos
Message 10 of 10
(1,068 Views)
Reply
This is an open group. Sign in and click the "Join Group" button to become a group member and start posting.