diff options
author | andrew-elder <aelder@audioscience.com> | 2017-06-23 11:27:57 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-23 11:27:57 -0400 |
commit | 63d7db3e1f5347f09de8527db337aba1d7567b08 (patch) | |
tree | 7c58905ac4ee120da1dd413221e3110b7cc9e6b5 | |
parent | 60cdf3c8a9a19bde19bc1b078f2117864c704636 (diff) | |
parent | ac840d6b908cf5601a0023b1fdd23b40dd88ca93 (diff) | |
download | Open-AVB-63d7db3e1f5347f09de8527db337aba1d7567b08.tar.gz |
Merge pull request #635 from christopher-s-hall/open-avb-next
RFC: Fix Priority1 check in announce timeout
-rw-r--r-- | daemons/gptp/common/common_port.cpp | 85 |
1 files changed, 38 insertions, 47 deletions
diff --git a/daemons/gptp/common/common_port.cpp b/daemons/gptp/common/common_port.cpp index be2d8159..512c579b 100644 --- a/daemons/gptp/common/common_port.cpp +++ b/daemons/gptp/common/common_port.cpp @@ -467,8 +467,18 @@ bool CommonPort::processStateChange( Event e ) bool CommonPort::processSyncAnnounceTimeout( Event e ) { + // We're Grandmaster, set grandmaster info to me + ClockIdentity clock_identity; + unsigned char priority1; + unsigned char priority2; + ClockQuality clock_quality; + + Timestamp system_time; + Timestamp device_time; + uint32_t local_clock, nominal_clock_rate; + // Nothing to do - if( clock->getPriority1() != 255 ) + if( clock->getPriority1() == 255 ) return true; // Restart timer @@ -487,57 +497,38 @@ bool CommonPort::processSyncAnnounceTimeout( Event e ) 1000000000.0))); } - if ( getPortState() == PTP_INITIALIZING || - getPortState() == PTP_UNCALIBRATED || - getPortState() == PTP_SLAVE || - getPortState() == PTP_PRE_MASTER ) - { - GPTP_LOG_STATUS( - "*** %s Timeout Expired - Becoming Master", - e == ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES ? "Announce" : - "Sync" ); - { - // We're Grandmaster, set grandmaster info to me - ClockIdentity clock_identity; - unsigned char priority1; - unsigned char priority2; - ClockQuality clock_quality; - - clock_identity = getClock()->getClockIdentity(); - getClock()->setGrandmasterClockIdentity - ( clock_identity ); - priority1 = getClock()->getPriority1(); - getClock()->setGrandmasterPriority1( priority1 ); - priority2 = getClock()->getPriority2(); - getClock()->setGrandmasterPriority2( priority2 ); - clock_quality = getClock()->getClockQuality(); - getClock()->setGrandmasterClockQuality - ( clock_quality ); - } - setPortState( PTP_MASTER ); - Timestamp system_time; - Timestamp device_time; + if( getPortState() == PTP_MASTER ) + return true; - uint32_t local_clock, nominal_clock_rate; + GPTP_LOG_STATUS( + "*** %s Timeout Expired - Becoming Master", + e == ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES ? "Announce" : + "Sync" ); - getDeviceTime(system_time, device_time, - local_clock, nominal_clock_rate); + clock_identity = getClock()->getClockIdentity(); + getClock()->setGrandmasterClockIdentity( clock_identity ); + priority1 = getClock()->getPriority1(); + getClock()->setGrandmasterPriority1( priority1 ); + priority2 = getClock()->getPriority2(); + getClock()->setGrandmasterPriority2( priority2 ); + clock_quality = getClock()->getClockQuality(); + getClock()->setGrandmasterClockQuality( clock_quality ); - (void) clock->calcLocalSystemClockRateDifference - ( device_time, system_time ); + setPortState( PTP_MASTER ); - setQualifiedAnnounce( NULL ); + getDeviceTime( system_time, device_time, + local_clock, nominal_clock_rate ); - // Add timers for Announce and Sync, this is as close to - // immediately as we get - if( clock->getPriority1() != 255) - { - clock->addEventTimerLocked - ( this, SYNC_INTERVAL_TIMEOUT_EXPIRES, - 16000000 ); - } - startAnnounce(); - } + (void) clock->calcLocalSystemClockRateDifference + ( device_time, system_time ); + + setQualifiedAnnounce( NULL ); + + clock->addEventTimerLocked + ( this, SYNC_INTERVAL_TIMEOUT_EXPIRES, + 16000000 ); + + startAnnounce(); return true; } |