libuav original

Dependents:   UAVCAN UAVCAN_Subscriber

Embed: (wiki syntax)

« Back to documentation index

SystemClock Class Reference

Linux system clock driver. More...

#include <clock.hpp>

Inherits uavcan::ISystemClock.

Public Member Functions

 SystemClock (ClockAdjustmentMode adj_mode=detectPreferredClockAdjustmentMode())
 By default, the clock adjustment mode will be selected automatically - global if root, private otherwise.
uavcan::MonotonicTime getMonotonic () const override
 Returns monotonic timestamp from librt.
uavcan::UtcTime getUtc () const override
 Returns wall time from gettimeofday().
void adjustUtc (const uavcan::UtcDuration adjustment) override
 Adjusts the wall clock.
void setGradualAdjustmentLimit (uavcan::UtcDuration limit)
 Sets the maximum phase error to use adjtime().
uavcan::UtcDuration getPrivateAdjustment () const
 This is only applicable if the selected clock adjustment mode is private.
std::uint64_t getStepAdjustmentCount () const
 Statistics that allows to evaluate clock sync preformance.

Static Public Member Functions

static ClockAdjustmentMode detectPreferredClockAdjustmentMode ()
 This static method decides what is the optimal clock sync adjustment mode for the current configuration.

Detailed Description

Linux system clock driver.

Requires librt.

Definition at line 33 of file drivers/linux/include/uavcan_linux/clock.hpp.


Constructor & Destructor Documentation

SystemClock ( ClockAdjustmentMode  adj_mode = detectPreferredClockAdjustmentMode() ) [explicit]

By default, the clock adjustment mode will be selected automatically - global if root, private otherwise.

Definition at line 72 of file drivers/linux/include/uavcan_linux/clock.hpp.


Member Function Documentation

void adjustUtc ( const uavcan::UtcDuration  adjustment ) [override, virtual]

Adjusts the wall clock.

Behavior depends on the selected clock adjustment mode - ClockAdjustmentMode. Clock adjustment mode can be set only once via constructor.

If the system wide adjustment mode is selected, two ways for performing adjustment exist:

  • Gradual adjustment using adjtime(), if the phase error is less than gradual adjustment limit.
  • Step adjustment using settimeofday(), if the phase error is above gradual adjustment limit. The gradual adjustment limit can be configured at any time via the setter method.
Exceptions:
uavcan_linux::Exception.

Implements ISystemClock.

Definition at line 124 of file drivers/linux/include/uavcan_linux/clock.hpp.

static ClockAdjustmentMode detectPreferredClockAdjustmentMode (  ) [static]

This static method decides what is the optimal clock sync adjustment mode for the current configuration.

It selects system wide mode if the application is running as root; otherwise it prefers the private adjustment mode because the system wide mode requires root privileges.

Definition at line 189 of file drivers/linux/include/uavcan_linux/clock.hpp.

uavcan::MonotonicTime getMonotonic (  ) const [override, virtual]

Returns monotonic timestamp from librt.

Exceptions:
uavcan_linux::Exception.

Implements ISystemClock.

Definition at line 83 of file drivers/linux/include/uavcan_linux/clock.hpp.

uavcan::UtcDuration getPrivateAdjustment (  ) const

This is only applicable if the selected clock adjustment mode is private.

In system wide mode this method will always return zero duration.

Definition at line 172 of file drivers/linux/include/uavcan_linux/clock.hpp.

std::uint64_t getStepAdjustmentCount (  ) const

Statistics that allows to evaluate clock sync preformance.

Definition at line 177 of file drivers/linux/include/uavcan_linux/clock.hpp.

uavcan::UtcTime getUtc (  ) const [override, virtual]

Returns wall time from gettimeofday().

Exceptions:
uavcan_linux::Exception.

Implements ISystemClock.

Definition at line 97 of file drivers/linux/include/uavcan_linux/clock.hpp.

void setGradualAdjustmentLimit ( uavcan::UtcDuration  limit )

Sets the maximum phase error to use adjtime().

If the phase error exceeds this value, settimeofday() will be used instead.

Definition at line 155 of file drivers/linux/include/uavcan_linux/clock.hpp.