Added a check for a new byte when moving back to IDLE for MS/TP capture utility.

This commit is contained in:
skarg
2016-08-12 22:13:40 +00:00
parent 278af89fa2
commit fef2943df5
+5 -1
View File
@@ -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);