Commit 0cae0cc0 authored by Aurelio Colosimo's avatar Aurelio Colosimo

White Rabbit: wr_present status implemented

parent 61b2062e
......@@ -6,6 +6,7 @@
#include <ppsi/ppsi.h>
#include <ppsi/diag.h>
#include "common-fun.h"
#include "wr-api.h"
int st_com_execute_slave(struct pp_instance *ppi, int check_delayreq)
{
......@@ -170,6 +171,12 @@ int st_com_slave_handle_announce(struct pp_instance *ppi, unsigned char *buf,
st_com_add_foreign(ppi, buf);
}
if ((DSPOR(ppi)->wrConfig & WR_S_ONLY) &&
(1 /* FIXME: Recommended State, see page 33*/) &&
(DSPOR(ppi)->parentWrConfig & WR_M_ONLY) &&
(!DSPOR(ppi)->wrMode || !DSPOR(ppi)->parentWrModeOn))
ppi->next_state = WRS_PRESENT;
/*Reset Timer handling Announce receipt timeout*/
st_com_restart_annrec_timer(ppi);
......
......@@ -6,6 +6,7 @@
#include <ppsi/ppsi.h>
#include <ppsi/diag.h>
#include "common-fun.h"
#include "wr-api.h"
int pp_listening(struct pp_instance *ppi, unsigned char *pkt, int plen)
{
......@@ -13,6 +14,8 @@ int pp_listening(struct pp_instance *ppi, unsigned char *pkt, int plen)
if (ppi->is_new_state) {
DSPOR(ppi)->portState = PPS_LISTENING;
DSPOR(ppi)->wrMode = NON_WR;
DSPOR(ppi)->wrPortState = WRS_IDLE;
st_com_restart_annrec_timer(ppi);
}
......
......@@ -30,6 +30,9 @@ int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen)
pp_timer_start(1 << DSPOR(ppi)->logMinPdelayReqInterval,
ppi->timers[PP_TIMER_PDELAYREQ]);
/* Send an announce immediately, when becomes master */
if (msg_issue_announce(ppi) < 0)
goto failure;
}
if (st_com_check_record_update(ppi))
......
......@@ -10,7 +10,7 @@ int wr_locked(struct pp_instance *ppi, unsigned char *pkt, int plen)
{
/* FIXME implementation */
if (ppi->is_new_state) {
DSPOR(ppi)->portState = PPS_SLAVE;
DSPOR(ppi)->portState = PPS_UNCALIBRATED;
DSPOR(ppi)->wrPortState = WRS_LOCKED;
ppi->next_delay = PP_DEFAULT_NEXT_DELAY_MS;
}
......
......@@ -8,11 +8,34 @@
int wr_present(struct pp_instance *ppi, unsigned char *pkt, int plen)
{
/* FIXME implementation */
int e = 0;
if (ppi->is_new_state) {
DSPOR(ppi)->portState = PPS_SLAVE;
DSPOR(ppi)->portState = PPS_UNCALIBRATED;
DSPOR(ppi)->wrPortState = WRS_PRESENT;
DSPOR(ppi)->wrMode = WR_SLAVE;
ppi->next_delay = PP_DEFAULT_NEXT_DELAY_MS;
pp_timer_start(DSPOR(ppi)->wrStateTimeout / 1000,
ppi->timers[PP_TIMER_WRS_PRESENT]);
st_com_restart_annrec_timer(ppi);
e = msg_issue_wrsig(ppi, SLAVE_PRESENT);
}
if (pp_timer_expired(ppi->timers[PP_TIMER_WRS_PRESENT])) {
ppi->next_state = PPS_LISTENING;
goto state_updated;
}
return 0;
if (e == 0)
st_com_execute_slave(ppi, 0);
else
ppi->next_state = PPS_FAULTY;
state_updated:
if (ppi->next_state != ppi->state) {
pp_timer_stop(ppi->timers[PP_TIMER_WRS_PRESENT]);
pp_timer_stop(ppi->timers[PP_TIMER_ANN_RECEIPT]);
}
return e;
}
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