Commit ebb2fbfb authored by Alessandro Rubini's avatar Alessandro Rubini

proto-standard: return proper millisecs according to next timeout

fsm states where we are waitiing for a frame or for a timeout,
now correctly set next_delay to the right number of milliseconds.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 22fac7c2
......@@ -54,7 +54,7 @@ state_updated:
if (ppi->next_state != ppi->state)
pp_timeout_clr(ppi, PP_TO_ANN_RECEIPT);
ppi->next_delay = PP_DEFAULT_NEXT_DELAY_MS;
ppi->next_delay = pp_ms_to_timeout(ppi, PP_TO_ANN_RECEIPT);
return 0;
}
......@@ -11,7 +11,7 @@ int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen)
{
TimeInternal *time;
TimeInternal *time_snt;
int msgtype;
int msgtype, d1, d2;
int e = 0; /* error var, to check errors in msg handling */
time = &ppi->last_rcv_time;
......@@ -110,6 +110,8 @@ out:
}
state_updated:
ppi->next_delay = PP_DEFAULT_NEXT_DELAY_MS;
d1 = pp_ms_to_timeout(ppi, PP_TO_ANN_INTERVAL);
d2 = pp_ms_to_timeout(ppi, PP_TO_SYNC);
ppi->next_delay = d1 < d2 ? d1 : d2;
return 0;
}
......@@ -12,6 +12,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
int e = 0; /* error var, to check errors in msg handling */
TimeInternal correction_field;
MsgHeader *hdr = &ppi->received_ptp_header;
int d1, d2;
if (ppi->is_new_state) {
DSPOR(ppi)->portState = PPS_SLAVE;
......@@ -139,8 +140,9 @@ state_updated:
pp_init_clock(ppi);
}
ppi->next_delay = PP_DEFAULT_NEXT_DELAY_MS;
d1 = d2 = pp_ms_to_timeout(ppi, PP_TO_ANN_RECEIPT);
if (ppi->timeouts[PP_TO_DELAYREQ])
d2 = pp_ms_to_timeout(ppi, PP_TO_DELAYREQ);
ppi->next_delay = d1 < d2 ? d1 : d2;
return 0;
}
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