Asynchronous link protocols chapter 4 – Rockwell Automation 1770-KF2 Data Highway or Highway Plus Interface Module User Manual User Manual
Page 58

Asynchronous Link Protocols
Chapter 4
4-15
Table 4.B
Receiver for Full-Duplex Protocol
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-CODE
if DLE STX then
begin
BCC = 0
GET-CODE
while it is a data code
begin
if buffer is not overflowed put data in buffer
GET-CODE
end
if the control code 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 last header
end
end
else if DLE ENQ then send LAST-RESPONSE
else LAST-RESPONSE = NAK
end loop
GET-CODE is defined as
loop
GET-CHAR
if char is not a 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 a DLE and a 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 character with a control flag
end
end loop
GET-CHAR is defined as
an implementation-dependent function that returns one byte of data from the link interface hardware.