Changed the data type of the MS/TP index for the receiving byte to allow an APDU of 480 bytes.
This commit is contained in:
@@ -48,7 +48,7 @@
|
||||
#include "txbuf.h"
|
||||
|
||||
/* This file has been customized for use with small microprocessors */
|
||||
/* Assumptions:
|
||||
/* Assumptions:
|
||||
Only one MS/TP datalink layer
|
||||
*/
|
||||
#include "hardware.h"
|
||||
@@ -124,7 +124,7 @@ static struct mstp_flag_t {
|
||||
/* A Boolean flag set TRUE by the datalink transmit if a
|
||||
pending packet is DataExpectingReply */
|
||||
unsigned TransmitPacketDER:1;
|
||||
/* A Boolean flag set TRUE by the datalink if a
|
||||
/* A Boolean flag set TRUE by the datalink if a
|
||||
packet has been received, but not processed. */
|
||||
unsigned ReceivePacketPending:1;
|
||||
} MSTP_Flag;
|
||||
@@ -366,9 +366,9 @@ static void MSTP_Receive_Frame_FSM(
|
||||
static uint16_t DataCRC = 0;
|
||||
/* Used to accumulate the CRC on the header of a frame. */
|
||||
static uint8_t HeaderCRC = 0;
|
||||
/* Used as an index by the Receive State Machine,
|
||||
/* Used as an index by the Receive State Machine,
|
||||
up to a maximum value of the MPDU */
|
||||
static uint8_t Index = 0;
|
||||
static uint16_t Index = 0;
|
||||
|
||||
switch (Receive_State) {
|
||||
case MSTP_RECEIVE_STATE_IDLE:
|
||||
@@ -388,7 +388,7 @@ static void MSTP_Receive_Frame_FSM(
|
||||
}
|
||||
break;
|
||||
case MSTP_RECEIVE_STATE_PREAMBLE:
|
||||
/* In the PREAMBLE state, the node waits for the
|
||||
/* In the PREAMBLE state, the node waits for the
|
||||
second octet of the preamble. */
|
||||
if (Timer_Silence() > Tframe_abort) {
|
||||
/* Timeout */
|
||||
@@ -468,7 +468,7 @@ static void MSTP_Receive_Frame_FSM(
|
||||
} else if (Index == 5) {
|
||||
/* HeaderCRC */
|
||||
HeaderCRC = CRC_Calc_Header(DataRegister, HeaderCRC);
|
||||
/* In the HEADER_CRC state, the node validates the CRC
|
||||
/* In the HEADER_CRC state, the node validates the CRC
|
||||
on the fixed message header. */
|
||||
if (HeaderCRC != 0x55) {
|
||||
/* BadCRC */
|
||||
@@ -480,7 +480,7 @@ static void MSTP_Receive_Frame_FSM(
|
||||
} else {
|
||||
/* Note: proposed change to BACnet MSTP state machine!
|
||||
If we don't decode data that is not for us, we could
|
||||
get confused about the start if the Preamble 55 FF
|
||||
get confused about the start if the Preamble 55 FF
|
||||
is part of the data. */
|
||||
if ((DataLength) && (DataLength <= InputBufferSize)) {
|
||||
/* Data */
|
||||
@@ -495,7 +495,7 @@ static void MSTP_Receive_Frame_FSM(
|
||||
(DestinationAddress ==
|
||||
MSTP_BROADCAST_ADDRESS)) {
|
||||
/* ForUs */
|
||||
/* indicate that a frame with
|
||||
/* indicate that a frame with
|
||||
no data has been received */
|
||||
MSTP_Flag.ReceivedValidFrame = true;
|
||||
} else {
|
||||
@@ -532,7 +532,7 @@ static void MSTP_Receive_Frame_FSM(
|
||||
/* Error */
|
||||
Timer_Silence_Reset();
|
||||
INCREMENT_AND_LIMIT_UINT8(EventCount);
|
||||
/* indicate that an error has occurred during
|
||||
/* indicate that an error has occurred during
|
||||
the reception of a frame */
|
||||
MSTP_Flag.ReceivedInvalidFrame = true;
|
||||
/* wait for the start of the next frame. */
|
||||
@@ -558,7 +558,7 @@ static void MSTP_Receive_Frame_FSM(
|
||||
if ((DestinationAddress == This_Station) ||
|
||||
(DestinationAddress == MSTP_BROADCAST_ADDRESS)) {
|
||||
/* ForUs */
|
||||
/* indicate that a frame with no data
|
||||
/* indicate that a frame with no data
|
||||
has been received */
|
||||
MSTP_Flag.ReceivedValidFrame = true;
|
||||
}
|
||||
@@ -680,7 +680,7 @@ static bool MSTP_Master_Node_FSM(
|
||||
default:
|
||||
break;
|
||||
}
|
||||
/* For DATA_EXPECTING_REPLY, we will keep the Rx Frame for
|
||||
/* For DATA_EXPECTING_REPLY, we will keep the Rx Frame for
|
||||
reference, and the flag will be cleared in the next state */
|
||||
if (Master_State != MSTP_MASTER_STATE_ANSWER_DATA_REQUEST) {
|
||||
MSTP_Flag.ReceivedValidFrame = false;
|
||||
@@ -1068,7 +1068,7 @@ uint16_t dlmstp_receive(
|
||||
MSTP_Receive_Frame_FSM();
|
||||
if (MSTP_Flag.ReceivedValidFrame || MSTP_Flag.ReceivedInvalidFrame)
|
||||
break;
|
||||
/* if we are not idle, then we are
|
||||
/* if we are not idle, then we are
|
||||
receiving a frame or timing out */
|
||||
if (Receive_State == MSTP_RECEIVE_STATE_IDLE)
|
||||
break;
|
||||
@@ -1100,7 +1100,7 @@ void dlmstp_set_mac_address(
|
||||
This_Station = mac_address;
|
||||
/* FIXME: implement your data storage */
|
||||
/* I2C_Write_Byte(
|
||||
EEPROM_DEVICE_ADDRESS,
|
||||
EEPROM_DEVICE_ADDRESS,
|
||||
mac_address,
|
||||
EEPROM_MSTP_MAC_ADDR); */
|
||||
if (mac_address > Nmax_master)
|
||||
@@ -1129,8 +1129,8 @@ void dlmstp_set_max_info_frames(
|
||||
if (max_info_frames >= 1) {
|
||||
Nmax_info_frames = max_info_frames;
|
||||
/* FIXME: implement your data storage */
|
||||
/* I2C_Write_Byte(
|
||||
EEPROM_DEVICE_ADDRESS,
|
||||
/* I2C_Write_Byte(
|
||||
EEPROM_DEVICE_ADDRESS,
|
||||
(uint8_t)max_info_frames,
|
||||
EEPROM_MSTP_MAX_INFO_FRAMES_ADDR); */
|
||||
}
|
||||
@@ -1157,7 +1157,7 @@ void dlmstp_set_max_master(
|
||||
Nmax_master = max_master;
|
||||
/* FIXME: implement your data storage */
|
||||
/* I2C_Write_Byte(
|
||||
EEPROM_DEVICE_ADDRESS,
|
||||
EEPROM_DEVICE_ADDRESS,
|
||||
max_master,
|
||||
EEPROM_MSTP_MAX_MASTER_ADDR); */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user