Removed the unused state of MSTP_RECEIVE_STATE_HEADER_CRC. Hopefully this doesn't break too many implementations!
This commit is contained in:
+16
-1
@@ -1,6 +1,6 @@
|
||||
all: library readprop writeprop readfile writefile reinit server dcc \
|
||||
whohas whois ucov timesync epics readpropm mstpcap \
|
||||
whoisrouter iamrouter initrouter
|
||||
whoisrouter iamrouter initrouter
|
||||
@echo "utilities are in the bin directory"
|
||||
|
||||
clean: lib/Makefile\
|
||||
@@ -94,3 +94,18 @@ iamrouter: demo/iamrouter/Makefile
|
||||
initrouter: demo/initrouter/Makefile
|
||||
( cd demo/initrouter ; make ; cp bacinitr ../../bin )
|
||||
|
||||
ports: atmega168 at91sam7s bdk-atxx4-mstp
|
||||
echo "Built the ports"
|
||||
|
||||
atmega168: ports/atmega168/Makefile
|
||||
make -C ports/atmega168 clean all
|
||||
|
||||
at91sam7s: ports/at91sam7s/Makefile
|
||||
make -C ports/at91sam7s clean all
|
||||
|
||||
bdk-atxx4-mstp: ports/bdk-atxx4-mstp/Makefile
|
||||
make -C ports/bdk-atxx4-mstp clean all
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -73,8 +73,7 @@ typedef enum {
|
||||
MSTP_RECEIVE_STATE_IDLE = 0,
|
||||
MSTP_RECEIVE_STATE_PREAMBLE = 1,
|
||||
MSTP_RECEIVE_STATE_HEADER = 2,
|
||||
MSTP_RECEIVE_STATE_HEADER_CRC = 3,
|
||||
MSTP_RECEIVE_STATE_DATA = 4
|
||||
MSTP_RECEIVE_STATE_DATA = 3
|
||||
} MSTP_RECEIVE_STATE;
|
||||
|
||||
/* master node FSM states */
|
||||
|
||||
@@ -419,7 +419,6 @@ void MSTP_Receive_Frame_FSM(
|
||||
mstp_port->HeaderCRC);
|
||||
mstp_port->DataAvailable = false;
|
||||
/* don't wait for next state - do it here */
|
||||
/* MSTP_RECEIVE_STATE_HEADER_CRC */
|
||||
if (mstp_port->HeaderCRC != 0x55) {
|
||||
/* BadCRC */
|
||||
/* indicate that an error has occurred during the reception of a frame */
|
||||
@@ -478,10 +477,6 @@ void MSTP_Receive_Frame_FSM(
|
||||
mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
/* In the HEADER_CRC state, the node validates the CRC on the fixed */
|
||||
/* message header. */
|
||||
case MSTP_RECEIVE_STATE_HEADER_CRC:
|
||||
break;
|
||||
/* In the DATA state, the node waits for the data portion of a frame. */
|
||||
case MSTP_RECEIVE_STATE_DATA:
|
||||
|
||||
@@ -40,58 +40,9 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "bacdef.h"
|
||||
#include "mstpdef.h"
|
||||
#include "dlmstp.h"
|
||||
|
||||
/* The value 255 is used to denote broadcast when used as a */
|
||||
/* destination address but is not allowed as a value for a station. */
|
||||
/* Station addresses for master nodes can be 0-127. */
|
||||
/* Station addresses for slave nodes can be 127-254. */
|
||||
#define MSTP_BROADCAST_ADDRESS 255
|
||||
|
||||
/* MS/TP Frame Type */
|
||||
/* Frame Types 8 through 127 are reserved by ASHRAE. */
|
||||
#define FRAME_TYPE_TOKEN 0
|
||||
#define FRAME_TYPE_POLL_FOR_MASTER 1
|
||||
#define FRAME_TYPE_REPLY_TO_POLL_FOR_MASTER 2
|
||||
#define FRAME_TYPE_TEST_REQUEST 3
|
||||
#define FRAME_TYPE_TEST_RESPONSE 4
|
||||
#define FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY 5
|
||||
#define FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY 6
|
||||
#define FRAME_TYPE_REPLY_POSTPONED 7
|
||||
/* Frame Types 128 through 255: Proprietary Frames */
|
||||
/* These frames are available to vendors as proprietary (non-BACnet) frames. */
|
||||
/* The first two octets of the Data field shall specify the unique vendor */
|
||||
/* identification code, most significant octet first, for the type of */
|
||||
/* vendor-proprietary frame to be conveyed. The length of the data portion */
|
||||
/* of a Proprietary frame shall be in the range of 2 to 501 octets. */
|
||||
#define FRAME_TYPE_PROPRIETARY_MIN 128
|
||||
#define FRAME_TYPE_PROPRIETARY_MAX 255
|
||||
/* The initial CRC16 checksum value */
|
||||
#define CRC16_INITIAL_VALUE (0xFFFF)
|
||||
|
||||
|
||||
/* receive FSM states */
|
||||
typedef enum {
|
||||
MSTP_RECEIVE_STATE_IDLE = 0,
|
||||
MSTP_RECEIVE_STATE_PREAMBLE = 1,
|
||||
MSTP_RECEIVE_STATE_HEADER = 2,
|
||||
MSTP_RECEIVE_STATE_HEADER_CRC = 3,
|
||||
MSTP_RECEIVE_STATE_DATA = 4
|
||||
} MSTP_RECEIVE_STATE;
|
||||
|
||||
/* master node FSM states */
|
||||
typedef enum {
|
||||
MSTP_MASTER_STATE_INITIALIZE = 0,
|
||||
MSTP_MASTER_STATE_IDLE = 1,
|
||||
MSTP_MASTER_STATE_USE_TOKEN = 2,
|
||||
MSTP_MASTER_STATE_WAIT_FOR_REPLY = 3,
|
||||
MSTP_MASTER_STATE_DONE_WITH_TOKEN = 4,
|
||||
MSTP_MASTER_STATE_PASS_TOKEN = 5,
|
||||
MSTP_MASTER_STATE_NO_TOKEN = 6,
|
||||
MSTP_MASTER_STATE_POLL_FOR_MASTER = 7,
|
||||
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST = 8
|
||||
} MSTP_MASTER_STATE;
|
||||
|
||||
struct mstp_port_struct_t {
|
||||
MSTP_RECEIVE_STATE receive_state;
|
||||
/* When a master node is powered up or reset, */
|
||||
@@ -203,21 +154,6 @@ struct mstp_port_struct_t {
|
||||
uint8_t TxFrameType; /* type of message - needed by MS/TP */
|
||||
};
|
||||
|
||||
#define DEFAULT_MAX_INFO_FRAMES 1
|
||||
#define DEFAULT_MAX_MASTER 127
|
||||
#define DEFAULT_MAC_ADDRESS 127
|
||||
|
||||
/* The minimum time after the end of the stop bit of the final octet of a */
|
||||
/* received frame before a node may enable its EIA-485 driver: 40 bit times. */
|
||||
/* At 9600 baud, 40 bit times would be about 4.166 milliseconds */
|
||||
/* At 19200 baud, 40 bit times would be about 2.083 milliseconds */
|
||||
/* At 38400 baud, 40 bit times would be about 1.041 milliseconds */
|
||||
/* At 57600 baud, 40 bit times would be about 0.694 milliseconds */
|
||||
/* At 76800 baud, 40 bit times would be about 0.520 milliseconds */
|
||||
/* At 115200 baud, 40 bit times would be about 0.347 milliseconds */
|
||||
/* 40 bits is 4 octets including a start and stop bit with each octet */
|
||||
#define Tturnaround 40
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@@ -255,9 +255,6 @@ char *mstp_receive_state_text(
|
||||
case MSTP_RECEIVE_STATE_HEADER:
|
||||
text = "HEADER";
|
||||
break;
|
||||
case MSTP_RECEIVE_STATE_HEADER_CRC:
|
||||
text = "HEADER_CRC";
|
||||
break;
|
||||
case MSTP_RECEIVE_STATE_DATA:
|
||||
text = "DATA";
|
||||
break;
|
||||
|
||||
@@ -40,58 +40,9 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "bacdef.h"
|
||||
#include "mstpdef.h"
|
||||
#include "dlmstp.h"
|
||||
|
||||
/* The value 255 is used to denote broadcast when used as a */
|
||||
/* destination address but is not allowed as a value for a station. */
|
||||
/* Station addresses for master nodes can be 0-127. */
|
||||
/* Station addresses for slave nodes can be 127-254. */
|
||||
#define MSTP_BROADCAST_ADDRESS 255
|
||||
|
||||
/* MS/TP Frame Type */
|
||||
/* Frame Types 8 through 127 are reserved by ASHRAE. */
|
||||
#define FRAME_TYPE_TOKEN 0
|
||||
#define FRAME_TYPE_POLL_FOR_MASTER 1
|
||||
#define FRAME_TYPE_REPLY_TO_POLL_FOR_MASTER 2
|
||||
#define FRAME_TYPE_TEST_REQUEST 3
|
||||
#define FRAME_TYPE_TEST_RESPONSE 4
|
||||
#define FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY 5
|
||||
#define FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY 6
|
||||
#define FRAME_TYPE_REPLY_POSTPONED 7
|
||||
/* Frame Types 128 through 255: Proprietary Frames */
|
||||
/* These frames are available to vendors as proprietary (non-BACnet) frames. */
|
||||
/* The first two octets of the Data field shall specify the unique vendor */
|
||||
/* identification code, most significant octet first, for the type of */
|
||||
/* vendor-proprietary frame to be conveyed. The length of the data portion */
|
||||
/* of a Proprietary frame shall be in the range of 2 to 501 octets. */
|
||||
#define FRAME_TYPE_PROPRIETARY_MIN 128
|
||||
#define FRAME_TYPE_PROPRIETARY_MAX 255
|
||||
/* The initial CRC16 checksum value */
|
||||
#define CRC16_INITIAL_VALUE (0xFFFF)
|
||||
|
||||
|
||||
/* receive FSM states */
|
||||
typedef enum {
|
||||
MSTP_RECEIVE_STATE_IDLE,
|
||||
MSTP_RECEIVE_STATE_PREAMBLE,
|
||||
MSTP_RECEIVE_STATE_HEADER,
|
||||
MSTP_RECEIVE_STATE_HEADER_CRC,
|
||||
MSTP_RECEIVE_STATE_DATA
|
||||
} MSTP_RECEIVE_STATE;
|
||||
|
||||
/* master node FSM states */
|
||||
typedef enum {
|
||||
MSTP_MASTER_STATE_INITIALIZE,
|
||||
MSTP_MASTER_STATE_IDLE,
|
||||
MSTP_MASTER_STATE_USE_TOKEN,
|
||||
MSTP_MASTER_STATE_WAIT_FOR_REPLY,
|
||||
MSTP_MASTER_STATE_DONE_WITH_TOKEN,
|
||||
MSTP_MASTER_STATE_PASS_TOKEN,
|
||||
MSTP_MASTER_STATE_NO_TOKEN,
|
||||
MSTP_MASTER_STATE_POLL_FOR_MASTER,
|
||||
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST
|
||||
} MSTP_MASTER_STATE;
|
||||
|
||||
struct mstp_port_struct_t {
|
||||
MSTP_RECEIVE_STATE receive_state;
|
||||
/* When a master node is powered up or reset, */
|
||||
@@ -205,14 +156,6 @@ struct mstp_port_struct_t {
|
||||
uint8_t TxFrameType; /* type of message - needed by MS/TP */
|
||||
};
|
||||
|
||||
#define DEFAULT_MAX_INFO_FRAMES 1
|
||||
#define DEFAULT_MAX_MASTER 127
|
||||
|
||||
/* The minimum time after the end of the stop bit of the final octet of a */
|
||||
/* received frame before a node may enable its EIA-485 driver: 40 bit times. */
|
||||
/* At 9600 baud, 40 bit times would be about 4.166 milliseconds */
|
||||
#define Tturnaround 40;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@@ -410,7 +410,6 @@ void MSTP_Receive_Frame_FSM(
|
||||
mstp_port->HeaderCRC);
|
||||
mstp_port->HeaderCRCActual = mstp_port->DataRegister;
|
||||
/* don't wait for next state - do it here */
|
||||
/* MSTP_RECEIVE_STATE_HEADER_CRC */
|
||||
if (mstp_port->HeaderCRC != 0x55) {
|
||||
/* BadCRC */
|
||||
/* indicate that an error has occurred during
|
||||
@@ -482,13 +481,6 @@ void MSTP_Receive_Frame_FSM(
|
||||
mstp_port->DataAvailable = false;
|
||||
}
|
||||
break;
|
||||
/* In the HEADER_CRC state, the node validates the CRC on the fixed */
|
||||
/* message header. */
|
||||
case MSTP_RECEIVE_STATE_HEADER_CRC:
|
||||
/* note: we should never get to this state since we shortcut
|
||||
it earlier in the state machine, and never set this state */
|
||||
mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE;
|
||||
break;
|
||||
/* In the DATA state, the node waits for the data portion of a frame. */
|
||||
case MSTP_RECEIVE_STATE_DATA:
|
||||
/* Timeout */
|
||||
|
||||
@@ -40,7 +40,6 @@ static INDTEXT_DATA mstp_receive_state_text[] = {
|
||||
{MSTP_RECEIVE_STATE_IDLE, "IDLE"},
|
||||
{MSTP_RECEIVE_STATE_PREAMBLE, "PREAMBLE"},
|
||||
{MSTP_RECEIVE_STATE_HEADER, "HEADER"},
|
||||
{MSTP_RECEIVE_STATE_HEADER_CRC, "HEADER_CRC"},
|
||||
{MSTP_RECEIVE_STATE_DATA, "DATA"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user