LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Setting Date/Time Programmatically fails on cRIO 9055

Solved!
Go to solution

For my application, I need to programatically set the date/time of my cRIO with minimal delay. The attached VI (LV 2019 SP1) was developed based on the feedback here. It has been tested and works on an older cRIO 9065.

 

I have been migrating code to a new cRIO 9055. This VI fails on it, the Call Library Function Node returns a -1 and the system time isn't updated.

 

Any suggestions on what might be going wrong?

0 Kudos
Message 1 of 5
(3,503 Views)

The post you are linking is rather old. Did you verify whether you run into the same trouble on your cRIO?

I recently used Set Time from RT-Utilities with a 9056. It worked well for me.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 2 of 5
(3,335 Views)

Set-Time from RT Utilities does work but it takes between 1 and 3 seconds to execute. This is too long for my application. When settimeofday is used through a call library function the delay is on a ms scale. 

 

I have successfully run the originally attached vi on a cRIO 9065 but it fails on a cRIO 9055.

0 Kudos
Message 3 of 5
(3,324 Views)
Solution
Accepted by topic author ProlucidDavid

I still don't know what is going wrong. I have validated that the lvuser process has cap_sys_time+ep and should be allowed to execute code that updates system time. Whenever I try I receive the error "Operation not Permitted".

 

I have found a workaround. The idea is ssh in as root and build a binary whose only job is to update the system time. Using suid we can flag the binary to be executed with root permissions even if it's invoked by a different process.

 

These are the steps followed:

  • SSH into cRIO as root
  • use opkg to install a gcc toolchain. These are the commands I ran
    • opkg update
    • opkg upgrade all
    • opkg install gcc
    • opkg install gcc-symlinks
    • opkg install build-essential
    • opkg install binutils-symlinks
    • opkg install libcap-dev
  • Copy the attached C file onto the cRIO
  • Build with gcc
    • gcc -o setTime setTime.c
  • Move binary to known location (/usr/bin in this case)
    • cp setTime /usr/bin/setTime
  • Assign it execution permissions and set suid so that it will run with admin permissions
    • chmod +x /usr/bin/prolucidSetTime
    • chmod u+s /usr/bin/prolucidSetTime
  • The attached VI will run the binary
Download All
0 Kudos
Message 4 of 5
(3,248 Views)

After working through the issue with NI support I have the following extra information on the identified solution:

1) The supported way to update the time on a cRIO is through the System Configuration API. This method is slow and I've measured it at 1-3 seconds to execute

2) While better timing can be achieved through calls to libc.6.so, NI doesn't control this library and can't guarantee operation

0 Kudos
Message 5 of 5
(2,863 Views)