Rockwell Automation 1770, D17706.5.16 Ref Mnl DF1 Protocol Command User Manual

Page 62

Advertising
background image

4–8

Using Full-duplex Protocol to Send and Receive Messages

Publication 1770Ć6.5.16 - October 1996

The following program describes the actions of the receiver in detail.

RECEIVER is defined as

variables

LAST-HEADER is 4 bytes copied out of the last good message
RESPONSE is the value of the last ACK or NAK sent
BCC is an 8-bit block check accumulator

LAST-HEADER = invalid
LAST RESPONSE = NAK
loop

reset parity error flag
GET-SYMBOL
if DLE STX then

begin

BCC = 0
GET-SYMBOL
while it is a data symbol

begin

if buffer is not overflowed put
data in buffer
GET-SYMBOL

end

if the control symbol is not a DLE ETX then send DLE
NAK
else if error flag is set then send DLE NAK
else if BCC is not zero then send DLE NAK
else if message is too small then send DLE NAK
else if message is too large then send DLE NAK
else if header is same as last message send a DLE ACK
else if message sink is full send DLE NAK
else

begin

send message to message sink
send a DLE ACK
save a last header

end

end

else if DLE ENQ then send LAST-RESPONSE
else LAST-RESPONSE = NAK

end loop

GET-SYMBOL is defined as

loop

GET-CHAR
if char is not DLE

begin

add char to BCC
return the char and data flag

end

else

begin

GET-CHAR
if char is a DLE

begin

add char to BCC
return DLE and data flag

end

else if char is an ACK or NAK send it to the transmitter
else if char is an ETX

begin

GET-CHAR
add char to BCC
return ETX with a control flag

end
else return char with a control flag

end

end loop

The receiver keeps a record of the last response sent to

the transmitter. The value of this response is either DLE

ACK or DLE NAK. It is initialized to DLE NAK. When a

DLE ENQ (enquiry) is received from the transmitter, the

receiver sends the value of the last response.
The receiver ignores all input until a DLE STX or DLE ENQ

is received. If anything other than a DLE STX or DLE ENQ

is received on path one, the receiver sets the last response

variable to NAK.
When this symbol is received Then the

from the transmitter
DLE ENQ

last response is sent

and the receiver

continues waiting for

input.

DLE ACK

BCC/CRC and the

message buffer are

reset, and the receiver

starts building a reply

message.

While building a reply message, all data symbols are

stored in the message buffer and added to the BCC/CRC.

If the buffer overflows, the receiver continues summing the

BCC/CRC, but the data is discarded.
If a parity, overrun, framing, or modem handshaking error is

detected, it is recorded .
If a control symbol other than DLE STX or DLE ETX is

received, the message is aborted and a DLE NAK is sent

to the transmitter. When DLE STX or DLE ETX is received,

the error flag, the BCC/CRC, the message size, and the

address (optionally) are all checked. If any of the tests fail,

a DLE NAK is sent.
GETĆCHAR is defined as an implementationĆdependant

function that returns one byte of data from the link

interface hardware

Advertising