The text of a manual · part 6 of 10
QTERM-IV/P40 User's Manual: Chapter 4.
Pages 35 to 42 of 64, from QTERM-IV/P40 User's Manual
The original document is the PDF (1.2 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.
For the QSI Corp QTerm-IV and Beijer QTerm-IV
Page 35
CHAPTER 4. QTERM SERIAL MODES 4.1
Serial Modes
Regardless of the serial interface hardware selected, the QTERM software can operate in three different serial interface modes: Full-Duplex, Block and Multidrop Modes. These serial modes can be selected from within either Power-On Setup mode or the QDATA file by setting the [serial mode] field. Not all serial modes are useful with all of the different types of serial interface hardware available with the QTERM. For example, Full-Duplex mode is not useful with an EIA-485 hardware interface. Block Mode is very similar to Multidrop Mode. If your QTERM is a Multidrop unit, we recommend that you read the Block Mode section before reading the Multidrop section.
4.2
Full-Duplex Serial Mode
When in Full-Duplex serial mode, the QTERM immediately executes key strokes as they are pushed. Host mode string data is sent to the host and local mode data, and commands and special functions are executed when the key is pressed. Commands are executed and displayable data is displayed as soon as they are received from the host. Only one terminal may be connected to the host. Full-Duplex may be used only with the following hardware interfaces: EIA-232, -422, and 5-volt Buffered. Xon/Xoff handshaking is supported and is only available in Full-Duplex mode. If desired, Xon/Xoff handshaking can be disabled from within the QDATA file.
4.3
Block Serial Mode
Block Serial Mode is useful for prompt/response systems with semi-intelligent hosts where the user must construct a complete, correct response at the QTERM, prior to transmission, without host intervention.
In Block Mode, all communication between the Host and the QTERM is done with data packets. A valid Block Mode data packet consists of a data portion followed by a userdefinable, End-Of-Packet (EOP) terminator character. The data portion may contain any number of displayable or command data bytes, but must not contain a byte equal to the EOP character. The EOP character is user-definable in the QDATA file; any 8-bit value is valid. Block Mode may be used only with the following hardware interfaces: EIA-232, -422, and 5-volt Buffered. Since Block Mode is not a full-duplex scheme, the QTERM cannot simultaneously process incoming data from the host and keystrokes. This does not mean that data will be lost, but it does mean that the host software must support the communications scheme described below. In order to understand the operation of Block Mode (and Multidrop Mode), you must understand the following terminology: DATA PACKET A formatted sequence of bytes which must be used to transmit data to and from the QTERM running in Block Mode. The format is very simple. All Data Packets consist of a free-form data portion followed by an EOP Terminator (described below). The data portion consists of a stream of bytes and may be as long as desired, but it may not contain a character equal to the EOP Terminator. The data portion must always be followed by the EOP Terminator. EOP TERMINATOR A special character, defined in the QDATA file, which performs two functions. It terminates all Data Packets sent from and received by the QTERM when in Block Mode. It is also used to terminate EDIT Mode and causes the EDIT Buffer to be sent to the host when a key, defined with the EOP Terminator character, is pushed. If you wish to use Block Mode, you must define at least one key with the EOP Terminator.
Beijer Electronics Fax 801-466-8792 Web www.beijerelectronicsinc.com Phone 801-466-8770
Page 36
26
QTERM-IV/P40 User's Manual
The QTERM automatically sends the EOP Terminator at the end of all Response Packets it returns to the host. RESPONSE PACKET A Data Packet automatically returned by the QTERM after it receives a complete transmission from the host. The Response Packet's data portion can consist of nothing (a NULL packet), data returned in response to a query command or an acknowledgment byte. The Response Packet is always terminated with an EOP Terminator. IDLE MODE The operating mode of the QTERM anytime it is neither processing strings nor receiving data from the host. EDIT MODE The operating mode in which string data is entered into an LCD buffer and edited prior to transmission to host. 4.3.1
Receiving Data from the Host
If the QTERM is in IDLE, and the host begins a transmission, the QTERM will only process data coming from the host until the EOP Terminator is received; keystrokes will be buffered but not processed. While receiving the incoming packet from the host, the incoming data is displayed and incoming commands are executed as they are received. Upon receiving the EOP Terminator from the host, the QTERM will send a response packet, process any buffered keystrokes, and revert to IDLE to await the next event. 4.3.2
Response Packets
The QTERM always returns a response packet after receiving a host packet (unless ACK/NAK responses are disabled; see below). The data portion of the response packet will always consist of one of the following: nothing (a Null Packet), query data (in answer to a query command sent by the host), or either an ACK (ASCII 06h) or NAK (ASCII 15h) character. Response packets are always automatically terminated by the EOP character. Null Packets are only returned in response to a Query Buffer command; this command is not useful in Block Mode since the EDIT Buffer never needs to be queried. Other types of query commands sent by the host will cause the QTERM to return data. If the QTERM receives a command from the host which requires that the QTERM return data to the host, i.e. a Query Cursor Position command etc., the requested data will be sent in lieu of any acknowledgment byte.
Acknowledgment bytes are only returned if nothing in the incoming host packet requires the QTERM to return query data. For example, if the host sends a packet containing only display data to the QTERM, the data portion of the QTERM response packet will contain only an ASCII ACK or NAK acknowledgement byte. If instead, the host sends display data and a Query Cursor Position command, the QTERM response packet will contain the current cursor position only without an acknowledgement byte. The only acknowledgement bytes are ACK (ASCII 06h) or NAK (ASCII 15h) character to indicate that the QTERM received the host's transmission without error or that the QTERM was busy and ignored the host transmission, respectively. Automatic transmission of response packets containing acknowledgement bytes may be disabled, if necessary, by the [MD/Block response mode] field in the QDATA file. 4.3.3 Transmitting Data to the Host and the Operation of EDIT Mode The host data portion of a string is not sent immediately to the host when the string is executed. Instead, host data is buffered on the display in a special area called the EDIT buffer. The EDIT buffer position is variable and is reset each time the QTERM receives a packet from the host. At the termination of an incoming packet, the start of the EDIT buffer is relocated to the last cursor position. The EDIT buffer always extends to the end of the same line on which it started. If a key is pressed while the QTERM is in IDLE, or if there are buffered keystrokes waiting to be handled after the QTERM received a packet, or some other string has been triggered (i.e. Timeout string, Autoexec string etc.) the QTERM enters EDIT mode. While in EDIT mode, the host data portion of executed strings will be entered into the EDIT buffer up to the end of the buffer. Keys may be defined using certain commands as edit keys (described below) with which to modify the data in the EDIT buffer prior to transmission. While in EDIT mode, incoming packets from the host will not be processed (with a few exceptions noted below) but will generate a response packet containing a NAK acknowledgement indicating to the host that the packet was not processed. Keystrings will continue to be appended to the EDIT buffer until the EOP Terminator is encountered in the current string definition or until the user hits a key defined with the EOP character. When the EOP character is encountered, the entire EDIT buffer is sent to the host, the cursor is returned to the start of the EDIT buffer, EDIT mode is terminated and the QTERM returns to IDLE. Because of this, you must
Beijer Electronics Fax 801-466-8792 Web www.beijerelectronicsinc.com Phone 801-466-8770
Page 37
QTERM-IV/P40 User's Manual have at least one key defined with the EOP character. The EDIT buffer is not cleared automatically after transmission. 4.3.4
EDIT Mode and the Use of Local and Host Data
Because host data in the string definitions is sent to the EDIT buffer on the LCD, Local-mode, display data loses some of it's utility when you run in Block Mode. For example, a key defined as follows: <k00> 'To Host',\L, 'Local data' would put both “To Host” and “Local Data” in the EDIT buffer. Since both strings wind up in the EDIT buffer, what use is Local Mode? Don't be fooled; there are big differences in the way Host and Local data are handled. Host data is not interpreted in any way by the QTERM, other that to detect an EOP Terminator indicating the EDIT buffer should be transmitted. The QTERM simply puts all Host Data, as is, into the EDIT buffer. On the other hand, Local Data is sent through the QTERM's command processor. The command processor looks for any QTERM commands and executes them. If it cannot find any commands, it assumes the Local Data is just display information and sends it to the LCD. Both the strings in the key definition above get into the EDIT buffer, but they get there in entirely different ways. Because of this behavior, you probably will not use Local Mode display data, by itself, very often while running in Block Mode. You will find uses for Local Mode commands though. For example, by executing a Local Mode cursor positioning command, you could put Local mode display data on the LCD but somewhere other than the EDIT buffer. You cannot do this with Host Data; it is always directed to the EDIT buffer.
27 IDLE mode. These functions are not usually limited to operating on the EDIT buffer; this behavior only occurs when they are executed within a Local Mode string while the QTERM is in Block Mode. As an example, you might want to define 3 EDIT buffer editing keys: clear buffer, cursor left and cursor right. These keys would be defined as follows: <k00> \L,x1B,'H',x1B,'K'; Clear Buffer <k01> \L,x1B,'C'; Cursor Right <k02> \L,x1B,'D'; Cursor Left There are a few things to notice in these definitions. First, note that the Clear Buffer key does not use the Flush TX buffer command but rather, homes the cursor (] H) then clears to the end-of-line (] K). This is because the Flush TX Buffer command not only clears the EDIT buffer, it also returns us to IDLE mode. To clear the EDIT buffer and remain in EDIT mode, home the cursor to the start of the buffer with the ] H command, then clear the line. Also note that the Cursor Right key uses the standard Cursor Right command which is not one of the commands mentioned above which takes on special behavior regarding the EDIT buffer. This is because the Cursor Right command naturally stops at the end of the current line which is also always the end of the EDIT buffer. Lastly, the Cursor Left key uses the standard Cursor Left command. This command will normally move the cursor left up to the beginning of the current line. In this application though, since we are in Block Mode and it is being executed from within a Local Mode string, the Cursor Left command takes on special behavior and stops at the start of the EDIT buffer rather than the start of the current line. 4.3.6
4.3.5
The EOP Terminator and EDIT Mode
Defining Editing Keys for the EDIT Buffer
Certain commands, when executed from within a Local Mode string while running in Block Mode, can be used to create EDIT Buffer editing keys so the user can modify characters entered into the EDIT buffer prior to sending the buffer to the host. These commands, if executed from within a Local Mode string, behave differently than if they were received from the host and operate only on the EDIT buffer. These commands are: BackSpace (ASCII BS, 08), DELete (ASCII DEL, 127), Cursor Left (] D), Home Cursor (] H), and Flush TX buffer (] k). Backspace, Delete and Cursor Left will only move the cursor left to the start of the EDIT buffer. Home Cursor homes the cursor to the start of the EDIT buffer and Flush TX Buffer clears the EDIT buffer and returns the QTERM to
In order to transmit the EDIT buffer to the host, the QTERM must execute a string defined with the EOP Terminator character. When the EOP Terminator is executed, the EDIT buffer is transmitted, the cursor returns to the start of the EDIT buffer, EDIT mode is canceled and the terminal returns to IDLE. Note that the EDIT buffer is not cleared. If you wish to clear the EDIT buffer after it is transmitted, you can define your “Enter” key as follows: <k53>x0D,\L,x1B,'K';Transmit buffer ;and clear it x0D is the default EOP Terminator (you may define EOP to be any byte value), then we switch to Local Mode and clear
Beijer Electronics Fax 801-466-8792 Web www.beijerelectronicsinc.com Phone 801-466-8770
Page 38
28
QTERM-IV/P40 User's Manual to the end of line with x1B,'K' (ASCII ] K). This works because anytime the QTERM executes the EOP and transmits the EDIT buffer, it will return the cursor to the start of the buffer automatically. The EOP Terminator can be entered separately from the other data entered into the EDIT buffer, or it can be appended to a string definition. If EOP is appended to a string definition, the string will be entered into the EDIT buffer and be transmitted in a single step. For example, [timeout string] 'timeout!',x0D,\L,x1B,'K'
Next, we toggle back to host mode with another \L switch and send to the EDIT buffer the “-sp” prefix, which the host will recognize as a command to accept a speed parameter. Then the default EOP Terminator, x0D, is encountered so “-sp” is sent to the host. Remember, the prefix is sent to the host in a packet which is terminated by the EOP Terminator. (This “prefix” is only useful to the mythical host used in this example; it has no significance to the QTERM.) Lastly, we toggle back to Local Mode with another \L switch, home the cursor back to the start of the EDIT buffer (] H) and clear it out (] K) so the user can enter the speed parameter. This happens so fast, the user will never realize that the prefix has been sent to the host.
would put “timeout!” in the EDIT buffer, transmit it (x0D = EOP), and then clear the EDIT buffer. All this would happen so fast, you would not see anything on the LCD.
Without the \S switch, you could not separate the prompt from the prefix and both would be sent back to the host.
4.3.7
4.3.9
Received Commands Allowed in EDIT Mode
The contents of most incoming packets are ignored by the QTERM if it is currently in EDIT mode; in these cases the QTERM will return a NAK acknowledge packet to the host in response. Certain commands, though, are received and processed by the QTERM, even when it's in EDIT mode. These commands are: Reset, Sleep, Query Status, Set Keypad mode, TX buffer flush and Query buffer. These commands allow the host to take control of the QTERM regardless of its current operating mode. 4.3.8
The Special Function Switch \S and EDIT Mode
In some situations, you may want to reset the start of the EDIT buffer from within a string definition. The EDIT Buffer Start switch, \S, sets the start of the Multidrop/Block EDIT buffer at the current cursor location and may appear anywhere inside a string definition. For example, you might want to set up a function key which displays a prompt and sends a prefix peculiar to the host to notify it of a parameter to be entered later by the user: <k31>
\L,x1B,'E','Enter Speed:',\S,\L, - sp',x0D,\L,x1B,'H',x1B, 'K'
This one is complicated, but let's see how it works. When the key string executes, we first switch to Local mode to clear the screen and position the cursor to the top left. Then we display the prompt, “Enter Speed:” on the LCD and reset the EDIT buffer to the location just after the prompt with the \S switch.
Auxiliary Serial Port Operation
Section 2.2.46 gives an explanation of the Auxiliary Port Control Command, and the general operation of the auxiliary port. There are a few things to note about operating the auxiliary port while in Block Mode. Data packets, as described above, are never used for communications between the aux port and devices connected to it; this is true for Block Mode or for any other serial mode. The host can disable the port, initiate transmissions from the aux port, or it can enable reception from the aux port but it can only do one of these at a time; i.e. you cannot simultaneously transmit and receive on the aux port. The port disable command and port-transmission enable command operate as described in the User's Manual, but reception from the port is a bit different than that described in the User's Manual when the QTERM is in Block Mode. To understand how received aux port data is handled in Block Mode, think of the aux port as a secondary keypad device. All data received at the aux port is handled by the QTERM just as though the data was entered on the keypad as would Host Mode key strings. This means that incoming data is not sent immediately to the host as it would be in Full-Duplex Serial mode. Instead, the QTERM enters EDIT mode and stores all incoming data in the EDIT buffer. Incoming aux port data is entered into the buffer until the EOP Terminator is received from the aux port or entered on the keypad, then the EDIT buffer is sent to the host. Keystrokes and other executed strings may be freely mixed with aux port input in the EDIT buffer. Aux port data may be edited just like all other data stored in the EDIT buffer. The Aux Port Control Command can also be executed in Local Mode from within a string definition.
Beijer Electronics Fax 801-466-8792 Web www.beijerelectronicsinc.com Phone 801-466-8770
Page 39
QTERM-IV/P40 User's Manual 4.4
Multidrop Serial Mode
Multidrop Mode is a half-duplex communications mode which allows you to connect up to 32 QTERMs to one host port. Only one host is allowed in any network, and only the host can initiate network communications. Each terminal has a unique address which is used to direct data packets from the host to a single QTERM on the network. Please read the Block Mode sections above before continuing; Multidrop operation is very similar to Block Mode operation and the following discussion will explain Multidrop operation in terms of its differences from Block Mode operation. Multidrop Mode may be used only with the following hardware interfaces: EIA-422 and EIA-485. This makes EIA422 is the most flexible interface, in terms of serial modes since you can use any Serial Mode with the EIA-422 hardware interface. All communications between the host and the QTERMs is done with Data Packets. Multidrop Data Packets are similar to those used in Block Mode with the addition of two address bytes at the start of the packet. The format of Multidrop data packets is described completely below. In order to understand the operation of Multidrop Mode, you must understand the following terminology: PENDING MODE The operating mode in which string data, previously buffered in EDIT mode, is held until queried by the host. The QTERM can only enter PENDING Mode after passing through EDIT Mode. The QTERM enters PENDING Mode when it encounters the EOP Terminator while processing string data. When this happens, instead of transmitting the EDIT buffer to the host, as would happen in Block Mode, the QTERM enters PENDING Mode, the keypad is disabled, and the LCD blinks to indicate to the user that no more data may be entered and that the QTERM is waiting for a query from the host. The host must then query the QTERM for the contents of the EDIT buffer. When queried, the QTERM transmits a packet containing the buffer contents, the keypad becomes active, the LCD stops blinking, and the terminal reverts to IDLE mode. TURN-AROUND TIME Multidrop turn-around time is the time between the reception of the last byte of an incoming packet to when the terminal switches on its transmitter to send a response packet.
29 This time is programmable on the QTERM via a setting in the QDATA file. BROADCAST PACKET A data packet sent by the host which is prefixed with the unit address “00” ; all terminals on the network will process this packet. Because all the terminals process Broadcast Packets, no terminal is allowed to return a response packet in answer to a Broadcast. 4.4.1
Multidrop Drivers and the Hardware Interface
The EIA-422 interface is not normally used as a multidrop network, but it can be if only one host is allowed per network. The host does not need tri-state transmit drivers since the host's transmitter is only connected to the QTERM's receiver and never needs to share its transmit line with other transmitters. The EIA-485 interface uses the same channel to transmit and receive so the host must be able to switch its driver direction from transmit to receive. EIA-485 is robust but it is very unforgiving of timing and protocol mismatches between the host and the terminal. Be very careful in the design of your network interface and software and you will be rewarded with reliable communications; be complacent and you will regret it. 4.4.1.1
Turn-Around Time
The network driver on a multi-drop terminal must be switched on when the terminal is transmitting a packet, and switched off (high impedance) at all other times, so that other terminals can use the network. This is done automatically by the QTERM software. The host must control its own transmit line switching. Turn-around time only has meaning on an EIA-485 multidrop network. Because a multidrop EIA-422 network uses separate channels to transmit and receive, the host need not switch its transmitter direction or implement a turn-around time delay before transmitting. Turn-around time is critical on an EIA-485 network. On an EIA-485 network, after the host has sent the stop bit of the last byte in a packet to a network QTERM, it must switch its drivers to receive in less time than the QTERM's current turn-around time setting or the network will fail. 4.4.1.2
Network Biasing and Matching Resistors
On any multidrop network, there will be periods of inactivity when the network will not be actively driven by either the host or a QTERM. During these periods, the network may “float.” You must ensure that the differential voltage
Beijer Electronics Fax 801-466-8792 Web www.beijerelectronicsinc.com Phone 801-466-8770
Page 40
30
QTERM-IV/P40 User's Manual between the + and - network lines cannot float enough to produce a phantom start bit at the QTERM or the QTERM will think it is receiving data when it is not. This will cause network communications faults and other problems which can be difficult to diagnose. To prevent these problems, you must bias the network towards the “marking” state so that it will always enter the “marking” state when it is not being actively driven. Since both the EIA-422 and -485 networks are non-inverted, the simplest way to implement the needed bias is to “pull up” the “+” line by connecting a 1kΩ to 100kΩ resistor between the “+” line and power, and “pull down” the “-” line by connecting a similar resistor between the “-” line and ground. This will ensure that the network is always “marking” when idle. On an EIA-422, multidrop network, the QTERM's receive lines (“+” and “-”) are always driven by the host so you don't need to pull these lines up or down. The QTERM's transmit lines are sometimes tri-stated so these must be biased to prevent the host from seeing phantom noise at its receiver. The “marking” bias usually only needs to be applied at one point on the network. If your network is very long (over 1000 feet or so) you may need to “terminate” the network; most networks will not require termination. This means installing an impedance matching resistor between the “+” and “-” lines on your network. On an EIA-422 network, you must “terminate” the transmit and the receive pairs separately, if you need to terminate the network at all. A typical matching-resistor value would be 147Ω, 1/4 watt. This resistor should be installed in the QTERM farthest from the host. 4.4.2
Multidrop Data Packets
All multidrop packets are formatted as follows: <ADR1> <ADR2> <DATA...> <EOP> where: <ADR1>=Unit address MSD, ASCII decimal digit, 0 to 9 <ADR2>=Unit address LSD, ASCII decimal digit, 0 to 9 <DATA....>=Data bytes, zero or more data bytes <EOP>=End-Of-Packet Terminator byte Unit Address. Each QTERM attached to a multidrop network must have a unique address from “01” to “99”. This address can be set either during power-on setup or by a QDATA download. To send a packet to a QTERM, the host puts the unit's address in the ADR1 and ADR2 fields in the data packet. The response packet returned by the QTERM will also contain that unit's address in these fields.
Address “00” is used to indicate a broadcast packet. Broadcast packets are received and processed by all QTERMs connected to the network, regardless of their addresses. Since all the terminals on a network process broadcast packets at the same time, the QTERM never transmits a response packet in answer to a broadcast packet. Data Bytes. The <DATA....> portion of the packet consists of zero or more bytes of data (i.e. an empty packet is valid). In packets sent by the host, the DATA portion will usually consist of commands and/or display data. In packets returned by the QTERM-, the DATA portion will always contain one of the following:
• an ASCII ACK or NAK for acknowledgment (byte values x06 and x15, respectively)
• a status byte • a command response string • the contents of the QTERM's EDIT buffer • nothing (Null packet) The only invalid value for a data byte (whether to or from the host) is the EOP Terminator byte. End-of-Packet. The EOP character is used to terminate all data packets. 4.4.3
Receiving Data from the Host
Data received from the host is processed the same as in Block Mode. 4.4.4
Response Packets
Response packets are generated similarly to Block Mode. All response packets are prefixed with the unit address of the responding terminal. ACK and NAK response packets can be disabled with the QDATA file's [MD/Block response mode] field. 4.4.5 Transmitting Data to the Host and the Operation of EDIT Mode This is also similar to Block Mode with one major difference: the EDIT Buffer is not sent when the QTERM encounters the EOP Terminator, within a string definition, while in EDIT mode. Instead the QTERM enters PENDING mode, the LCD flashes and the keypad is disabled. The LCD flash rate is controlled by the “Set LED Blink Rate” command. If the flash rate is set too fast, the display will be difficult to read.
Beijer Electronics Fax 801-466-8792 Web www.beijerelectronicsinc.com Phone 801-466-8770
Page 41
QTERM-IV/P40 User's Manual Once the QTERM enters PENDING mode, it will remain there until the host sends a packet containing the Query Buffer command. The host must send a packet containing the “Query Buffer” command to receive the contents of the QTERM's EDIT buffer. When the QTERM receives the “Query Buffer” command, its EDIT buffer will be transmit-
31 ted to the host, PENDING mode will terminate, the LCD will stop flashing and the QTERM will return to IDLE mode to await the next event. Data packets transmitted by a QTERM are always prefixed with the unit address of the responding QTERM.
Beijer Electronics Fax 801-466-8792 Web www.beijerelectronicsinc.com Phone 801-466-8770
Page 42
32
QTERM-IV/P40 User's Manual
Beijer Electronics Fax 801-466-8792 Web www.beijerelectronicsinc.com Phone 801-466-8770