Fixed MS/TP zero-config FSM getting stuck when duplicate address is detected. (#1048)
This commit is contained in:
@@ -641,6 +641,7 @@ bool MSTP_Master_Node_FSM(struct mstp_port_struct_t *mstp_port)
|
||||
(mstp_port->ReceivedValidFrame == true) &&
|
||||
(mstp_port->SourceAddress == mstp_port->This_Station)) {
|
||||
/* DuplicateNode */
|
||||
mstp_port->This_Station = 255;
|
||||
mstp_port->Zero_Config_State = MSTP_ZERO_CONFIG_STATE_INIT;
|
||||
mstp_port->master_state = MSTP_MASTER_STATE_INITIALIZE;
|
||||
/* ignore the frame */
|
||||
|
||||
@@ -1082,6 +1082,27 @@ static void testZeroConfigNode_Test_LURK_ClaimLostToken(
|
||||
mstp_port->Zero_Config_State, MSTP_ZERO_CONFIG_STATE_IDLE, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
testZeroConfigNode_Test_DuplicateNode(struct mstp_port_struct_t *mstp_port)
|
||||
{
|
||||
bool transition_now;
|
||||
uint8_t station;
|
||||
|
||||
/* ClaimAddressInUse */
|
||||
station = mstp_port->Zero_Config_Station;
|
||||
mstp_port->SourceAddress = station;
|
||||
mstp_port->DestinationAddress = 0;
|
||||
mstp_port->FrameType = FRAME_TYPE_POLL_FOR_MASTER;
|
||||
mstp_port->ReceivedValidFrame = true;
|
||||
transition_now = MSTP_Master_Node_FSM(mstp_port);
|
||||
zassert_false(transition_now, NULL);
|
||||
zassert_true(mstp_port->ReceivedValidFrame == false, NULL);
|
||||
zassert_equal(
|
||||
mstp_port->Zero_Config_State, MSTP_ZERO_CONFIG_STATE_IDLE, NULL);
|
||||
zassert_equal(mstp_port->master_state, MSTP_MASTER_STATE_INITIALIZE, NULL);
|
||||
zassert_equal(mstp_port->This_Station, 255, NULL);
|
||||
}
|
||||
|
||||
static void testZeroConfigNodeFSM(void)
|
||||
{
|
||||
struct mstp_port_struct_t MSTP_Port = { 0 }; /* port data */
|
||||
@@ -1148,6 +1169,14 @@ static void testZeroConfigNodeFSM(void)
|
||||
testZeroConfigNode_Test_IDLE_ValidFrame(&MSTP_Port);
|
||||
testZeroConfigNode_Test_LURK_Claim(&MSTP_Port);
|
||||
testZeroConfigNode_Test_LURK_ClaimLostToken(&MSTP_Port);
|
||||
/* test case: valid frame event LURK PFMs: ClaimAddress
|
||||
ConfirmationSuccessful, DuplicateNode */
|
||||
testZeroConfigNode_Init(&MSTP_Port);
|
||||
testZeroConfigNode_Test_IDLE_ValidFrame(&MSTP_Port);
|
||||
testZeroConfigNode_Test_LURK_Claim(&MSTP_Port);
|
||||
testZeroConfigNode_Test_LURK_ClaimTokenForUs(&MSTP_Port);
|
||||
testZeroConfigNode_Test_LURK_ConfirmationSuccessful(&MSTP_Port);
|
||||
testZeroConfigNode_Test_DuplicateNode(&MSTP_Port);
|
||||
/* test next station rollover */
|
||||
station = 0;
|
||||
test_station = Nmin_poll_station;
|
||||
|
||||
Reference in New Issue
Block a user