From 69fad0502a65e85008ff8bdbdf622cd81fcf97b2 Mon Sep 17 00:00:00 2001 From: skarg Date: Thu, 17 Sep 2009 03:38:20 +0000 Subject: [PATCH] Changed MS/TP idle state: when no-token timeout occurs, clear the receive frame flags in case a message was received and timeout occurred, which may cause MS/TP to stop working in optimized dlmstp loops which don't check for new events when either of those flags are set. Thank you, Jason! --- bacnet-stack/ports/at91sam7s/dlmstp.c | 4 ++++ bacnet-stack/ports/atmega168/dlmstp.c | 4 ++++ bacnet-stack/ports/bdk-atxx4-mstp/dlmstp.c | 4 ++++ bacnet-stack/ports/pic18f6720/mstp.c | 4 ++++ bacnet-stack/ports/rtos32/mstp.c | 4 ++++ bacnet-stack/src/mstp.c | 4 ++++ 6 files changed, 24 insertions(+) diff --git a/bacnet-stack/ports/at91sam7s/dlmstp.c b/bacnet-stack/ports/at91sam7s/dlmstp.c index 07cf54f8..26fa122b 100644 --- a/bacnet-stack/ports/at91sam7s/dlmstp.c +++ b/bacnet-stack/ports/at91sam7s/dlmstp.c @@ -727,6 +727,10 @@ static bool MSTP_Master_Node_FSM( /* assume that the token has been lost */ EventCount = 0; /* Addendum 135-2004d-8 */ Master_State = MSTP_MASTER_STATE_NO_TOKEN; + /* set the receive frame flags to false in case we received + some bytes and had a timeout for some reason */ + MSTP_Flag.ReceivedValidFrame = false; + MSTP_Flag.ReceivedInvalidFrame = false; transition_now = true; } else if (MSTP_Flag.ReceivedInvalidFrame == true) { /* ReceivedInvalidFrame */ diff --git a/bacnet-stack/ports/atmega168/dlmstp.c b/bacnet-stack/ports/atmega168/dlmstp.c index 597dc18a..134276cf 100644 --- a/bacnet-stack/ports/atmega168/dlmstp.c +++ b/bacnet-stack/ports/atmega168/dlmstp.c @@ -636,6 +636,10 @@ static bool MSTP_Master_Node_FSM( /* assume that the token has been lost */ EventCount = 0; /* Addendum 135-2004d-8 */ Master_State = MSTP_MASTER_STATE_NO_TOKEN; + /* set the receive frame flags to false in case we received + some bytes and had a timeout for some reason */ + MSTP_Flag.ReceivedValidFrame = false; + MSTP_Flag.ReceivedInvalidFrame = false; transition_now = true; } else if (MSTP_Flag.ReceivedInvalidFrame == true) { /* ReceivedInvalidFrame */ diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/dlmstp.c b/bacnet-stack/ports/bdk-atxx4-mstp/dlmstp.c index 597ac54e..952ccc0a 100644 --- a/bacnet-stack/ports/bdk-atxx4-mstp/dlmstp.c +++ b/bacnet-stack/ports/bdk-atxx4-mstp/dlmstp.c @@ -724,6 +724,10 @@ static bool MSTP_Master_Node_FSM( /* assume that the token has been lost */ EventCount = 0; /* Addendum 135-2004d-8 */ Master_State = MSTP_MASTER_STATE_NO_TOKEN; + /* set the receive frame flags to false in case we received + some bytes and had a timeout for some reason */ + MSTP_Flag.ReceivedValidFrame = false; + MSTP_Flag.ReceivedInvalidFrame = false; transition_now = true; } else if (MSTP_Flag.ReceivedInvalidFrame == true) { /* ReceivedInvalidFrame */ diff --git a/bacnet-stack/ports/pic18f6720/mstp.c b/bacnet-stack/ports/pic18f6720/mstp.c index e958a926..3b874024 100644 --- a/bacnet-stack/ports/pic18f6720/mstp.c +++ b/bacnet-stack/ports/pic18f6720/mstp.c @@ -607,6 +607,10 @@ bool MSTP_Master_Node_FSM( /* assume that the token has been lost */ mstp_port->EventCount = 0; /* Addendum 135-2004d-8 */ mstp_port->master_state = MSTP_MASTER_STATE_NO_TOKEN; + /* set the receive frame flags to false in case we received + some bytes and had a timeout for some reason */ + mstp_port->ReceivedInvalidFrame = false; + mstp_port->ReceivedValidFrame = false; transition_now = true; } /* ReceivedInvalidFrame */ diff --git a/bacnet-stack/ports/rtos32/mstp.c b/bacnet-stack/ports/rtos32/mstp.c index e70e3c47..df84e9d4 100644 --- a/bacnet-stack/ports/rtos32/mstp.c +++ b/bacnet-stack/ports/rtos32/mstp.c @@ -742,6 +742,10 @@ bool MSTP_Master_Node_FSM( /* assume that the token has been lost */ mstp_port->EventCount = 0; /* Addendum 135-2004d-8 */ mstp_port->master_state = MSTP_MASTER_STATE_NO_TOKEN; + /* set the receive frame flags to false in case we received + some bytes and had a timeout for some reason */ + mstp_port->ReceivedInvalidFrame = false; + mstp_port->ReceivedValidFrame = false; transition_now = true; } /* ReceivedInvalidFrame */ diff --git a/bacnet-stack/src/mstp.c b/bacnet-stack/src/mstp.c index af672dcf..b885105c 100644 --- a/bacnet-stack/src/mstp.c +++ b/bacnet-stack/src/mstp.c @@ -618,6 +618,10 @@ bool MSTP_Master_Node_FSM( /* assume that the token has been lost */ mstp_port->EventCount = 0; /* Addendum 135-2004d-8 */ mstp_port->master_state = MSTP_MASTER_STATE_NO_TOKEN; + /* set the receive frame flags to false in case we received + some bytes and had a timeout for some reason */ + mstp_port->ReceivedInvalidFrame = false; + mstp_port->ReceivedValidFrame = false; transition_now = true; } else if (mstp_port->ReceivedInvalidFrame == true) { /* ReceivedInvalidFrame */