The text of a manual · part 8 of 31
DF1 Protocol and Command Set Reference Manual: 4 - Using Full-duplex Protocol to Send and Receive Messages, pages 55 to 63
Pages 55 to 63 of 251, from DF1 Protocol and Command Set Reference Manual
The original document is the PDF (2.1 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
Filed in the catalog under the Allen-Bradley 5250-LP and Allen-Bradley 5250-MLP1
Page 55
Chapter
4
Using Full-duplex Protocol to Send and Receive Messages In full-duplex protocol, devices share the same data circuits, and both devices can “talk” at the same time. Full-duplex protocol can be likened to a two-lane bridge: traffic can travel in both directions at one time. (To compare full-duplex to half-duplex protocol, refer to Chapter 3, “Using Half-duplex Protocols to Send and Receive Messages.”) Read this chapter to help learn how to use full-duplex protocol to send and receive messages. It contains these sections: Section
"
Page
Full-duplex Protocol Message Transmission
4-2
Full-duplex Protocol Environment
4-3
Message Characteristics
4-4
Transmitter and Receiver Message Transfer
4-4
Full-duplex Protocol Diagrams
4-10
Link arbitration You can use these Allen-Bradley interface modules to automatically handle the link arbitration: •1747-KE
•1771-KE
•1775-KA (via modem port)
•1770-KF2
•1771-KF
•1785-KE
•1770-KF3
•1771-KG
•5130-RM1 (channel one)
•1770-KFC
•5130-KA
•5130-RM2
Publication 1770-6.5.16 - October 1996
Page 56
4–2
Using Full-duplex Protocol to Send and Receive Messages
Full-duplex Protocol Message Transmission
With full-duplex protocol, a link uses two physical circuits for two-way simultaneous message transmission (command or reply message packets). These two physical circuits provide communication on four logical paths: Figure 4.1 Data paths for two-way simultaneous operation path 1 receiver B transmitter A path 2 circuit 1 circuit 2 path 3 receiver A transmitter B path 4
•On the first circuit, transmitter A sends messages to receiver B (path 1) and receiver A sends response control symbols (DLE ACK, DLE NAK) to transmitter B (path 3). •On the second circuit, transmitter B sends messages to receiver A (path 4) and receiver B sends response control symbols (DLE ACK, DLE NAK) to transmitter A (path 2). •All message and symbols on the first circuit are traveling in the same direction (node A to node B) and all messages and symbols on the second circuit are traveling in the opposite direction (B to A).
Publication 1770-6.5.16 - October 1996
Page 57
Using Full-duplex Protocol to Send and Receive Messages
4–3
Figure 4.2 Software implementation of data paths Paths 1, 2, 3, and 4 Transmitter A
Receiver B
Path 1 Software Multiplexer
Path 2
Path 1
Path 2 Physical Circuit AB
Software Separator
Software Separator
Physical Circuit BA
Software Multiplexer
Path 4
Path 3
Path 4
Path 3 Transmitter B
Receiver A
Paths 1 (a message symbol sent from node A to node B) Transmitter A
Receiver B
Path 1 Software Multiplexer
Physical Circuit
Path 1 Software Separator
•To implement four logical paths with two physical circuits, a software multiplexer is needed to combine the message symbols with the response symbols going in the same direction. •At the other end of the link, a software separator divides the message symbols from the response symbols. The internal software sends the message symbols to the appropriate receiver, and the response symbols to the appropriate transmitter. •Although message symbols and response symbols on the same circuit operate independently of each other, there is some interaction. •For example, a message on physical circuit AB will be delayed if a response symbol from receiver A is inserted in a stream of message symbols from transmitter A (embedded response). •Also, any hardware problems that affect message symbols traveling over a circuit will also affect response symbols on the same circuit.
Full-duplex Protocol Environment
To define the environment of the protocol: • the transmitter needs to know where to get the message it sends, the message source. We assume the message source: – supplies one message at a time upon request from the transmitter – requires notification of the success or failure of the transfer before supplying the next message
• the receiver must have a means of disposing of messages, the message sink If the
Then the message source is empty transmitter waits in an inactive state until a message is available receiver has received a message successfully receiver attempts to give it to the message sink. If the message sink is full, the receiver must be notified
Publication 1770-6.5.16 - October 1996
Page 58
4–4
Using Full-duplex Protocol to Send and Receive Messages
Figure 4.3 shows the protocol environment for message symbols from transmitter A to receiver B (path 1) and response codes from receiver B to transmitter A (path 2). Figure 4.3 Protocol Environment Packet Source
Path 1 Transmitter A
Packet Receiver B
Sink
Path 2 Packet Status
Message Characteristics
Sink Full
Ideally, the data-link-layer protocol is not concerned with the content or form of the message packet (link-layer data) it is transferring. However, full-duplex protocol places the following restrictions on link-layer data submitted to it for transfer: • minimum size of valid link-layer data is 6 bytes • maximum size of valid link-layer data depends on the application-layer command • some protocol implementations (e.g., point-to-point links to a 1771-KG module) require that the first byte of the link-layer data match the node address The receiver ignores messages that do not contain the correct address. • as part of the duplicate message detection algorithm, the receiver compares the second, third, fifth, and sixth bytes of the link-layer data with the same bytes in the previous message If there is no difference between the sets of bytes, the message is classified as a re-transmission of the previous message. You can set some Allen-Bradley interface modules so that they do not implement duplicate-message detection.
Transmitter and Receiver Message Transfer
Publication 1770-6.5.16 - October 1996
In full-duplex protocol, messages are sent from the source (part of software that supplies message packet) through a transmitter (device that sends data) and then a receiver (device that receives data) to the sink (part of the software that accepts the received data): For
See page structured text on how the transmitter operates
4-5 a flowchart of how the transmitter operates
4-6 structured text on how the receiver operates
4-7 a flowchart of how the receiver operates
4-9
Page 59
Using Full-duplex Protocol to Send and Receive Messages
4–5
How the Transmitter Operates The following program describes the actions of the transmitter: Whenever the message source can supply a message packet and the transmitter is not busy, it sends a frame on the link to the destination address. It then starts a timeout, and waits for a response. When this response is received from the receiving address
The message packet
DLE ACK has been successfully transferred. After signaling the message source that the message packet was successfully transmitted, the transmitter proceeds with the next message packet.
DLE NAK is retransmitted. The transmitter restarts the timeout and waits again for a response. If it receives a DLE ACK, the transmitter starts a timeout. This can be repeated several times. You can set a limit to the number of times a message can be re-transmitted for each module. If this limit is exceeded, the message source is informed of the failure and the transmitter proceeds with the next message.
If the timeout expires before a response is received, the transmitter sends a DLE ENQ to request a retransmission of the last response. It restarts the timeout and waits for a response. You can also set a limit to the number of timeouts that are allowed per message. If the enquiry (ENQ) limit is exceeded, the transmitter signals the message source that the transmission has failed, and the transmitter proceeds to the next message. There are three responses defined: DLE ACK, DLE NAK, DLE ENQ, If the transmitter receives an different response, the transmitter ignores it.
TRANSMITTER is defined as loop Message=GET-MESSAGE-TO-SEND Status=TRANSFER(Message) SIGNAL-RESULTS(Status) end loop loop WAIT for response on path 2 or timeout. if received DLE ACK then return SUCCESS else if received DLE NAK then if nak-limit is exceeded then return FAILURE else begin count NAK re-tries; SEND-MESSAGE(message); start timeout end else if timeout if enq-limit is exceeded then return FAILURE else begin count ENQ re-tries; send DLE ENQ on path 1; start timeout end end loop SEND (message) is defined as begin BCC = 0 send DLE STX on path 1 for every byte in the message do begin add the byte to the BCC; send the corresponding data symbol on path 1 end send DLE ETX BCC on path 1 end GET-MESSAGE-TO-SEND This is an operating-system-dependent interface routine that waits and allows the rest of the system to run until the message source has supplied a message to be sent. SIGNAL-RESULTS This is an implementation-dependent routine that tells the message source of the results of the attempted message transfer. WAIT This is an operating-system-dependent routine that waits for any of several events to occur while allowing other parts of the system to run. TRANSFER (Message) is defined as initialize nak-limit and enq-limit SEND(Message) start timeout
Publication 1770-6.5.16 - October 1996
Page 60
4–6
Using Full-duplex Protocol to Send and Receive Messages
The following flowcharts the software logic for implementing the transmitter: T retransmit same message message frame
DLE
STX
Data
DLE
ETX
BCC/CRC Field timeout loop Received DLE ACK? Yes Legend: T
= Ready to transmit next message
P
= Recovery procedure
*
= Default values used by the module
No
Received DLE NAK?
No
Timed out?
Yes
Yes
T 3* NAKs received for this message?
Yes
P
Yes
3* ENQ sent?
No
No DLE
Important:
Publication 1770-6.5.16 - October 1996
No
ENQ
Depending on network-link traffic and saturation level, you may need to wait for a reply from the remote node before transmitting the next message. Implement an option that allows users to choose the maximum amount of outstanding messages that can exist at one time; we suggest a selectable range of one to three messages.
Page 61
Using Full-duplex Protocol to Send and Receive Messages
4–7
How the Receiver Operates The receiver must be capable of responding to adverse situations. Some of the problems that can occur are: • the message sink is full, so the receiver has nowhere to put a message • a message can contain a parity error • the BCC or CRC can be invalid • the DLE STX or DLE ETX BCC/CRC may be missing • the message is too long or too short • a false control or data symbol occurs outside a message • a false control symbol occurs inside a message • the DLE ACK response is lost, causing the transmitter to send a duplicate copy of a message already passed to the message sink
Publication 1770-6.5.16 - October 1996
Page 62
4–8
Using Full-duplex Protocol to Send and Receive Messages
The following program describes the actions of the receiver in detail.
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 from the transmitter
Then the
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
Publication 1770-6.5.16 - October 1996
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
Page 63
Using Full-duplex Protocol to Send and Receive Messages
4–9
The following flowchart is the software logic for implementing the receiver. RCVE
LAST = NAK
Received DLE ENQ?
Yes
No
No
Received message? Yes
BCC/ CRC OK?
No
LAST = NAK
Yes LAST = ACK
Send DLE LAST
Publication 1770-6.5.16 - October 1996