indented.
This commit is contained in:
@@ -560,7 +560,8 @@ void MSTP_Receive_Frame_FSM(
|
||||
#endif
|
||||
/* DataOctet */
|
||||
if (mstp_port->Index < mstp_port->DataLength) {
|
||||
mstp_port->DataCRC = CRC_Calc_Data(mstp_port->DataRegister,
|
||||
mstp_port->DataCRC =
|
||||
CRC_Calc_Data(mstp_port->DataRegister,
|
||||
mstp_port->DataCRC);
|
||||
mstp_port->InputBuffer[mstp_port->Index] =
|
||||
mstp_port->DataRegister;
|
||||
@@ -569,14 +570,16 @@ void MSTP_Receive_Frame_FSM(
|
||||
}
|
||||
/* CRC1 */
|
||||
else if (mstp_port->Index == mstp_port->DataLength) {
|
||||
mstp_port->DataCRC = CRC_Calc_Data(mstp_port->DataRegister,
|
||||
mstp_port->DataCRC =
|
||||
CRC_Calc_Data(mstp_port->DataRegister,
|
||||
mstp_port->DataCRC);
|
||||
mstp_port->Index++;
|
||||
mstp_port->receive_state = MSTP_RECEIVE_STATE_DATA;
|
||||
}
|
||||
/* CRC2 */
|
||||
else if (mstp_port->Index == (mstp_port->DataLength + 1)) {
|
||||
mstp_port->DataCRC = CRC_Calc_Data(mstp_port->DataRegister,
|
||||
mstp_port->DataCRC =
|
||||
CRC_Calc_Data(mstp_port->DataRegister,
|
||||
mstp_port->DataCRC);
|
||||
/* STATE DATA CRC - no need for new state */
|
||||
/* indicate the complete reception of a valid frame */
|
||||
@@ -708,26 +711,21 @@ bool MSTP_Master_Node_FSM(
|
||||
#endif
|
||||
|
||||
/* some calculations that several states need */
|
||||
next_poll_station = (mstp_port->Poll_Station + 1) %
|
||||
(mstp_port->Nmax_master + 1);
|
||||
next_this_station = (mstp_port->This_Station + 1) %
|
||||
(mstp_port->Nmax_master + 1);
|
||||
next_next_station = (mstp_port->Next_Station + 1) %
|
||||
(mstp_port->Nmax_master + 1);
|
||||
next_poll_station =
|
||||
(mstp_port->Poll_Station + 1) % (mstp_port->Nmax_master + 1);
|
||||
next_this_station =
|
||||
(mstp_port->This_Station + 1) % (mstp_port->Nmax_master + 1);
|
||||
next_next_station =
|
||||
(mstp_port->Next_Station + 1) % (mstp_port->Nmax_master + 1);
|
||||
#if PRINT_ENABLED_MASTER
|
||||
if (mstp_port->master_state != master_state) {
|
||||
master_state = mstp_port->master_state;
|
||||
fprintf(stderr,
|
||||
"MSTP: TS=%02X[%02X] NS=%02X[%02X] PS=%02X[%02X] EC=%u TC=%u ST=%u %s\n",
|
||||
mstp_port->This_Station,
|
||||
next_this_station,
|
||||
mstp_port->Next_Station,
|
||||
next_next_station,
|
||||
mstp_port->Poll_Station,
|
||||
next_poll_station,
|
||||
mstp_port->EventCount,
|
||||
mstp_port->TokenCount,
|
||||
mstp_port->SilenceTimer,
|
||||
mstp_port->This_Station, next_this_station,
|
||||
mstp_port->Next_Station, next_next_station,
|
||||
mstp_port->Poll_Station, next_poll_station, mstp_port->EventCount,
|
||||
mstp_port->TokenCount, mstp_port->SilenceTimer,
|
||||
mstp_master_state_text(mstp_port->master_state));
|
||||
}
|
||||
#endif
|
||||
@@ -763,17 +761,14 @@ bool MSTP_Master_Node_FSM(
|
||||
#if PRINT_ENABLED_MASTER
|
||||
fprintf(stderr,
|
||||
"MSTP: ReceivedValidFrame Src=%02X Dest=%02X DataLen=%u FC=%u ST=%u Type=%s\n",
|
||||
mstp_port->SourceAddress,
|
||||
mstp_port->DestinationAddress,
|
||||
mstp_port->DataLength,
|
||||
mstp_port->FrameCount,
|
||||
mstp_port->SourceAddress, mstp_port->DestinationAddress,
|
||||
mstp_port->DataLength, mstp_port->FrameCount,
|
||||
mstp_port->SilenceTimer,
|
||||
mstp_frame_type_text(mstp_port->FrameType));
|
||||
#endif
|
||||
/* destined for me! */
|
||||
if ((mstp_port->DestinationAddress ==
|
||||
mstp_port->This_Station) ||
|
||||
(mstp_port->DestinationAddress ==
|
||||
if ((mstp_port->DestinationAddress == mstp_port->This_Station)
|
||||
|| (mstp_port->DestinationAddress ==
|
||||
MSTP_BROADCAST_ADDRESS)) {
|
||||
switch (mstp_port->FrameType) {
|
||||
/* ReceivedToken */
|
||||
@@ -964,10 +959,9 @@ bool MSTP_Master_Node_FSM(
|
||||
/* address at which a new master node may be found in that case. */
|
||||
mstp_port->TokenCount++;
|
||||
/* transmit a Token frame to NS */
|
||||
MSTP_Create_And_Send_Frame(mstp_port,
|
||||
FRAME_TYPE_TOKEN,
|
||||
mstp_port->Next_Station,
|
||||
mstp_port->This_Station, NULL, 0);
|
||||
MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TOKEN,
|
||||
mstp_port->Next_Station, mstp_port->This_Station, NULL,
|
||||
0);
|
||||
mstp_port->RetryCount = 0;
|
||||
mstp_port->EventCount = 0;
|
||||
mstp_port->master_state = MSTP_MASTER_STATE_PASS_TOKEN;
|
||||
@@ -991,10 +985,9 @@ bool MSTP_Master_Node_FSM(
|
||||
/* ResetMaintenancePFM */
|
||||
mstp_port->Poll_Station = mstp_port->This_Station;
|
||||
/* transmit a Token frame to NS */
|
||||
MSTP_Create_And_Send_Frame(mstp_port,
|
||||
FRAME_TYPE_TOKEN,
|
||||
mstp_port->Next_Station,
|
||||
mstp_port->This_Station, NULL, 0);
|
||||
MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TOKEN,
|
||||
mstp_port->Next_Station, mstp_port->This_Station, NULL,
|
||||
0);
|
||||
mstp_port->RetryCount = 0;
|
||||
mstp_port->TokenCount = 1; /* changed in Errata SSPC-135-2004 */
|
||||
mstp_port->EventCount = 0;
|
||||
@@ -1004,8 +997,8 @@ bool MSTP_Master_Node_FSM(
|
||||
/* SendMaintenancePFM */
|
||||
mstp_port->Poll_Station = next_poll_station;
|
||||
MSTP_Create_And_Send_Frame(mstp_port,
|
||||
FRAME_TYPE_POLL_FOR_MASTER,
|
||||
mstp_port->Poll_Station, mstp_port->This_Station, NULL, 0);
|
||||
FRAME_TYPE_POLL_FOR_MASTER, mstp_port->Poll_Station,
|
||||
mstp_port->This_Station, NULL, 0);
|
||||
mstp_port->RetryCount = 0;
|
||||
mstp_port->master_state = MSTP_MASTER_STATE_POLL_FOR_MASTER;
|
||||
}
|
||||
@@ -1027,8 +1020,7 @@ bool MSTP_Master_Node_FSM(
|
||||
/* RetrySendToken */
|
||||
mstp_port->RetryCount++;
|
||||
/* Transmit a Token frame to NS */
|
||||
MSTP_Create_And_Send_Frame(mstp_port,
|
||||
FRAME_TYPE_TOKEN,
|
||||
MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TOKEN,
|
||||
mstp_port->Next_Station, mstp_port->This_Station, NULL,
|
||||
0);
|
||||
mstp_port->EventCount = 0;
|
||||
@@ -1040,9 +1032,8 @@ bool MSTP_Master_Node_FSM(
|
||||
mstp_port->Poll_Station = next_next_station;
|
||||
/* Transmit a Poll For Master frame to PS. */
|
||||
MSTP_Create_And_Send_Frame(mstp_port,
|
||||
FRAME_TYPE_POLL_FOR_MASTER,
|
||||
mstp_port->Poll_Station, mstp_port->This_Station, NULL,
|
||||
0);
|
||||
FRAME_TYPE_POLL_FOR_MASTER, mstp_port->Poll_Station,
|
||||
mstp_port->This_Station, NULL, 0);
|
||||
/* no known successor node */
|
||||
mstp_port->Next_Station = mstp_port->This_Station;
|
||||
mstp_port->RetryCount = 0;
|
||||
@@ -1079,9 +1070,8 @@ bool MSTP_Master_Node_FSM(
|
||||
mstp_port->Poll_Station = next_this_station;
|
||||
/* Transmit a Poll For Master frame to PS. */
|
||||
MSTP_Create_And_Send_Frame(mstp_port,
|
||||
FRAME_TYPE_POLL_FOR_MASTER,
|
||||
mstp_port->Poll_Station, mstp_port->This_Station, NULL,
|
||||
0);
|
||||
FRAME_TYPE_POLL_FOR_MASTER, mstp_port->Poll_Station,
|
||||
mstp_port->This_Station, NULL, 0);
|
||||
/* indicate that the next station is unknown */
|
||||
mstp_port->Next_Station = mstp_port->This_Station;
|
||||
mstp_port->RetryCount = 0;
|
||||
@@ -1107,8 +1097,7 @@ bool MSTP_Master_Node_FSM(
|
||||
mstp_port->Next_Station = mstp_port->SourceAddress;
|
||||
mstp_port->EventCount = 0;
|
||||
/* Transmit a Token frame to NS */
|
||||
MSTP_Create_And_Send_Frame(mstp_port,
|
||||
FRAME_TYPE_TOKEN,
|
||||
MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TOKEN,
|
||||
mstp_port->Next_Station, mstp_port->This_Station, NULL,
|
||||
0);
|
||||
mstp_port->Poll_Station = mstp_port->This_Station;
|
||||
@@ -1141,8 +1130,7 @@ bool MSTP_Master_Node_FSM(
|
||||
/* poll for a master at address PS. */
|
||||
mstp_port->EventCount = 0;
|
||||
/* transmit a Token frame to NS */
|
||||
MSTP_Create_And_Send_Frame(mstp_port,
|
||||
FRAME_TYPE_TOKEN,
|
||||
MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TOKEN,
|
||||
mstp_port->Next_Station, mstp_port->This_Station,
|
||||
NULL, 0);
|
||||
mstp_port->RetryCount = 0;
|
||||
@@ -1214,8 +1202,7 @@ bool MSTP_Master_Node_FSM(
|
||||
/* and enter the IDLE state. */
|
||||
{
|
||||
MSTP_Create_And_Send_Frame(mstp_port,
|
||||
FRAME_TYPE_REPLY_POSTPONED,
|
||||
mstp_port->SourceAddress,
|
||||
FRAME_TYPE_REPLY_POSTPONED, mstp_port->SourceAddress,
|
||||
mstp_port->This_Station, NULL, 0);
|
||||
mstp_port->master_state = MSTP_MASTER_STATE_IDLE;
|
||||
transition_now = true;
|
||||
|
||||
Reference in New Issue
Block a user