Skip to content
Snippets Groups Projects

Userspace alternative to gpstime kernel module

Merged Christopher Wipf requested to merge christopher.wipf/advligorts:gpsclock into master
1 unresolved thread

This code can be used when models run in userspace and without GPS hardware. It removes the dependency on the special device file /dev/gpstime. GPS time is obtained in userspace from the system clock. Enable at compile time by defining USE_GPSCLOCK. When building a model, add userspacegps=1 to the CDS parameters.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Reviewing.

  • @christopher.wipf Thanks for the MR.

    I like the idea, it would be good to allow things to run w/o custom kernel drivers when possible. There are a few things I would like changed to help with future maintenance/support and packaging.

    1. We can do all of this at run time, so I don't think we need to do this via a configuration time check. This will make it easier for support as we will have less packages and variants to work with.

      a. The code can try to open /dev/gpstime, and if that fails call the gpsclock calls.

    2. For readability and maintenance down the line I would like to reduce the number of ifdefs. Typically consolidate them at the front of a file, including small static inline functions/macros that are used later in the code to make the code paths read the same.

    3. You found some bits of dead/unused code that we should just drop.

    I took the liberty of implementing these as a MR against this MR, and it has been submitted for your review.

    Thanks.

    Edited by Jonathan Hanks
  • Christopher Wipf added 2 commits

    added 2 commits

    • 58acce0a - Updates to the gpsclock.
    • 85017637 - Merge branch 'gpsclock' into 'gpsclock'

    Compare with previous version

  • @rolf.bork Can you sign off on the RCG side of the changes. I'm ready to merge this if it looks good to you.

    Specifically:

    • timing changes in controllerAppUser.c, controllerIopUser.c, there are supporting changes to feCodeGen.pl, Parameters.pm, and createUserMakefile.pm
  • Jonathan Hanks mentioned in commit 5b9c93d2

    mentioned in commit 5b9c93d2

18 }
19
20 int gpsclock_offset(long *offset) {
21 // TAI-UTC offset in seconds as of 1972
22 const long INITIAL_TAI_OFFSET = 10;
23 // GPS-TAI offset in seconds
24 const long GPS_TAI_OFFSET = -19;
25
26 char *savetz;
27 time_t now, gpszero, posixutc, rightutc;
28 struct tm now_tm, gpszero_tm = {.tm_year=80, .tm_mon=0, .tm_mday=6, .tm_hour=0, .tm_min=0, .tm_sec=0, .tm_wday=-1, .tm_yday=-1, .tm_isdst=-1};
29
30 // save TZ
31 savetz = getenv("TZ");
32 if (savetz) {
33 setenv("GPSCLOCK_TZ_ORIG", savetz, 1);
Please register or sign in to reply
Loading