The SCSI Mode Sense and Mode Select commands provide for control of various operating parameters. This application note contains suggestions for use.
The SCSI Mode Sense command requests information about various operating parameters from the Gypsy, whereas the Mode Select command instructs the Gypsy on how to set the various operating parameters. The Gypsy maintains separate parameters for each initiator.
The Mode Sense command has the following structure.
MODE SENSE(6) command
+-----+--------+--------+--------+--------+--------+--------+--------+--------+
| Bit| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|Byte | | | | | | | | |
+-----+--------+--------+--------+--------+--------+--------+--------+--------+
| 0 | Operation code (1Ah) |
+-----+--------------------------+--------+--------+--------------------------+
| 1 | Logical unit number |Reserved| DBD | Reserved |
+-----+-----------------+--------+--------+--------+--------------------------+
| 2 | PC | Page code |
+-----+-----------------+-----------------------------------------------------+
| 3 | Reserved |
+-----+-----------------------------------------------------------------------+
| 4 | Allocation length |
+-----+-----------------------------------------------------------------------+
| 5 | Control |
+-----+-----------------------------------------------------------------------+
The Gypsy does not make use of any block descriptors, so the Disable Block Descriptors (DBD) bit is ignored. A value of 0 means the target may return zero or more block descriptors, and a value of 1 means the target shall not return any block descriptors in the returned Mode Sense data.
The Page Control (PC) field defines the type of mode parameter values to be returned in the mode pages. This field only affects the mode parameters within the mode pages, and does not affect the PS bit, page code, page length, or buffered mode fields. The following table defines the PC field.
| Code | Type of parameter |
|---|---|
| 00b | Current values |
| 01b | Changeable values |
| 10b | Default values |
| 11b | Saved values |
A PC field value of 0h requests that the target return the current values of the mode parameters. The current values returned are:
A PC field value of 1h requests that the target return a mask denoting those mode parameters that are changeable. In the mask, the fields of the mode parameters that are changeable shall be set to all one bits, and the fields of the mode parameters that are non-changeable (i.e. reserved by the Gypsy) shall be set to all zero bits. An attempt to change a non-changeable mode parameter (via Mode Select) results in an error condition.
The initiator should issue a Mode Sense command with the PC field set to 1h and the page code field set to 3Fh to determine which mode pages are supported, wich mode parameters within the mode pages are changeable, and the supported length of each mode page prior to issuing any Mode Select commands.
A PC field value of 2h requests that the target return the default values of the mode parameters. Parameters not supported by the Gypsy shall be set to zero. Default values are accessible, even if the printer is not operational.
A PC field value of 3h requests that the target reutrn the saved values of the mode parameters. The Gypsy does not save parameters, so this request will be terminated with CHECK CONDITION status, and the sense key set to ILLEGAL REQUEST, and the additional sense code set to SAVING PARAMETERS NOT SUPPORTED.
The Mode Select command has the following structure.
MODE SELECT(6) command
+-----+--------+--------+--------+--------+--------+--------+--------+--------+
| Bit| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|Byte | | | | | | | | |
+-----+--------+--------+--------+--------+--------+--------+--------+--------+
| 0 | Operation code (15h) |
+-----+--------------------------+--------+--------------------------+--------+
| 1 | Logical unit number | PF | Reserved | SP |
+-----+--------------------------+--------+--------------------------+--------+
| 2 | Reserved |
+-----+-----------------------------------------------------------------------+
| 3 | Reserved |
+-----+-----------------------------------------------------------------------+
| 4 | Parameter list length |
+-----+-----------------------------------------------------------------------+
| 5 | Control |
+-----+-----------------------------------------------------------------------+
A page format (PF) bit of zero indicates that the MODE SELECT parameters are as specified in SCSI-1, (i.e. all parameters after the block descriptors are vendor-specific). A PF bit of one indicates that the MODE SELECT paramters following the header and block descriptor(s) are structures as pages of related parameters, and are as specified in the SCSI-2 standard. The Gypsy supports Page Formats.
A save pages (SP) bit of zero indicates the target shall perform the specified MODE SELECT operation, and shall not save any pages. Because the Gypsy does not support saved pages, so if the SP bit is set to one, the command shall be terminated with CHECK CONDITION status. The sense key shall be set to ILLEGAL REQUEST, and the additional sense code set to INVALID FIELD IN CDB.
The parameter list length field specifies the length in bytes of the mode parameter list that shall be transferred from the initiator to the target during the DATA OUT phase. A parameter list length of zero indicates that no data shall be transferred. This condition shall not be considered as an error. The Gypsy supports the following parameter list lengths: 0h, 4h, 10h.
The mode parameter list (the data returned by the Mode Sense command) has the following generic format.
Mode parameter list
+------+--------+--------+--------+--------+--------+--------+--------+--------+
| Bit| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|Byte | | | | | | | | |
+------+--------+--------+--------+--------+--------+--------+--------+--------+
|0 - n | Mode parameter header |
+------+-----------------------------------------------------------------------+
|0 - n | Block descriptor(s) |
+------+-----------------------------------------------------------------------+
|0 - n | Page(s) |
+------+-----------------------------------------------------------------------+
The mode parameter header has the following format.
Mode parameter header(6)
+-----+--------+--------+--------+--------+--------+--------+--------+--------+
| Bit| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|Byte | | | | | | | | |
+-----+--------+--------+--------+--------+--------+--------+--------+--------+
| 0 | Mode data length (mode sense only) {n-1=0F} |
+-----+-----------------------------------------------------------------------+
| 1 | Medium type {=0} |
+-----+-----------------------------------------------------------------------+
| 2 | WP | Buffered mode | Reserved |
+-----+-----------------------------------------------------------------------+
| 3 | Block descriptor length {=0} |
+-----+-----------------------------------------------------------------------+
When using the Mode Sense command, the mode data length field specifies the length in bytes of the following data that is available to be transferred. The mode data length does not include itself. When using the Mode Select command, this field is reserved.
The medium type returned by the Gypsy is always 0.
The Gypsy does not Write Protect (WP) the plotter's output medium, so this field should always be 0.
When using the Mode Sense command, the buffered mode field always returns the current value of this paramter (regardless of PC field).
When using the Mode Select command, a buffered mode of zero indicates that the Gypsy shall not report a GOOD status on Print or Format commands until the data are actually printed. A buffered mode of one indicates that the target may report a GOOD status on Print or Format commands as soon as the data have been transferred to the SCSI device buffer. The data from one or more commands may be buffered prior to printing. Buffered modes of 2h through 7h are reserved.
The Gypsy does not use block descriptors, so the block descriptor length will remain 0.
The Gypsy has only 1 mode code page, page code 20h. It is defined by the following table.
GYPSY-2000 options
+-----+--------+--------+--------+--------+--------+--------+--------+--------+
| Bit| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|Byte | | | | | | | | |
+-----+--------+--------+--------+--------+--------+--------+--------+--------+
| 0 | PS |Reserved| Page code (20h) |
+-----+--------+--------+-----------------------------------------------------+
| 1 | Page length (06h) |
+-----+-----------------------------------------------------------------------+
| 2 | (MSB) |
+-----+--- FORMAT timeout (seconds) ---+
| 3 | (LSB) |
+-----+-----------------------------------------------------------------------+
| 4 | (MSB) |
+-----+--- PLOT timeout (seconds) ---+
| 5 | (LSB) |
+-----+-----------------------------------------------------------------------+
| 6 | (MSB) |
+-----+--- Automatic RLTER line length (bytes) ---+
| 7 | (LSB) |
+-----+--------------------------------------------+--------------------------+
| 8 | Reserved | RDYCOND |
+-----+--------------------------------------------+--------+--------+--------+
| 9 | Reserved |exactRLTER|PLON2OFF|
+-----+-----------------------------------------------------+--------+--------+
| A | Reserved |
+-----+--- ---+
| B | |
+-----+-----------------------------------------------------------------------+
The parameters savable (PS) bit is only used with the MODE SENSE command. This bit is reserved with the MODE SELECT command. A PS bit of one indicates that the target is capable of saving the page in a non-volatile vendor-specific location. The GYPSY is not capable of saving parameters, so this field will always be returned as a zero.
The FORMAT timeout is the maximum time allowed for a FORMAT command to complete. The default is 30 seconds. A value of 0000h in MODE SELECT specifies that the target shall use its default value. In any case, the target shall report its actual value in the MODE SENSE data (not 0000h).
The FORMAT timeout may also be set when issuing a FORMAT command with 4 bytes of data. The MODE SELECT and FORMAT commands set the same FORMAT timeout. The Gypsy retains only one format timeout, but may be set via two commands. This timeout can not be set via the FORMAT command if the plotter is not operational. The MODE SELECT command is not dependent upon the plotter being operational, so it is a better choice when wishing to set the format timeout. The FORMAT command would then need to supply only one or two bytes of data.
The PLOT timeout is the maximum time allowed for each DMA transfer to the plotter. If the automatic RLTER feature is not enabled, then DMA is programmed to transfer the whole PLOT buffer to the plotter. If the automatic RLTER feature is enabled, then DMA is programmed to transfer one scan line of data to the plotter. The default PLOT timeout is 30 seconds. A value of 0000h in MODE SELECT specifies that the target shall use its default value. In any case, the target shall report its actual value in the MODE SENSE data (not 0000h).
The automatic RLTER line length field specifies the number of bytes sent to the plotter before a Remote Line TERminate (RLTER) is sent to the plotter. If this feature is enabled (non-zero), a RLTER will be issued at the completion of each PLOT command, even if this results in a partial line, unless the exactRLTER field is enabled (set to a one) (see description below). A value of 0000h in MODE SELECT specifies that the target shall not automatically send RLTER during a PLOT command (disables the auto RLTER feature). The target shall report its actual value in the MODE SENSE data.
The RDYCOND field controls the plotter's READY signal conditioning performed by the GYPSY. Changes in READY conditioning result in changes in the nominal data rate of the plotter port. The following calculated table gives the RDYCOND field value and its associated nominal plotter port data rate (in MBytes/second) using a "null plotter".
| RDYCOND | Nominal plotter port data rate (MB/sec) |
|---|---|
| 0 | 1.5 |
| 1 | 1.5 |
| 2 | 1.7 |
| 3 | 1.8 |
| 4 | 2.1 |
| 5 | 2.4 |
| 6 | 2.8 |
| 7 | 2.8 |
The default plotter port data rate is 1.5 MB/sec (RDYCOND=1). Selection of faster plotter port data rates may result in improper functioning. The use of the 2.8 MB/sec selections is not advised. The target shall report its actual value in the MODE SENSE data.
The PLON2OFF field controls the action taken by the target when the printer device goes offline while data is being transferred to the printer device. If this feature is enabled (non-zero), the target will reselect the initiator if currently disconnected, or terminate the current PLOT or FORMAT command if currently connected on the SCSI bus. The ending status will be CHECK CONDITION. The sense key indicate Not Ready. The additional sense code and sense code qualifier will indicate Ready to Not Ready transition (8200h). The target shall report its actual value in the MODE SENSE data.
The exactRLTER field controls the automatic RLTER at the end of a PLOT command which does not provide enough data to completely satisfy the line length specified for automatic RLTER operation. The exactRLTER field is applicable only when an automatic RLTER line length has been specified. When exactRLTER is not enabled (zero), a RLTER is issued at the completion of each PLOT command, even if this results in a partial line. When exactRLTER is enabled (one), a RLTER is issued only when enough data has been sent to satisfy the automatic RLTER line length. The GYPSY keeps a count of the residual amount of data. When the count finally reaches the line length, the automatic RLTER is issued. One or more PLOT commands may be necessary to send enough data to accumulate a sufficient quantity to cause the automatic RLTER. This count is cleared each time the exactRLTER field is changed, and each time any one of the following is issued: RFFED, RLTER, CLEAR, and RESET. The exactRLTER operation defaults to being disabled. The target shall report its actual value in the MODE SENSE data.
Buffered mode of operation grants permission to the Gypsy to report a GOOD status on PRINT and FORMAT commands as soon at the Gypsy receives the data. This allows the host to begin processing again instead of waiting for the Gypsy to transfer data to the plotter, and then for the Gypsy to report the status. In general, buffered mode of operation is desirable because it increases both the host's and Gypsy's throughput.
A timeout may be set for the FORMAT command and another timeout for the PLOT command. These timeouts give a maximum amount of time the initiator will allow the Gypsy to work on the given command. These timeouts are intended to keep the host process from hanging when the plotter is paused.
The Gypsy can break up data from a single PLOT command, inserting Remote Line Terminates every nn bytes, where nn is set by the host. This feature is very beneficial when the host can produce multiple raster lines which are not the plotter's full line width. A RLTER may or may not be issued at the end of the PLOT data, depending upon any partial line data being leftover, and the exactRLTER parameter.
A parameter is available to affect how the Gypsy conditions the plotter's READY signal. Its use is dependent upon the plotter's implementation of the interface. The default value is recommended.
The Gypsy will try to quickly report back to the host when the plotter becomes unavailable, if the PLON2OFF bit has been set.