From fef2943df520b59fa04bfd2b19502d80d585280b Mon Sep 17 00:00:00 2001 From: skarg Date: Fri, 12 Aug 2016 22:13:40 +0000 Subject: [PATCH] Added a check for a new byte when moving back to IDLE for MS/TP capture utility. --- bacnet-stack/demo/mstpcap/main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bacnet-stack/demo/mstpcap/main.c b/bacnet-stack/demo/mstpcap/main.c index 0c05744e..bb1c7149 100644 --- a/bacnet-stack/demo/mstpcap/main.c +++ b/bacnet-stack/demo/mstpcap/main.c @@ -71,6 +71,8 @@ static volatile struct mstp_port_struct_t MSTP_Port; /* track the receive state to know when there is a broken packet */ static MSTP_RECEIVE_STATE MSTP_Receive_State = MSTP_RECEIVE_STATE_IDLE; +/* track the bytes that are incoming to know when to check for loss */ +static bool DataAvailable; /* buffers needed by mstp port struct */ static uint8_t RxBuffer[MAX_MPDU]; static uint8_t TxBuffer[MAX_MPDU]; @@ -1174,6 +1176,7 @@ int main( /* run forever */ for (;;) { RS485_Check_UART_Data(mstp_port); + DataAvailable = mstp_port->DataAvailable; MSTP_Receive_Frame_FSM(mstp_port); /* process the data portion of the frame */ if (mstp_port->ReceivedValidFrame) { @@ -1192,7 +1195,8 @@ int main( mstp_structure_init(mstp_port); Invalid_Frame_Count++; packet_count++; - } else if (mstp_port->receive_state == MSTP_RECEIVE_STATE_IDLE) { + } else if ((mstp_port->receive_state == MSTP_RECEIVE_STATE_IDLE) && + (DataAvailable)) { if (MSTP_Receive_State == MSTP_RECEIVE_STATE_IDLE) { if (mstp_port->EventCount) { write_received_packet(mstp_port, 1);