Commit 0d0d7459 authored by Tomasz Wlostowski's avatar Tomasz Wlostowski

ptpd: lots of fixes (to be split later)

parent 1b5f4e3e
...@@ -45,7 +45,7 @@ LDFLAGS = #-L. -lminipc -lptpnetif ...@@ -45,7 +45,7 @@ LDFLAGS = #-L. -lminipc -lptpnetif
# Flags from the original Makefiles # Flags from the original Makefiles
#CFLAGS += -DPTPD_NO_DAEMON #CFLAGS += -DPTPD_NO_DAEMON
#CFLAGS += -DPTPD_TRACE_MASK=0xFFF7 CFLAGS += -DPTPD_TRACE_MASK="0xffff"
#CFLAGS += -DPTPD_TRACE_MASK=0x0000 #CFLAGS += -DPTPD_TRACE_MASK=0x0000
#CFLAGS += -DNETIF_VERBOSE #CFLAGS += -DNETIF_VERBOSE
CFLAGS += -DMACIEK_HACKs CFLAGS += -DMACIEK_HACKs
......
...@@ -15,7 +15,7 @@ void initDataPort(RunTimeOpts *rtOpts, PtpPortDS *ptpPortDS) ...@@ -15,7 +15,7 @@ void initDataPort(RunTimeOpts *rtOpts, PtpPortDS *ptpPortDS)
PTPD_TRACE(TRACE_BMC, ptpPortDS, "initDataPort\n"); PTPD_TRACE(TRACE_BMC, ptpPortDS, "initDataPort\n");
ptpPortDS->doRestart = FALSE;
/*init clockIdentity with MAC address and 0xFF and 0xFE. see spec 7.5.2.2.2*/ /*init clockIdentity with MAC address and 0xFF and 0xFE. see spec 7.5.2.2.2*/
//TODO (11): should be in initDataClock() //TODO (11): should be in initDataClock()
for (i=0;i<CLOCK_IDENTITY_LENGTH;i++) for (i=0;i<CLOCK_IDENTITY_LENGTH;i++)
...@@ -139,6 +139,8 @@ void initDataClock(RunTimeOpts *rtOpts, PtpClockDS *ptpClockDS) ...@@ -139,6 +139,8 @@ void initDataClock(RunTimeOpts *rtOpts, PtpClockDS *ptpClockDS)
/*Local clock is becoming Master. Table 13 (9.3.5) of the spec.*/ /*Local clock is becoming Master. Table 13 (9.3.5) of the spec.*/
void m1(PtpPortDS *ptpPortDS) void m1(PtpPortDS *ptpPortDS)
{ {
#if 0
/*Current data set update*/ /*Current data set update*/
ptpPortDS->ptpClockDS->stepsRemoved = 0; ptpPortDS->ptpClockDS->stepsRemoved = 0;
ptpPortDS->ptpClockDS->offsetFromMaster.nanoseconds = 0; ptpPortDS->ptpClockDS->offsetFromMaster.nanoseconds = 0;
...@@ -147,6 +149,7 @@ void m1(PtpPortDS *ptpPortDS) ...@@ -147,6 +149,7 @@ void m1(PtpPortDS *ptpPortDS)
ptpPortDS->ptpClockDS->meanPathDelay.seconds = 0; ptpPortDS->ptpClockDS->meanPathDelay.seconds = 0;
/*Parent data set*/ /*Parent data set*/
memcpy(ptpPortDS->ptpClockDS->parentPortIdentity.clockIdentity,ptpPortDS->clockIdentity,CLOCK_IDENTITY_LENGTH); memcpy(ptpPortDS->ptpClockDS->parentPortIdentity.clockIdentity,ptpPortDS->clockIdentity,CLOCK_IDENTITY_LENGTH);
ptpPortDS->ptpClockDS->parentPortIdentity.portNumber = 0; ptpPortDS->ptpClockDS->parentPortIdentity.portNumber = 0;
ptpPortDS->ptpClockDS->parentStats = DEFAULT_PARENTS_STATS; ptpPortDS->ptpClockDS->parentStats = DEFAULT_PARENTS_STATS;
...@@ -158,6 +161,7 @@ void m1(PtpPortDS *ptpPortDS) ...@@ -158,6 +161,7 @@ void m1(PtpPortDS *ptpPortDS)
ptpPortDS->ptpClockDS->grandmasterClockQuality.offsetScaledLogVariance = ptpPortDS->ptpClockDS->clockQuality.offsetScaledLogVariance; ptpPortDS->ptpClockDS->grandmasterClockQuality.offsetScaledLogVariance = ptpPortDS->ptpClockDS->clockQuality.offsetScaledLogVariance;
ptpPortDS->ptpClockDS->grandmasterPriority1 = ptpPortDS->ptpClockDS->priority1; ptpPortDS->ptpClockDS->grandmasterPriority1 = ptpPortDS->ptpClockDS->priority1;
ptpPortDS->ptpClockDS->grandmasterPriority2 = ptpPortDS->ptpClockDS->priority2; ptpPortDS->ptpClockDS->grandmasterPriority2 = ptpPortDS->ptpClockDS->priority2;
#endif
/*White Rabbit*/ /*White Rabbit*/
ptpPortDS->parentWrConfig = ptpPortDS->wrConfig; ptpPortDS->parentWrConfig = ptpPortDS->wrConfig;
...@@ -172,6 +176,7 @@ void m1(PtpPortDS *ptpPortDS) ...@@ -172,6 +176,7 @@ void m1(PtpPortDS *ptpPortDS)
ptpPortDS->ptpClockDS->primarySlavePortNumber=0; ptpPortDS->ptpClockDS->primarySlavePortNumber=0;
} }
void m3(PtpPortDS *ptpPortDS) void m3(PtpPortDS *ptpPortDS)
{ {
ptpPortDS->wrSlaveRole = NON_SLAVE; ptpPortDS->wrSlaveRole = NON_SLAVE;
......
...@@ -231,6 +231,7 @@ typedef struct { ...@@ -231,6 +231,7 @@ typedef struct {
Integer32 seconds; Integer32 seconds;
Integer32 nanoseconds; Integer32 nanoseconds;
Integer32 phase; Integer32 phase;
int correct;
} TimeInternal; } TimeInternal;
/** /**
...@@ -664,6 +665,7 @@ typedef struct { ...@@ -664,6 +665,7 @@ typedef struct {
* or disconnected * or disconnected
*/ */
Boolean linkUP; Boolean linkUP;
Boolean doRestart;
} PtpPortDS; } PtpPortDS;
......
...@@ -107,6 +107,7 @@ typedef struct { ...@@ -107,6 +107,7 @@ typedef struct {
int32_t fiber_fix_alpha; int32_t fiber_fix_alpha;
int32_t clock_period_ps; int32_t clock_period_ps;
int missed_iters;
} wr_servo_state_t; } wr_servo_state_t;
......
...@@ -186,7 +186,8 @@ int wr_servo_init(PtpPortDS *clock) ...@@ -186,7 +186,8 @@ int wr_servo_init(PtpPortDS *clock)
s->state = WR_SYNC_TAI; s->state = WR_SYNC_TAI;
s->cur_setpoint = 0; s->cur_setpoint = 0;
s->missed_iters = 0;
s->delta_tx_m = ((((int32_t)clock->otherNodeDeltaTx.scaledPicoseconds.lsb) >> 16) & 0xffff) | (((int32_t)clock->otherNodeDeltaTx.scaledPicoseconds.msb) << 16); s->delta_tx_m = ((((int32_t)clock->otherNodeDeltaTx.scaledPicoseconds.lsb) >> 16) & 0xffff) | (((int32_t)clock->otherNodeDeltaTx.scaledPicoseconds.msb) << 16);
s->delta_rx_m = ((((int32_t)clock->otherNodeDeltaRx.scaledPicoseconds.lsb) >> 16) & 0xffff) | (((int32_t)clock->otherNodeDeltaRx.scaledPicoseconds.msb) << 16); s->delta_rx_m = ((((int32_t)clock->otherNodeDeltaRx.scaledPicoseconds.lsb) >> 16) & 0xffff) | (((int32_t)clock->otherNodeDeltaRx.scaledPicoseconds.msb) << 16);
...@@ -213,6 +214,8 @@ int wr_servo_init(PtpPortDS *clock) ...@@ -213,6 +214,8 @@ int wr_servo_init(PtpPortDS *clock)
servo_state_valid = 1; servo_state_valid = 1;
cur_servo_state.valid = 1; cur_servo_state.valid = 1;
cur_servo_state.update_count = 0;
got_sync = 0; got_sync = 0;
return 0; return 0;
} }
...@@ -241,7 +244,7 @@ int wr_servo_got_sync(PtpPortDS *clock, TimeInternal t1, TimeInternal t2) ...@@ -241,7 +244,7 @@ int wr_servo_got_sync(PtpPortDS *clock, TimeInternal t1, TimeInternal t2)
s->t1 = timeint_to_wr(t1); s->t1 = timeint_to_wr(t1);
s->t1.correct = 1; s->t1.correct = 1;
s->t2 = timeint_to_wr(t2); s->t2 = timeint_to_wr(t2);
s->t2.correct = 1; s->t2.correct = t2.correct;
got_sync = 1; got_sync = 1;
...@@ -255,7 +258,7 @@ int wr_servo_got_delay(PtpPortDS *clock, Integer32 cf) ...@@ -255,7 +258,7 @@ int wr_servo_got_delay(PtpPortDS *clock, Integer32 cf)
s->t3 = clock->delayReq_tx_ts; s->t3 = clock->delayReq_tx_ts;
// s->t3.phase = 0; // s->t3.phase = 0;
s->t4 = timeint_to_wr(clock->delay_req_receive_time); s->t4 = timeint_to_wr(clock->delay_req_receive_time);
s->t4.correct = 1; s->t4.correct = 1; //clock->delay_req_receive_time.correct;
s->t4.phase = (int64_t) cf * 1000LL / 65536LL; s->t4.phase = (int64_t) cf * 1000LL / 65536LL;
return 0; return 0;
} }
...@@ -282,42 +285,25 @@ int wr_servo_update(PtpPortDS *clock) ...@@ -282,42 +285,25 @@ int wr_servo_update(PtpPortDS *clock)
return 0; return 0;
} }
cur_servo_state.update_count++;
got_sync = 0; got_sync = 0;
if (1) { /* enable for debugging */ if (0) { /* enable for debugging */
dump_timestamp("servo:t1", s->t1); dump_timestamp("servo:t1", s->t1);
dump_timestamp("servo:t2", s->t2); dump_timestamp("servo:t2", s->t2);
dump_timestamp("servo:t3", s->t3); dump_timestamp("servo:t3", s->t3);
dump_timestamp("servo:t4", s->t4); dump_timestamp("servo:t4", s->t4);
dump_timestamp("->mdelay", s->mu); dump_timestamp("->mdelay", s->mu);
fprintf(stderr,"servo:fix_alpha %d, period %dps\n", s->fiber_fix_alpha, s->clock_period_ps);
} }
#if 0
//merge problem: do we need it??
alpha = 1.4682e-04*1.76; // EXPERIMENTALLY DERIVED. VALID.
big_delta = (double) s->delta_tx_m + (double) s->delta_tx_s
+ (double) s->delta_rx_m + (double) s->delta_rx_s;
// fiber part (first line) + PHY/routing part (second line)
delay_ms = ((double)ts_to_picos(s->mu) - big_delta) * ((1.0 + alpha) / (2.0 + alpha))
+ (double)s->delta_tx_m + (double) s->delta_rx_s + ph_adjust;
printf("delay_ms [float] = %.0f ps\n", delay_ms);
#endif
s->mu = ts_sub(ts_sub(s->t4, s->t1), ts_sub(s->t3, s->t2)); s->mu = ts_sub(ts_sub(s->t4, s->t1), ts_sub(s->t3, s->t2));
big_delta_fix = s->delta_tx_m + s->delta_tx_s big_delta_fix = s->delta_tx_m + s->delta_tx_s
+ s->delta_rx_m + s->delta_rx_s; + s->delta_rx_m + s->delta_rx_s;
fprintf(stderr,"servo:mu_nodeltas: %lld\n", ts_to_picos(s->mu) - big_delta_fix);
delay_ms_fix = (((int64_t)(ts_to_picos(s->mu) - big_delta_fix) * (int64_t) s->fiber_fix_alpha) >> FIX_ALPHA_FRACBITS) delay_ms_fix = (((int64_t)(ts_to_picos(s->mu) - big_delta_fix) * (int64_t) s->fiber_fix_alpha) >> FIX_ALPHA_FRACBITS)
+ ((ts_to_picos(s->mu) - big_delta_fix) >> 1) + ((ts_to_picos(s->mu) - big_delta_fix) >> 1)
+ s->delta_tx_m + s->delta_rx_s + ph_adjust; + s->delta_tx_m + s->delta_rx_s + ph_adjust;
...@@ -326,13 +312,9 @@ int wr_servo_update(PtpPortDS *clock) ...@@ -326,13 +312,9 @@ int wr_servo_update(PtpPortDS *clock)
ts_offset = ts_add(ts_sub(s->t1, s->t2), picos_to_ts(delay_ms_fix)); ts_offset = ts_add(ts_sub(s->t1, s->t2), picos_to_ts(delay_ms_fix));
ts_offset_hw = ts_hardwarize(ts_offset, s->clock_period_ps); ts_offset_hw = ts_hardwarize(ts_offset, s->clock_period_ps);
/* dump_timestamp("Offset", ts_offset);
dump_timestamp("OffsetHW", ts_offset_hw);*/
cur_servo_state.mu = (uint64_t)ts_to_picos(s->mu); cur_servo_state.mu = (uint64_t)ts_to_picos(s->mu);
cur_servo_state.cur_offset = ts_to_picos(ts_offset); cur_servo_state.cur_offset = ts_to_picos(ts_offset);
cur_servo_state.delay_ms = delay_ms_fix; cur_servo_state.delay_ms = delay_ms_fix;
cur_servo_state.total_asymmetry = cur_servo_state.total_asymmetry =
(cur_servo_state.mu - 2LL * (int64_t)delay_ms_fix); (cur_servo_state.mu - 2LL * (int64_t)delay_ms_fix);
...@@ -347,9 +329,17 @@ int wr_servo_update(PtpPortDS *clock) ...@@ -347,9 +329,17 @@ int wr_servo_update(PtpPortDS *clock)
tics = ptpd_netif_get_msec_tics(); tics = ptpd_netif_get_msec_tics();
dump_timestamp("servo:HWOffset", ts_offset_hw); PTPD_TRACE(TRACE_SERVO, NULL, "servo:HWOffset", ts_offset_hw);
PTPD_TRACE(TRACE_SERVO, NULL, "servo:state: %d\n", s->state); PTPD_TRACE(TRACE_SERVO, NULL, "servo:state: %d\n", s->state);
if(ptpd_netif_locking_poll(0, clock->netPath.ifaceName, 0) != PTPD_NETIF_READY)
{
PTPD_TRACE(TRACE_SERVO, NULL, "PLL OutOfLock, restarting sync\n");
ptpd_netif_enable_timing_output(0);
clock->doRestart = TRUE;
}
switch(s->state) switch(s->state)
{ {
case WR_WAIT_SYNC_IDLE: case WR_WAIT_SYNC_IDLE:
...@@ -362,6 +352,8 @@ int wr_servo_update(PtpPortDS *clock) ...@@ -362,6 +352,8 @@ int wr_servo_update(PtpPortDS *clock)
break; break;
case WR_SYNC_TAI: case WR_SYNC_TAI:
ptpd_netif_enable_timing_output(0);
if(ts_offset_hw.utc != 0) if(ts_offset_hw.utc != 0)
{ {
strcpy(cur_servo_state.slave_servo_state, "SYNC_UTC"); strcpy(cur_servo_state.slave_servo_state, "SYNC_UTC");
...@@ -405,11 +397,16 @@ int wr_servo_update(PtpPortDS *clock) ...@@ -405,11 +397,16 @@ int wr_servo_update(PtpPortDS *clock)
{ {
int64_t remaining_offset = abs(ts_to_picos(ts_offset_hw)); int64_t remaining_offset = abs(ts_to_picos(ts_offset_hw));
if(remaining_offset < WR_SERVO_OFFSET_STABILITY_THRESHOLD) if(ts_offset_hw.utc !=0 || ts_offset_hw.nsec != 0)
s->state = WR_SYNC_TAI;
else if(remaining_offset < WR_SERVO_OFFSET_STABILITY_THRESHOLD)
{ {
ptpd_netif_enable_timing_output(1); ptpd_netif_enable_timing_output(1);
s->state = WR_TRACK_PHASE; s->state = WR_TRACK_PHASE;
} } else s->missed_iters++;
if(s->missed_iters >= 10)
s->state = WR_SYNC_TAI;
break; break;
} }
...@@ -419,6 +416,9 @@ int wr_servo_update(PtpPortDS *clock) ...@@ -419,6 +416,9 @@ int wr_servo_update(PtpPortDS *clock)
cur_servo_state.cur_setpoint = s->cur_setpoint; cur_servo_state.cur_setpoint = s->cur_setpoint;
cur_servo_state.cur_skew = s->delta_ms - s->delta_ms_prev; cur_servo_state.cur_skew = s->delta_ms - s->delta_ms_prev;
if(ts_offset_hw.utc !=0 || ts_offset_hw.nsec != 0)
s->state = WR_SYNC_TAI;
if(tracking_enabled) if(tracking_enabled)
{ {
// pps_gen_enable_output(1); // pps_gen_enable_output(1);
......
...@@ -45,7 +45,6 @@ void issuePDelayRespFollowUp(TimeInternal*,MsgHeader*,RunTimeOpts*,PtpPortDS*); ...@@ -45,7 +45,6 @@ void issuePDelayRespFollowUp(TimeInternal*,MsgHeader*,RunTimeOpts*,PtpPortDS*);
* 'port_state' by calling toState(), but once they are done we loop around * 'port_state' by calling toState(), but once they are done we loop around
* again and perform the actions required for the new 'port_state'. * again and perform the actions required for the new 'port_state'.
*/ */
#ifndef WRPC_EXTRA_SLIM
void singlePortLoop(RunTimeOpts *rtOpts, PtpPortDS *ptpPortDS, int portIndex) void singlePortLoop(RunTimeOpts *rtOpts, PtpPortDS *ptpPortDS, int portIndex)
{ {
...@@ -53,18 +52,21 @@ void singlePortLoop(RunTimeOpts *rtOpts, PtpPortDS *ptpPortDS, int portIndex) ...@@ -53,18 +52,21 @@ void singlePortLoop(RunTimeOpts *rtOpts, PtpPortDS *ptpPortDS, int portIndex)
link_up = isPortUp(&ptpPortDS->netPath); link_up = isPortUp(&ptpPortDS->netPath);
if(link_up && !ptpPortDS->linkUP) if(link_up && !ptpPortDS->linkUP)
went_up = TRUE; went_up = TRUE;
else if(!link_up && ptpPortDS->linkUP) else if(!link_up && ptpPortDS->linkUP)
went_down = TRUE; went_down = TRUE;
if(went_up) if(went_up || ptpPortDS->doRestart)
{ {
toState(PTP_INITIALIZING, rtOpts, ptpPortDS); toState(PTP_INITIALIZING, rtOpts, ptpPortDS);
if(!doInit(rtOpts, ptpPortDS)) if(!doInit(rtOpts, ptpPortDS))
PTPD_TRACE(TRACE_ERROR, ptpPortDS,"Port %d failed to doInit()\n",(portIndex+1)); PTPD_TRACE(TRACE_ERROR, ptpPortDS,"Port %d failed to doInit()\n",(portIndex+1));
clearForeignMasters(ptpPortDS); if(ptpPortDS->wrMode == WR_S_ONLY)
clearForeignMasters(ptpPortDS);
ptpPortDS->doRestart = FALSE;
PTPD_TRACE(TRACE_STARTUP, ptpPortDS, "Port '%s' went up.\n", ptpPortDS->netPath.ifaceName); PTPD_TRACE(TRACE_STARTUP, ptpPortDS, "Port '%s' went up.\n", ptpPortDS->netPath.ifaceName);
} else if(went_down) { } else if(went_down) {
...@@ -73,6 +75,7 @@ void singlePortLoop(RunTimeOpts *rtOpts, PtpPortDS *ptpPortDS, int portIndex) ...@@ -73,6 +75,7 @@ void singlePortLoop(RunTimeOpts *rtOpts, PtpPortDS *ptpPortDS, int portIndex)
if(link_up) if(link_up)
{ {
if(ptpPortDS->portState != PTP_INITIALIZING) if(ptpPortDS->portState != PTP_INITIALIZING)
doState(rtOpts, ptpPortDS); doState(rtOpts, ptpPortDS);
else if(!doInit(rtOpts, ptpPortDS)) else if(!doInit(rtOpts, ptpPortDS))
...@@ -83,6 +86,32 @@ void singlePortLoop(RunTimeOpts *rtOpts, PtpPortDS *ptpPortDS, int portIndex) ...@@ -83,6 +86,32 @@ void singlePortLoop(RunTimeOpts *rtOpts, PtpPortDS *ptpPortDS, int portIndex)
} }
void sharedPortsLoop(PtpPortDS *ptpPortDS)
{
if(ptpPortDS->ptpClockDS->globalStateDecisionEvent)
{
PTPD_TRACE(TRACE_PROTO, ptpPortDS,"update secondary slaves\n");
/* Do after State Decision Even in all the ports */
if(globalSecondSlavesUpdate(ptpPortDS) == FALSE)
PTPD_TRACE(TRACE_PROTO, ptpPortDS,"no secondary slaves\n");
ptpPortDS->ptpClockDS->globalStateDecisionEvent = FALSE;
}
/* Handle Best Master Clock Algorithm globally */
if(globalBestForeignMastersUpdate(ptpPortDS))
{
PTPD_TRACE(TRACE_PROTO, ptpPortDS,"Initiate global State Decision Event\n");
ptpPortDS->ptpClockDS->globalStateDecisionEvent = TRUE;
}
else
ptpPortDS->ptpClockDS->globalStateDecisionEvent = FALSE;
// ptpd_handle_wripc();
checkClockClassValidity(ptpPortDS->ptpClockDS);
}
#ifndef WRPC_EXTRA_SLIM
void multiProtocol(RunTimeOpts *rtOpts, PtpPortDS *ptpPortDS) void multiProtocol(RunTimeOpts *rtOpts, PtpPortDS *ptpPortDS)
{ {
...@@ -105,30 +134,12 @@ void multiProtocol(RunTimeOpts *rtOpts, PtpPortDS *ptpPortDS) ...@@ -105,30 +134,12 @@ void multiProtocol(RunTimeOpts *rtOpts, PtpPortDS *ptpPortDS)
for(;;) for(;;)
{ {
for (i=0; i < rtOpts->portNumber; i++) for (i=0; i < rtOpts->portNumber; i++)
singlePortLoop(rtOpts, &ptpPortDS[i], i); singlePortLoop(rtOpts, &ptpPortDS[i], i);
if(ptpPortDS->ptpClockDS->globalStateDecisionEvent) sharedPortsLoop(ptpPortDS);
{
PTPD_TRACE(TRACE_PROTO, ptpPortDS,"update secondary slaves\n");
/* Do after State Decision Even in all the ports */
if(globalSecondSlavesUpdate(ptpPortDS) == FALSE)
PTPD_TRACE(TRACE_PROTO, ptpPortDS,"no secondary slaves\n");
ptpPortDS->ptpClockDS->globalStateDecisionEvent = FALSE;
}
/* Handle Best Master Clock Algorithm globally */
if(globalBestForeignMastersUpdate(ptpPortDS))
{
PTPD_TRACE(TRACE_PROTO, ptpPortDS,"Initiate global State Decision Event\n");
ptpPortDS->ptpClockDS->globalStateDecisionEvent = TRUE;
}
else
ptpPortDS->ptpClockDS->globalStateDecisionEvent = FALSE;
ptpd_handle_wripc();
checkClockClassValidity(ptpPortDS->ptpClockDS);
usleep(10000); ptpd_handle_wripc();
usleep(1000);
} }
} }
...@@ -649,7 +660,8 @@ void doState(RunTimeOpts *rtOpts, PtpPortDS *ptpPortDS) ...@@ -649,7 +660,8 @@ void doState(RunTimeOpts *rtOpts, PtpPortDS *ptpPortDS)
issueSync(rtOpts, ptpPortDS); issueSync(rtOpts, ptpPortDS);
issueFollowup(rtOpts,ptpPortDS); if(ptpPortDS->synch_tx_ts.correct)
issueFollowup(rtOpts,ptpPortDS);
} }
if(timerExpired(&ptpPortDS->timers.announceInterval)) if(timerExpired(&ptpPortDS->timers.announceInterval))
...@@ -828,7 +840,7 @@ void handleAnnounce(MsgHeader *header, Octet *msgIbuf, ssize_t length, Boolean i ...@@ -828,7 +840,7 @@ void handleAnnounce(MsgHeader *header, Octet *msgIbuf, ssize_t length, Boolean i
{ {
PTPD_TRACE(TRACE_ERROR, NULL,"Too short Announce message\n"); PTPD_TRACE(TRACE_ERROR, NULL,"Too short Announce message\n");
toState(PTP_FAULTY, rtOpts, ptpPortDS); toState(PTP_FAULTY, rtOpts, ptpPortDS);
return; return;
} }
if(length > ANNOUNCE_LENGTH) if(length > ANNOUNCE_LENGTH)
...@@ -899,7 +911,7 @@ void handleAnnounce(MsgHeader *header, Octet *msgIbuf, ssize_t length, Boolean i ...@@ -899,7 +911,7 @@ void handleAnnounce(MsgHeader *header, Octet *msgIbuf, ssize_t length, Boolean i
return; return;
} }
// mprintf("AddForeign!\n");
addForeign(ptpPortDS->msgIbuf,header,ptpPortDS); addForeign(ptpPortDS->msgIbuf,header,ptpPortDS);
ptpPortDS->record_update = TRUE; ptpPortDS->record_update = TRUE;
break; break;
...@@ -950,6 +962,7 @@ void handleSync(MsgHeader *header, Octet *msgIbuf, ssize_t length, TimeInternal ...@@ -950,6 +962,7 @@ void handleSync(MsgHeader *header, Octet *msgIbuf, ssize_t length, TimeInternal
ptpPortDS->sync_receive_time.seconds = ptpPortDS->current_rx_ts.utc; ptpPortDS->sync_receive_time.seconds = ptpPortDS->current_rx_ts.utc;
ptpPortDS->sync_receive_time.nanoseconds = ptpPortDS->current_rx_ts.nsec; ptpPortDS->sync_receive_time.nanoseconds = ptpPortDS->current_rx_ts.nsec;
ptpPortDS->sync_receive_time.phase = ptpPortDS->current_rx_ts.phase; ptpPortDS->sync_receive_time.phase = ptpPortDS->current_rx_ts.phase;
ptpPortDS->sync_receive_time.correct = ptpPortDS->current_rx_ts.correct;
if ((header->flagField[0] & 0x02) == TWO_STEP_FLAG) if ((header->flagField[0] & 0x02) == TWO_STEP_FLAG)
{ {
...@@ -1199,6 +1212,7 @@ void handleDelayResp(MsgHeader *header,Octet *msgIbuf,ssize_t length,Boolean isF ...@@ -1199,6 +1212,7 @@ void handleDelayResp(MsgHeader *header,Octet *msgIbuf,ssize_t length,Boolean isF
ptpPortDS->delay_req_receive_time.seconds = requestReceiptTimestamp.seconds; ptpPortDS->delay_req_receive_time.seconds = requestReceiptTimestamp.seconds;
ptpPortDS->delay_req_receive_time.nanoseconds = requestReceiptTimestamp.nanoseconds; ptpPortDS->delay_req_receive_time.nanoseconds = requestReceiptTimestamp.nanoseconds;
ptpPortDS->delay_req_receive_time.phase = requestReceiptTimestamp.phase; ptpPortDS->delay_req_receive_time.phase = requestReceiptTimestamp.phase;
ptpPortDS->delay_req_receive_time.correct = requestReceiptTimestamp.correct;
/* coppy correctionField from header->cF to local variable (correctionField) */ /* coppy correctionField from header->cF to local variable (correctionField) */
integer64_to_internalTime(header->correctionfield,&correctionField); integer64_to_internalTime(header->correctionfield,&correctionField);
......
...@@ -13,6 +13,8 @@ extern ptpdexp_sync_state_t cur_servo_state; ...@@ -13,6 +13,8 @@ extern ptpdexp_sync_state_t cur_servo_state;
int ptpdexp_get_sync_state(ptpdexp_sync_state_t *state) int ptpdexp_get_sync_state(ptpdexp_sync_state_t *state)
{ {
fprintf(stderr," GSS: valid %d\n", servo_state_valid);
if(servo_state_valid) if(servo_state_valid)
{ {
memcpy(state, &cur_servo_state, sizeof(ptpdexp_sync_state_t)); memcpy(state, &cur_servo_state, sizeof(ptpdexp_sync_state_t));
...@@ -41,6 +43,7 @@ static int export_get_sync_state(const struct minipc_pd *pd, ...@@ -41,6 +43,7 @@ static int export_get_sync_state(const struct minipc_pd *pd,
ptpdexp_sync_state_t state; ptpdexp_sync_state_t state;
ptpdexp_get_sync_state(&state); ptpdexp_get_sync_state(&state);
*(ptpdexp_sync_state_t *)ret = state; *(ptpdexp_sync_state_t *)ret = state;
return 0; return 0;
...@@ -71,8 +74,7 @@ void ptpd_init_exports(void) ...@@ -71,8 +74,7 @@ void ptpd_init_exports(void)
void ptpd_handle_wripc() void ptpd_handle_wripc()
{ {
// fprintf(stderr, "."); minipc_server_action(ptp_ch, 10 /* ms */);
// minipc_server_action(ptp_ch, 200 /* ms */);
} }
#endif #endif
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
typedef struct{ typedef struct{
int valid; int valid;
char slave_servo_state[128]; char slave_servo_state[32];
char sync_source[128]; char sync_source[32];
int tracking_enabled; int tracking_enabled;
int64_t mu; int64_t mu;
int64_t delay_ms; int64_t delay_ms;
...@@ -22,6 +22,7 @@ typedef struct{ ...@@ -22,6 +22,7 @@ typedef struct{
int64_t cur_offset; int64_t cur_offset;
int64_t cur_setpoint; int64_t cur_setpoint;
int64_t cur_skew; int64_t cur_skew;
int64_t update_count;
} ptpdexp_sync_state_t ; } ptpdexp_sync_state_t ;
#define PTPDEXP_COMMAND_TRACKING 1 #define PTPDEXP_COMMAND_TRACKING 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment