Commit 18d76f2f authored by Jean-Claude BAU's avatar Jean-Claude BAU

Slave/Uncalib states: GM detection by BMCA

- When a new GM has been detected by the BMCA, the SLAVE state must
transition to UNCALIBRATED. If the state is already set to UNCALIBRATED
, nothing must be done.
parent 4daf4aec
...@@ -245,7 +245,6 @@ int pp_slave(struct pp_instance *ppi, void *buf, int len) ...@@ -245,7 +245,6 @@ int pp_slave(struct pp_instance *ppi, void *buf, int len)
int ret = PP_SEND_OK; /* error var, to check errors in msg handling */ int ret = PP_SEND_OK; /* error var, to check errors in msg handling */
Boolean uncalibrated = (ppi->state == PPS_UNCALIBRATED); Boolean uncalibrated = (ppi->state == PPS_UNCALIBRATED);
MsgHeader *hdr = &ppi->received_ptp_header; MsgHeader *hdr = &ppi->received_ptp_header;
int newState=ppi->is_new_state;
/* upgrade from uncalibrated to slave or back*/ /* upgrade from uncalibrated to slave or back*/
if (uncalibrated) { if (uncalibrated) {
...@@ -256,23 +255,21 @@ int pp_slave(struct pp_instance *ppi, void *buf, int len) ...@@ -256,23 +255,21 @@ int pp_slave(struct pp_instance *ppi, void *buf, int len)
} else { } else {
ppi->next_state = PPS_SLAVE; ppi->next_state = PPS_SLAVE;
} }
} } else {
/* Check if the foreign master has changed */ /* Check if the foreign master has changed */
if ( DSPAR(ppi)->newGrandmaster ) { if ( DSPAR(ppi)->newGrandmaster ) {
// New grandmaster detected // New grandmaster detected
DSPAR(ppi)->newGrandmaster=FALSE; // Clear it DSPAR(ppi)->newGrandmaster=FALSE; // Clear it
if ( !uncalibrated )
// State must transition from SLAVE to UNCALIBRATED // State must transition from SLAVE to UNCALIBRATED
ppi->next_state =PPS_UNCALIBRATED; ppi->next_state = PPS_UNCALIBRATED;
else
newState=1;// If already in uncalibrated state, force to see it as a new state
Octet *id=DSPAR(ppi)->parentPortIdentity.clockIdentity.id; Octet *id=DSPAR(ppi)->parentPortIdentity.clockIdentity.id;
pp_info("New grandmaster detected: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n", pp_info("New grandmaster detected: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
id[0],id[1],id[2],id[3],id[4],id[5],id[6],id[7]); id[0],id[1],id[2],id[3],id[4],id[5],id[6],id[7]);
}
} }
/* Force to stay on desired state if externalPortConfiguration option is enabled */ /* Force to stay on desired state if externalPortConfiguration option is enabled */
...@@ -282,7 +279,7 @@ int pp_slave(struct pp_instance *ppi, void *buf, int len) ...@@ -282,7 +279,7 @@ int pp_slave(struct pp_instance *ppi, void *buf, int len)
ppi->next_state = PPS_UNCALIBRATED; //Force to stay in uncalibrated state ppi->next_state = PPS_UNCALIBRATED; //Force to stay in uncalibrated state
/* when entering uncalibrated init servo */ /* when entering uncalibrated init servo */
if (uncalibrated && newState) { if (uncalibrated && ppi->is_new_state) {
memset(&ppi->t1, 0, sizeof(ppi->t1)); memset(&ppi->t1, 0, sizeof(ppi->t1));
pp_diag(ppi, bmc, 2, "Entered to uncalibrated, reset servo\n"); pp_diag(ppi, bmc, 2, "Entered to uncalibrated, reset servo\n");
pp_servo_init(ppi); pp_servo_init(ppi);
......
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