Rtnl2AdjustClockTime

Rtnl2AdjustClockTime adjusts the time of a clock by applying an offset to the current counter value.

Syntax

Copy
BOOL Rtnl2AdjustClockTime(
    [in] RTNL2_HCLOCK Clock, 
    [in] const RTNL2_TIMESTAMP *pTimeOffset
);

Parameters

[in] Clock

A handle to the clock object (see RTNL2_HCLOCK).

[in] pTimeOffset

The offset (positive or negative) to apply.

Return Value

If the function succeeds, it returns TRUE. If the function fails, it returns FALSE. Call GetLastError to obtain an error code.

Possible error codes:

Error code Meaning

ERROR_NOT_READY

The calling process has not called Rtnl2Init.

ERROR_INVALID_PARAMETER

O of the following conditions occurred:

  • The supplied Clock handle is invalid.
  • pTimeOffset is NULL.
  • pTimeOffset contains an inconsistent sign for the Seconds and Nanoseconds fields.
  • pTimeOffset contains an invalid value of Nanoseconds (not in the range -999,999,999 .. +999,999,999).
  • pTimeOffset contains an invalid value of Seconds (not in the range -(2^48-1) .. +(2^48-1)).

ERROR_ACCESS_DENIED

The clock handle was not opened with the RTNL2_CLOCK_FLAG_MODIFY flag.

ERROR_DEVICE_FEATURE_NOT_SUPPORTED

The hardware doesn’t support setting the NIC clock counter.

RTNL2_ERROR_SERIALIZED_COMMAND_TIMEOUT

The NL2 process didn’t reply within an acceptable delay.

RTNL2_ERROR_NO_MORE_COMMUNICATION

Unable to communicate with the NL2 process. This might be because the NL2 process is no longer running, or because an application process thread was terminated during a previous call to an NL2 API function.

Remarks

Depending on the hardware capabilities, the NL2 will use one of the two following methods:

IMPORTANT: Modifying the clock time is a disruptive operation that should be done with the greatest care. Whenever possible, it is preferable to maintain a logical time offset in software rather than modifying the hardware clock time.

IMPORTANT: If this clock is currently used by another application (typically PTP for Ethernet packet ingress/egress timestamping), that application should be made aware of the modification by some means outside of the NL2. Otherwise, it may wrongly interpret invalid timestamps and behave incorrectly.

IMPORTANT: Hardware clocks generally use a hardware register to record the value of their counter (e.g. a 32-bit register for the number of seconds and another 32-bit register for the number of nanoseconds, or a single 64-bit register for the number of nanoseconds). The size of this(these) register(s) is normally sufficient to avoid counter overflow for a very long time (e.g. 136 years for a 32-bit seconds register). However, if the application modifies the clock time by applying a large offset, it may cause the counter to overflow, which results in the clock time wrapping around. The NL2 does not prevent this from happening. It’s the application’s responsibility to either make sure it doesn’t happen or handle it correctly if it does. A similar problem occurs when applying a large negative time offset (counter underflow). See RTNL2_INTERFACE_FEATURES.ClockTimeRange for the range of possible values for the hardware clock time.

Characteristics

Real-time

Deterministic

No

Shutdown-safe

No

Local memory usage

Process

External MSpace usage

Internal MSpace usage

System

No

No

NL2 process

No

No

Calling process

No

No

Windows contiguous memory usage

Usage

No

Requirements

Minimum supported version Header Library

wRTOS 1.0 SDK

Rtnl2Api.h

Rtnl2Api.lib

See Also: