The text of a manual · part 8 of 10
Model 30 Hardware Operations Manual, pages 71 to 80
Pages 71 to 80 of 96
The original document is the PDF (557 KB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
For the Accu-Sort Model 30
Page 71
6-3
Appendices
The following is the framing for all messages sent by any device on the multidrop line: 0FFH
STX
ID(2)
TYPE(2)
SEQ
DATA
LRC(2)
CR
(FFhex) = Guard Character This character is "sacrificed" to the line noise that occurs when the unit transmitter is first turned on. The unit software may (optionally) wait one character time between transmitter enable and transmission of the STX (the next character). This eliminates transmitting the guard character. The receiver ignores this character. STX(02hex) = Start of text character This character indicates the start of a message. The receiver should clear any characters in its receive buffer whenever it receives this character. ID(2 ASCII digits) = The unit ID This field indicates the unit identification number of the unit to which the message is directed, if the message is coming from the master. This field indicates the unit identification number of the unit transmitting the message, if the message is from a slave. A message with an ID of "00" from the master is a broadcast message. All slave units should act on the message (display data, reset, etc.), but no slave should respond to the message. TYPE(2 ASCII digits) = The message type This field describes the purpose of the message that is sent. There are five message types as shown below: Message Types 01
Poll
This message type is sent by the master unit to request data from a slave.
02
Data
This message type is sent by either a master to transfer data to a slave or by a slave to transfer data to the master after receiving a poll. The TYPE field will then be followed by a SEQ field and a data field.
03
ACK
This message type is sent by the unit that has just received a valid data message.
Model 30 Hardware Operations Manual
Page 72
6-4
Chapter 6
04
Wake up
This message type is sent by the master. The slave that receives it should acknowledge the message.
05
No data
This message type may be sent by a slave indicating that the slave has no data to send in response to a poll. This message is optional. If the slave has no data, it may ignore the poll.
SEQ(1 ASCII digit) = The sequence number This field starts at zero at power up, and is incremented by one for each data message sent. When the sequence number reaches nine, it wraps around to one. This field is only present in a data message. DATA = The content of the data field This field contains data, if the message type indicates that data is included. This field may contain no characters (length of zero; poll, acknowledge and wake up messages do not have data fields.) LRC(2 HEX digits) = The Linear Redundancy Check Sequence The LRC is computed by exclusive-oring all the characters in the ID, TYPE, SEQ, and data fields, then converting the hex number into two ascii digits. This mathematical process checks to make sure that the message is valid. CR (0Dh) = Carriage return This character indicates the end of the message. When this character is received, the unit should check to see that the message started with a STX, and check that the LRC is correct before accepting it as a valid message.
Message Sequencing The master unit initiates all data transfers by either sending data to a slave or requesting data from a slave. This protocol is strictly half duplex; only one device may be transmitting at any time. A slave device should not transmit unless it receives a valid message that requires a response--when it does receive such a message, it must respond quickly (See Timing). The master unit should respond in a timely manner, but is not under the same constraints as a slave. The following is the example of processing a Master/Slave interaction: 1. 2. 3. 4. 5.
Accu-Sort Systems
Master Wake up Poll Poll Poll Data
Slave’s response ACK Data No data -noneACK
Master’s response -noneACK -none-none-none-
Page 73
6-5
Appendices
Timing If a slave unit is going to respond to a poll from the master, it must start its response within two character times of the end of the carriage return at the end of the poll. NOTE: This makes the response time dependent upon the baud rate. The slave must turn on its transmitter within two character times after receiving the CR of the master's poll. The slave must place the STX at the beginning of its response, into its serial port no later than three character times after receipt of the master’s carriage return. Once the slave begins transmitting, it must not allow a gap of more than one half a character time between characters. Most transmissions will take place under interrupt, so this should not be a problem; however, it means that serial port interrupts may not be disabled for an extended period of time during data transmission.
Master: RTS TXD
Time:
S0123456Ps (CR) B A
C
Slave: RTS TXD
S0123456PsS0123456Ps_________S01 (FFh) (STX)
“S” is the start bit, “0123456” are the character bits, “P” is the parity bit and “s” is the stop bit. Typically, the “RTS” line is used to control the transmitter. In this diagram, “RTS” is high when the transmitter is enabled and low when the transmitter is disabled (“tri-stated”). NOTE: The slave’s “FF” may be replaced with a 1 character time (10/ baud rate) delay between transmitter turn-on and transmission of the STX.
Model 30 Hardware Operations Manual
Page 74
6-6
Chapter 6
Time Limits: A
Maximum: 2 character times (20/baud rate). Minimum: 0.
B
Maximum: 4 character times (40/baud rate). Minimum: 2 character times (due to guard character + STX transmission time).
C
Maximum: 1/2 character time (5/baud rate). Minimum: 0.
Both the master and the slave must disable their transmitter as soon as possible after transmitting the carriage return at the end of the message. The transmitter must remain enabled while the carriage return is being sent out, however. This means that the transmitting device must wait for a “transmitter empty” (as opposed to a “transmitter ready”) indication from the serial port before disabling the transmitter. This protocol has been designed for a "slow" master to communicate with a "fast" slave. The only time-critical item for the master is for the master to release control of the line immediately after sending a message to a slave. While the slave must respond within a very short time window, there are no such constraints on the master. The master may have any amount of time between messages or between characters within its message.
Error Recovery Error: The slave does not understand a poll message. Recovery: None. The master will time out, waiting for the slave’s response, then will go on to the next unit. Error: The slave does not understand a data message from the master. Recovery: The master will retransmit the data message again after timing out while waiting for the acknowledgement. Error: The master does not understand the slave’s acknowledgement of a data message. Recovery: The master will retransmit the data message after timing out while waiting for the acknowledgement. The slave will acknowledge the retransmitted message and discard it, since the message will have the same sequence number as the last message received.
Accu-Sort Systems
Page 75
6-7
Appendices
Error: The master does not understand the slave’s data message (response to a poll). Recovery: The master will time out waiting for the slave’s response, then continue on to the next poll. Since the slave did not receive an acknowledgement for the data message, it will retransmit the same message in response to the next poll. Error: The slave does not understand the master’s acknowledgement of the slave’s data message. Recovery: The slave will retransmit the same message in response to the next poll. The master will see that it is a duplicate message, acknowledge it, and discard it. Error: The slave does not understand a broadcast message. Recovery: None. The message will be lost.
The general rules are as follows: 1. Each data message will be acknowledged by the recipient. If a data message is not acknowledged, the transmitter should retransmit it again up to three retries. After the third retry, a communications error message should be displayed and the message discarded (in some systems the message may be recorded in a disk file or on a printer to prevent data loss). 2. Each new message will have a new sequence number. If a message is received that has the same message number as the last message received, the recipient should acknowledge the message and then discard it. The sequence number should only be checked for equality to the last sequence number received: there is no requirement that the sequence number must be the next number expected (although in some systems the master will keep track of “out of sequence” errors since they would indicate that messages had been lost). The sequence number zero is a special case, since it indicates that the data message is the first data message sent since the device sending it has powered up. Messages with a sequence number of zero should always be processed as required, regardless of whether or not they are repeated “back to back”. 3. Any message that contains parity errors, LRC errors or an unrecognized message type should be discarded. No acknowledgement should be sent. In some systems, the master will keep track of these transmission errors.
Model 30 Hardware Operations Manual
Page 76
6-8
Chapter 6
4. Any message that contains a correct LRC, has no errors, is of a correct type, and requires an acknowledgement should be acknowledged even if its sequence number indicates that it is a duplicate message (the sequence number is the same as the last message). If it is a duplicate message, it should be acknowledged, then discarded. In some systems, the master will keep track of these duplicate message errors since they would indicate that an acknowledgement had been lost. A broadcast message (one sent to unit “00”) must not be acknowledged.
Multidrop Protocol Examples Message framing: FFh, (DEL,
02h, STX, idhigh, idlow, ?, ?, type, ?, seq no, ?,
... data..., ?, lrc0, ?, lrc1, ?,
0Dh CR)
NOTE: The DEL character is used as a guard character to make sure that the transmission line is quiet for one character time before the STX is sent. The sequence number only appears on data messages. The LRC stands for “linear redundancy check” and appears on all messages. Polling sequence: 1. MUX polls slave at address 01 with the following format: STX, unit id (2 char), 0, 1, lrc (2 char), CR Example: STX 0 1 0 1 HEX:
02h
30h 31h
30h 31h
0 0 30h 30h
CR 0Dh
2. SLAVE answers the poll with the data in the following format: STX, unit id, 0, 2, seq (1 char), ...data..., lrc, CR Example: STX 0 1 0 2 1 A HEX:
02h
30h 31h
30h 32h
B C D E 7 3 CR 31h 41h 42h 43h 44h 45h 37h 33h 0Dh
If no data is available: STX, unit id, 0, 5, lrc, CR Example: STX 0 HEX:
02h
1 30h 31h
0 5 30h 35h
0 4 30h 34h
CR 0Dh
NOTE: It is normally faster to allow the master to time out (which takes three character times) than to use the "no data" response.
Accu-Sort Systems
Page 77
6-9
Appendices
3. MUX acknowledges data in the following format: STX, unit id, 0, 3, lrc, CR Example:STX 0 1
0
3
0
2
CR
HEX:
30h
31h
30h
32h
0Dh
02h
30h
31h
4. MUX polls the next unit . . .
Accu-Sort Master/Slave Protocol This protocol may not be available for every Accu-Sort device.
Accu-Sort’s master/slave protocol is a method of allowing two AccuSort scanners to scan during the same trigger cycle and send their data through one unit to a host. One unit is configured as a master unit. This unit communicates to the host through its primary serial port. It also receives data from the other unit through its secondary serial port. The other unit is configured as a slave unit. It will send any data received for the current trigger cycle to the master unit. A message is transmitted for each bar code read. DATA FORMAT The secondary port of the master and the primary port of the slave are configured the same. They should both be set for RS-232 pointto-point. They communicate at 19200 baud, 7 data bits, even parity, and 2 stop bits. The slave transmits a message for each code enabled using a fixed format. The master is configured to receive this format. (See MESSAGE FORMAT) TIMING Non-Tracking: In non-tracking mode, the slave unit's watch dog timer defaults to 400 ms. The slave unit has 400 ms from the end of the trigger cycle to begin transmission of its bar code data. It can begin transmission of its data anytime from the end of the trigger until the watch dog timer has expired. It is required to have completed all of its transmissions by the expiration of the master’s watch dog timer. The master’s watch dog timer will default to 500 ms. The master will be required to wait until the expiration of its watch dog timer before it begins transmitting its data. This will allow the master to receive and process all of the slave unit’s data before transmission.
Model 30 Hardware Operations Manual
Page 78
6-10
Chapter 6
Tracking: In tracking mode, the master and slave units are configured for the same transmit time. The slave unit is then required to calculate the longest time it needs to send all of its data. To compensate for this value, the slave adjusts its transmit time down. This allows the master to receive and process all of the slave unit’s data before transmission. MESSAGE FORMAT The transmission of bar code data from the slave unit to the master unit will use the following format: STX TRIG_ID(1) TYPE (2) CODE(n) QQ(2) CR STX = Start of text character (02h). TRIG_ID(1) = Single ascii character representing the ID number for the current trigger cycle. The first trigger cycle will start with an ID of zero (30h). Each consecutive trigger will increment the ID. The ID will increment up to nine (39h), wrap to one (31h), and begin incrementing again. All messages for a trigger cycle will have the same ID. TYPE (2) = Two ascii characters representing the code type of the data being transmitted. VALUE 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17
Accu-Sort Systems
TYPE No-read Straight 2 of 5 Interleaved 2 of 5 Code 39 (STI option) Code 39 Code 128 UPC-A (10 characters) UPC-E (6 characters) UPC-A (12 characters) UPC-E (12 characters) EAN-13 EAN-8 Codabar (start/stop not included) Codabar (start/stop included) AS-10 10 Bit Periodic Binary Code 93 PharmaCode
Page 79
6-11
Appendices
CODE(n) = String of ascii characters containing the bar code. This field is not required for a no-read message. QQ(2) = Two ascii characters representing the quality of code read (01-99). This field is not required for a no-read message. CR = Carriage return (0Dh). MESSAGE PROTOCOL Each device will use ACK/NAK protocol with the other unit. When a message is transmitted, the transmitting unit will expect to receive an ACK (06h) or a NAK (15h) in response. If an ACK is received, this communication sequence is complete. If a NAK is received, the message should be transmitted again. If nothing is received for 250 ms, the transmitting device will treat this as a NAK being received and re-transmit. A message will be re-transmitted a maximum of three times. If a fourth NAK or time out is seen, an error should be logged and the message should not be re-sent. All messages received should be ACK’d by the receiving unit. The NAK response is reserved for use in custom applications. When each unit powers up, it will send a synchronization character (SYN or 16h) to the other unit. This character will indicate that both units will set their next trigger ID to 0. The data messages will be sent down from the slave to the master for each trigger cycle. For each trigger cycle, the master will wait for messages from the slave before transmitting to the host. Each message received from the slave should have the same trigger ID that the master is using for that trigger cycle. If an incorrect ID is received, an error should be logged on the master unit and the data should be discarded. The master will place any valid messages into its compare buffer and process them as if they were read by that unit.
Model 30 Hardware Operations Manual
Page 80
6-12
Chapter 6
Protocols Used With RS232, Current Loop, and 422 RTS/CTS (Used with only RS232) This protocol stands for "Request To Send" and "Clear To Send". This is a common type of "handshaking" that goes on between two units. When one device wants to transmit to another device, it will drive the RTS line indicating it has data to transmit. When the receiving device is ready to receive, it will drive the CTS line indicating it is ready. When you use RTS/CTS it requires the addition of two more wires on the communication cable. If they are not needed, it is advised not to use any other additional lines in the cable. ACK/NAK This is a software protocol. When a unit receives a message, it indicates whether it has received that message correctly. If all information is received, the unit will transmit an "ACK" (acknowledge). The ACK is a signal that more information may be transmitted. If the information is not received correctly, then it will transmit a "NAK" (non-acknowledge). The NAK is a signal requesting a message be retransmitted. Most software has a limit to the number of retransmits. Three NAKS is common. XON/XOFF This is a software protocol. XON stands for "transmit on" and XOFF stands for "transmit off." A unit receiving data may signal the unit transmitting that it should stop sending data by transmitting and XOFF (ctrl-S). An XON (ctrl-Q) signals the original unit to begin transmitting again.
Accu-Sort Systems