Refactor/mstp zero config state machine (#676)

* Changed MS/TP master node self destination checks to be located in receive FSM

* Changed MSTP zero configuration: modified comments for state transition names; modified next station increment; refactored the UUID rand() to not be required by common zero config implementation; added more unit tests.

* Added another context to MS/TP user data to allow additional user data
This commit is contained in:
Steve Karg
2024-06-26 07:43:25 -05:00
committed by GitHub
parent 9e0751f8c9
commit ddb2b43125
16 changed files with 313 additions and 126 deletions
+1
View File
@@ -24,6 +24,7 @@ add_compile_definitions(
BIG_ENDIAN=0
CONFIG_ZTEST=1
BACDL_MSTP=1
MSTP_ZERO_CONFIG_STATION_INCREMENT_MODULO
)
include_directories(
+23
View File
@@ -643,6 +643,7 @@ static void testZeroConfigNode_Init(struct mstp_port_struct_t *mstp_port)
/* configure for Zero Config */
mstp_port->ZeroConfigEnabled = true;
mstp_port->This_Station = 255;
MSTP_Zero_Config_UUID_Init(mstp_port);
MSTP_Init(mstp_port);
zassert_true(mstp_port->master_state == MSTP_MASTER_STATE_INITIALIZE, NULL);
@@ -1055,6 +1056,7 @@ static void testZeroConfigNode_Test_LURK_ClaimLostToken(
static void testZeroConfigNodeFSM(void)
{
struct mstp_port_struct_t MSTP_Port = { 0 }; /* port data */
unsigned station, next_station, test_station;
/* test case: timeout event */
testZeroConfigNode_Init(&MSTP_Port);
@@ -1117,6 +1119,27 @@ static void testZeroConfigNodeFSM(void)
testZeroConfigNode_Test_IDLE_ValidFrame(&MSTP_Port);
testZeroConfigNode_Test_LURK_Claim(&MSTP_Port);
testZeroConfigNode_Test_LURK_ClaimLostToken(&MSTP_Port);
/* test next station rollover */
station = 0;
test_station = Nmin_poll_station;
next_station = MSTP_Zero_Config_Station_Increment(station);
zassert_equal(next_station, test_station, "station=%u next_station=%u",
station, next_station);
station = Nmin_poll_station;
test_station = Nmin_poll_station + 1;
next_station = MSTP_Zero_Config_Station_Increment(station);
zassert_equal(next_station, test_station, "station=%u next_station=%u",
station, next_station);
station = Nmax_poll_station - 1;
test_station = Nmax_poll_station;
next_station = MSTP_Zero_Config_Station_Increment(station);
zassert_equal(next_station, test_station,"station=%u next_station=%u",
station, next_station);
station = Nmax_poll_station;
test_station = Nmin_poll_station;
next_station = MSTP_Zero_Config_Station_Increment(station);
zassert_equal(next_station, test_station, "station=%u next_station=%u",
station, next_station);
}
/**