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

Page 42

Advertising
background image

3–5

Using Half-duplex Protocols to Send and Receive Messages

Publication 1770Ć6.5.16 - October 1996

GETMESSAGE is defined as

GET-CODE
while it is data code

begin

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

end

if it is a control code and it is an ETX then

begin

if parity error flag is set then return a NAK
if BCC is not zero then return a NAK
if message is too small then return a NAK
if message is too large then return a NAK
return an ACK

end

else end

GET-CODE is defined as

loop

variable
GET-CHAR
if char is not a DLE

begin

add char to BCC
return the char and a 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 ETX

begin

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

end

else return char with a control flag

end

end

end

GETĆCHAR is defined as

an implementationĆdependent function that returns one byte of data

from the link interface hardware

SEND (Message) is defined as

begin

BCC = 0

send DLE STX

for every byte in the message do

begin

subtract the byte from the BCC

send the corresponding data code

end

send DLE ETX BCC

end

Advertising