let me first explain my scenario. I compiled the source code into a dynamic library and wrote a client program that calls the dynamic library and periodically sends requests to read server properties. The program is in good shape for a while, and this will continue for about a few hours, after which it starts to fail to read the properties intermittently
By turning on the debug option in the Makefile, I found the following log output for the problem scenario:
MSTP: Rx Header: BadCRC [01]
MSTP: Rx Data: SilenceTimer 96ms > 95ms
MSTP: Rx Header: BadCRC [01]
MSTP: Rx Header: BadCRC [55]
MSTP: Rx Header: BadCRC [27]
MSTP: Rx Header: BadCRC [3B]
MSTP: Rx Header: BadCRC [3E]
MSTP: Rx Header: BadCRC [4B]
MSTP: Rx Header: BadCRC [4D]
MSTP: Rx Header: BadCRC [FF]
MSTP: Rx Header: BadCRC [5E]
MSTP: Rx Header: SilenceTimer 96 > 95
MSTP: Rx Header: BadCRC [6E]
MSTP: Rx Header: BadCRC [74]
MSTP: Rx Header: BadCRC [FF]
MSTP: Rx Header: BadCRC [FF]
MSTP: Rx Header: BadCRC [03]
MSTP: Rx Header: BadCRC [FF]
MSTP: Rx Header: BadCRC [55]
MSTP: Rx Header: BadCRC [55]
MSTP: Rx Header: BadCRC [55]
MSTP: Rx Header: BadCRC [FF]
MSTP: Rx Header: BadCRC [55]
MSTP: Rx Header: BadCRC [FF]
MSTP: Rx Header: BadCRC [00]
MSTP: Rx Header: BadCRC [45]
MSTP: Rx Header: BadCRC [FF]
MSTP: Rx Header: BadCRC [55]
MSTP: Rx Header: BadCRC [55]
MSTP: Rx Header: BadCRC [55]
MSTP: Rx Header: BadCRC [FF]
MSTP: Rx Header: BadCRC [00]
MSTP: Rx Header: BadCRC [55]
MSTP: Rx Header: BadCRC [FF]
By looking at the source code, I found that the error reported was an error in the header crc checksum, after which this frame of data would be flagged as illegal and the program would continue to look for the leading code for the next frame. Logically, a frame of data j checksum error should not logically have a continuous effect on the next frame of data, but the actual result was different from what was expected.
The function with the error: bacnet-stack-1.0.0/ports/linux/dlmstp.c - MSTP_Receive_Frame_FSM
The code is as follows:
case MSTP_RECEIVE_STATE_HEADER.
/* Timeout */
if (mstp_port->SilenceTimer((void *)mstp_port) > Tframe_abort) {
/* indicate that an error has occurred during the reception of a
* frame */
mstp_port->ReceivedInvalidFrame = true.
/* wait for the start of a frame. */
mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE.
debug_printf("MSTP: Rx Header. SilenceTimer %u > %d\n".
(unsigned)mstp_port->SilenceTimer((void *)mstp_port).
Tframe_abort).
}
/* don't wait for next state - do it here */
if (mstp_port->HeaderCRC != 0x55) {
/* BadCRC */
/* indicate that an error has occurred during
the reception of a frame */
mstp_port->ReceivedInvalidFrame = true.
debug_printf("MSTP: Rx Header. BadCRC [%02X], Tframe_abort = %d\n".
mstp_port->DataRegister, Tframe_abort).
/* wait for the start of the next frame. */
mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE.
}
During the error period I grabbed the messages via wireshark, but the messages were normal and there was no error in the crc checksum, so I think the program received the messages and processed the error itself