gPTP Documentation
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IEEE1588Clock Class Reference

#include <avbts_clock.hpp>

Collaboration diagram for IEEE1588Clock:
Collaboration graph

Public Member Functions

 IEEE1588Clock (bool forceOrdinarySlave, bool syntonize, uint8_t priority1, HWTimestamper *timestamper, OSTimerQueueFactory *timerq_factory, OS_IPC *ipc, OSLockFactory *lock_factory)
 Instantiates a IEEE 1588 Clock. More...
 
bool serializeState (void *buf, long *count)
 Updates the frequencyRatio information. More...
 
bool restoreSerializedState (void *buf, long *count)
 Restores the frequencyRatio with the serialized input buffer data. More...
 
Timestamp getTime (void)
 Gets the current time from system clock. More...
 
Timestamp getPreciseTime (void)
 Gets the timestamp from hardware (Deprecated) More...
 
bool isBetterThan (PTPMessageAnnounce *msg)
 Compares the 1588 Clock to the grandmaster clock. More...
 
ClockIdentity getLastEBestIdentity (void)
 Gets the Last Best clock identity. More...
 
void setLastEBestIdentity (ClockIdentity id)
 Sets the last Best clock identity. More...
 
void setClockIdentity (char *id)
 Sets clock identity by id. More...
 
void setClockIdentity (LinkLayerAddress *addr)
 Set clock id based on the link layer address. Clock id is 8 octets long whereas link layer address is 6 octets long and it is turned into a clock identity as per the 802.1AS standard described in clause 8.5.2.2. More...
 
unsigned char getDomain (void)
 Gets the domain number. More...
 
ClockIdentity getGrandmasterClockIdentity (void)
 Gets grandmaster clock ID. More...
 
void setGrandmasterClockIdentity (ClockIdentity id)
 Sets a new GM clock ID. More...
 
ClockQuality getGrandmasterClockQuality (void)
 Gets grandmaster clock quality object. More...
 
void setGrandmasterClockQuality (ClockQuality clock_quality)
 Sets grandmaster clock quality. More...
 
ClockQuality getClockQuality (void)
 Gets the IEEE 1588 Clock quality. More...
 
unsigned char getGrandmasterPriority1 (void)
 Gets grandmaster priority1 attribute (IEEE 802.1AS clause 10.5.3.2.2) More...
 
unsigned char getGrandmasterPriority2 (void)
 Gets grandmaster priotity2 attribute (IEEE 802.1AS clause 10.5.3.2.4) More...
 
void setGrandmasterPriority1 (unsigned char priority1)
 Sets grandmaster's priority1 attribute (IEEE 802.1AS clause 10.5.3.2.2) More...
 
void setGrandmasterPriority2 (unsigned char priority2)
 Sets grandmaster's priority2 attribute (IEEE 802.1AS clause 10.5.3.2.4) More...
 
uint16_t getMasterStepsRemoved (void)
 Gets master steps removed (IEEE 802.1AS clause 10.3.3) More...
 
uint16_t getCurrentUtcOffset (void)
 Gets the currentUtcOffset attribute (IEEE 802.1AS clause 10.3.8.9) More...
 
uint8_t getTimeSource (void)
 Gets the TimeSource attribute (IEEE 802.1AS-2011 clause 10.3.8.10) More...
 
unsigned char getPriority1 (void)
 Gets IEEE1588Clock priority1 value (IEEE 802.1AS clause 8.6.2.1) More...
 
unsigned char getPriority2 (void)
 Gets IEEE1588Clock priority2 attribute (IEEE 802.1AS clause 8.6.2.5) More...
 
uint16_t getNextPortId (void)
 Gets nextPortId value. More...
 
void registerPort (IEEE1588Port *port, uint16_t index)
 Registers a new IEEE1588 port. More...
 
void getPortList (int &count, IEEE1588Port **&ports)
 Gets the current port list instance. More...
 
void addEventTimer (IEEE1588Port *target, Event e, unsigned long long time_ns)
 Add a new event to the timer queue. More...
 
void deleteEventTimer (IEEE1588Port *target, Event e)
 Deletes an event from the timer queue. More...
 
void addEventTimerLocked (IEEE1588Port *target, Event e, unsigned long long time_ns)
 Adds an event to the timer queue using a lock. More...
 
void deleteEventTimerLocked (IEEE1588Port *target, Event e)
 Deletes and event from the timer queue using a lock. More...
 
FrequencyRatio calcMasterLocalClockRateDifference (Timestamp master_time, Timestamp sync_time)
 Calculates the master to local clock rate difference. More...
 
FrequencyRatio calcLocalSystemClockRateDifference (Timestamp local_time, Timestamp system_time)
 Calculates the local to system clock rate difference. More...
 
void setMasterOffset (int64_t master_local_offset, Timestamp local_time, FrequencyRatio master_local_freq_offset, int64_t local_system_offset, Timestamp system_time, FrequencyRatio local_system_freq_offset, unsigned sync_count, unsigned pdelay_count, PortState port_state)
 Sets the master offset, sintonyze and adjusts the frequency offset. More...
 
ClockIdentity getClockIdentity ()
 Get the IEEE1588Clock identity value. More...
 
void newSyntonizationSetPoint ()
 Sets a flag that will allow syntonization during setMasterOffset calls. More...
 
int getTxLockAll ()
 Gets all TX locks. More...
 
int putTxLockAll ()
 Release all TX locks. More...
 
OSLockResult getTimerQLock ()
 Gets the timer queue lock. More...
 
OSLockResult putTimerQLock ()
 Releases the timer queue lock. More...
 
OSLocktimerQLock ()
 Gets a pointer to the timer queue lock object. More...
 

Static Public Member Functions

static Timestamp getSystemTime (void)
 Gets current system time. More...
 

Friends

void tick_handler (int sig)
 Declares a friend instance of tick_handler method. More...
 

Detailed Description

Provides the 1588 clock interface

Constructor & Destructor Documentation

IEEE1588Clock::IEEE1588Clock ( bool  forceOrdinarySlave,
bool  syntonize,
uint8_t  priority1,
HWTimestamper timestamper,
OSTimerQueueFactory timerq_factory,
OS_IPC ipc,
OSLockFactory lock_factory 
)

Instantiates a IEEE 1588 Clock.

Parameters
forceOrdinarySlaveForces it to be an ordinary slave
syntonizeif TRUE, clock will syntonize to the master clock
priority1It is used in the execution of BCMA. See IEEE 802.1AS Clause 10.3
timestamper[in] Provides an object for hardware timestamp
timerq_factory[in] Provides a factory object for creating timer queues (managing events)
ipc[in] Inter process communication object
lock_factory[in] Provides a factory object for creating locking a locking mechanism

Member Function Documentation

void IEEE1588Clock::addEventTimer ( IEEE1588Port target,
Event  e,
unsigned long long  time_ns 
)

Add a new event to the timer queue.

Parameters
targetIEEE1588Port target
eEvent to be added
time_nsTime in nanoseconds
void IEEE1588Clock::addEventTimerLocked ( IEEE1588Port target,
Event  e,
unsigned long long  time_ns 
)

Adds an event to the timer queue using a lock.

Parameters
targetIEEE1588Port target
eEvent to be added
time_nscurrent time in nanoseconds
Returns
void
FrequencyRatio IEEE1588Clock::calcLocalSystemClockRateDifference ( Timestamp  local_time,
Timestamp  system_time 
)

Calculates the local to system clock rate difference.

Parameters
local_timeLocal time
system_timeSystem time
Returns
The offset in ppt (parts per trillion)
FrequencyRatio IEEE1588Clock::calcMasterLocalClockRateDifference ( Timestamp  master_time,
Timestamp  sync_time 
)

Calculates the master to local clock rate difference.

Parameters
master_timeMaster time
sync_timeLocal time
Returns
The offset in ppt (parts per trillion)
void IEEE1588Clock::deleteEventTimer ( IEEE1588Port target,
Event  e 
)

Deletes an event from the timer queue.

Parameters
targetTarget port to remove the event from
eEvent to be removed
Returns
void
void IEEE1588Clock::deleteEventTimerLocked ( IEEE1588Port target,
Event  e 
)

Deletes and event from the timer queue using a lock.

Parameters
targetTarget port to remove the event from
eEvent to be deleted
Returns
ClockIdentity IEEE1588Clock::getClockIdentity ( )
inline

Get the IEEE1588Clock identity value.

Returns
clock identity
ClockQuality IEEE1588Clock::getClockQuality ( void  )
inline

Gets the IEEE 1588 Clock quality.

Returns
ClockQuality
uint16_t IEEE1588Clock::getCurrentUtcOffset ( void  )
inline

Gets the currentUtcOffset attribute (IEEE 802.1AS clause 10.3.8.9)

Returns
currentUtcOffset
unsigned char IEEE1588Clock::getDomain ( void  )
inline

Gets the domain number.

Returns
domain number
ClockIdentity IEEE1588Clock::getGrandmasterClockIdentity ( void  )
inline

Gets grandmaster clock ID.

Returns
GM clock ID
ClockQuality IEEE1588Clock::getGrandmasterClockQuality ( void  )
inline

Gets grandmaster clock quality object.

Returns
Clock quality
unsigned char IEEE1588Clock::getGrandmasterPriority1 ( void  )
inline

Gets grandmaster priority1 attribute (IEEE 802.1AS clause 10.5.3.2.2)

Returns
Grandmaster priority1
unsigned char IEEE1588Clock::getGrandmasterPriority2 ( void  )
inline

Gets grandmaster priotity2 attribute (IEEE 802.1AS clause 10.5.3.2.4)

Returns
Grandmaster priority2
ClockIdentity IEEE1588Clock::getLastEBestIdentity ( void  )
inline

Gets the Last Best clock identity.

Returns
clock identity
uint16_t IEEE1588Clock::getMasterStepsRemoved ( void  )
inline

Gets master steps removed (IEEE 802.1AS clause 10.3.3)

Returns
steps removed value
uint16_t IEEE1588Clock::getNextPortId ( void  )
inline

Gets nextPortId value.

Returns
The remaining value from the division of current number of ports by (maximum number of ports + 1) + 1
void IEEE1588Clock::getPortList ( int &  count,
IEEE1588Port **&  ports 
)
inline

Gets the current port list instance.

Parameters
count[out] Number of ports
ports[out] Pointer to the port list
Returns
Timestamp IEEE1588Clock::getPreciseTime ( void  )

Gets the timestamp from hardware (Deprecated)

Returns
Hardware timestamp
unsigned char IEEE1588Clock::getPriority1 ( void  )
inline

Gets IEEE1588Clock priority1 value (IEEE 802.1AS clause 8.6.2.1)

Returns
Priority1 value
unsigned char IEEE1588Clock::getPriority2 ( void  )
inline

Gets IEEE1588Clock priority2 attribute (IEEE 802.1AS clause 8.6.2.5)

Returns
Priority2 value
static Timestamp IEEE1588Clock::getSystemTime ( void  )
static

Gets current system time.

Returns
Instance of a Timestamp object
Timestamp IEEE1588Clock::getTime ( void  )

Gets the current time from system clock.

Returns
System time
OSLockResult IEEE1588Clock::getTimerQLock ( )
inline

Gets the timer queue lock.

Returns
OSLockResult structure
uint8_t IEEE1588Clock::getTimeSource ( void  )
inline

Gets the TimeSource attribute (IEEE 802.1AS-2011 clause 10.3.8.10)

Returns
TimeSource
int IEEE1588Clock::getTxLockAll ( )
inline

Gets all TX locks.

Returns
void
bool IEEE1588Clock::isBetterThan ( PTPMessageAnnounce msg)

Compares the 1588 Clock to the grandmaster clock.

Parameters
msg[in] PTP announce message
Returns
TRUE if the 1588 clock
void IEEE1588Clock::newSyntonizationSetPoint ( )
inline

Sets a flag that will allow syntonization during setMasterOffset calls.

Returns
void
OSLockResult IEEE1588Clock::putTimerQLock ( )
inline

Releases the timer queue lock.

Returns
OSLockResult structure
int IEEE1588Clock::putTxLockAll ( )
inline

Release all TX locks.

Returns
void
void IEEE1588Clock::registerPort ( IEEE1588Port port,
uint16_t  index 
)
inline

Registers a new IEEE1588 port.

Parameters
port[in] IEEE1588port instance
indexPort's index
Returns
void
bool IEEE1588Clock::restoreSerializedState ( void *  buf,
long *  count 
)

Restores the frequencyRatio with the serialized input buffer data.

Parameters
buf[in] serialized frequencyRatio information
count[inout] Size of buffer. It is incremented internally
Returns
TRUE in case of success, FALSE otherwise.
bool IEEE1588Clock::serializeState ( void *  buf,
long *  count 
)

Updates the frequencyRatio information.

Parameters
buf[out] Stores the serialized clock quality state
count[inout] Provides the size of buffer. Its decremented internally
Returns
TRUE in case of success, FALSE when the count should be updated with the right size.
void IEEE1588Clock::setClockIdentity ( char *  id)
inline

Sets clock identity by id.

Parameters
id[id] Clock identity (as an octet array)
Returns
void
void IEEE1588Clock::setClockIdentity ( LinkLayerAddress addr)
inline

Set clock id based on the link layer address. Clock id is 8 octets long whereas link layer address is 6 octets long and it is turned into a clock identity as per the 802.1AS standard described in clause 8.5.2.2.

Parameters
addrLink layer address
Returns
void
void IEEE1588Clock::setGrandmasterClockIdentity ( ClockIdentity  id)
inline

Sets a new GM clock ID.

Parameters
idNew id
Returns
void
void IEEE1588Clock::setGrandmasterClockQuality ( ClockQuality  clock_quality)
inline

Sets grandmaster clock quality.

Parameters
clock_qualityClockQuality object to be set
Returns
void
void IEEE1588Clock::setGrandmasterPriority1 ( unsigned char  priority1)
inline

Sets grandmaster's priority1 attribute (IEEE 802.1AS clause 10.5.3.2.2)

Parameters
priority1value to be set
Returns
void
void IEEE1588Clock::setGrandmasterPriority2 ( unsigned char  priority2)
inline

Sets grandmaster's priority2 attribute (IEEE 802.1AS clause 10.5.3.2.4)

Parameters
priority2Value to be set
Returns
void
void IEEE1588Clock::setLastEBestIdentity ( ClockIdentity  id)
inline

Sets the last Best clock identity.

Parameters
idClockIdentity object to be set
Returns
void
void IEEE1588Clock::setMasterOffset ( int64_t  master_local_offset,
Timestamp  local_time,
FrequencyRatio  master_local_freq_offset,
int64_t  local_system_offset,
Timestamp  system_time,
FrequencyRatio  local_system_freq_offset,
unsigned  sync_count,
unsigned  pdelay_count,
PortState  port_state 
)

Sets the master offset, sintonyze and adjusts the frequency offset.

Parameters
master_local_offsetMaster to local phase offset
local_timeLocal time
master_local_freq_offsetMaster to local frequency offset
local_system_offsetLocal time to system time phase offset
system_timeSystem time
local_system_freq_offsetLocal to system frequency offset
sync_countSync messages count
pdelay_countPDelay messages count
port_statePortState instance
OSLock* IEEE1588Clock::timerQLock ( )
inline

Gets a pointer to the timer queue lock object.

Returns
OSLock instance

Friends And Related Function Documentation

void tick_handler ( int  sig)
friend

Declares a friend instance of tick_handler method.

Parameters
sigSignal
Returns
void

The documentation for this class was generated from the following file: