Skip to content

LinuxClock::system_offset is wrong about UnixClock::system_offset timescale? #689

Description

@teodly

In statime-linux, system_offset expects UnixClock::system_offset (from clock-steering) to be REALTIME:

        // The clock crate's system offset gives the T1 and T3 timestamps on the
        // CLOCK_REALTIME timescale which is UTC, not TAI, so we need to correct
        // here.
            let tai_offset = UnixClock::CLOCK_REALTIME.get_tai().unwrap();
            t1.seconds += tai_offset as libc::time_t;
            t3.seconds += tai_offset as libc::time_t;

However, here, clock-steering uses TAI, both in fallback userspace timestamp sandwitching:

            let t1 = Self::CLOCK_TAI.now();
            let tp = self.now();
            let t2 = Self::CLOCK_TAI.now();

and it already converts PTP_SYS_OFFSET result which is REALTIME to TAI:

            let tai_offset = Self::CLOCK_TAI.get_tai()?;

            Ok((
                Timestamp {
                    seconds: (offset.ts[0].sec + tai_offset as i64) as _,
                    nanos: offset.ts[0].nsec as _,
                },
                Timestamp {
                    seconds: offset.ts[1].sec as _,
                    nanos: offset.ts[1].nsec as _,
                },
                Timestamp {
                    seconds: (offset.ts[2].sec + tai_offset as i64) as _,
                    nanos: offset.ts[2].nsec as _,
                },
            ))

So is it really wrong or am I missing something?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions