Make yourself a favour... (you're skeptical, eh? I was too...)

SCSI - Small Computers System Interface

SCSI2

Recommended SCSI hw & books from Amazon
  • The SCSI2 standard specification
  • SCSI2 command set reference
  • SCSI2 device types
  • SCSI2 commands
  • SCSI2 devices interchangeability
  • SCSI2 targets
  • Sending SCSI2 commands
  • Error reporting
  • Differences between devices of the same type
  • The SCSI2 standard specification

    SCSI2 is one of the most interesting standards in the PC world. The first thing to point out is that it is an actual standard, compared to its predecessor SCSI1. So when a device is labeled "SCSI2" you are assured that some basic characteristics are implemented. We will revise the concepts underlying SCSI2 from the programmer's standpoint.

    SCSI2 is defined in its specification, designated with X3.131-1994 and published by the ANSI. This document is easy to find on the Internet (check here). Some years ago I downloaded my copy and printed it, then I started using it as the basic reference.

    SCSI2 specification is a structured document that describes all the aspects of the standard, but the only things the programmer has to concern of are the theory of operations and the command set of the SCSI2 device type that he is going to deal with. Forget everything else: physical characteristics, bus phases, etc.: the ASPI manager will deal with those annoyances for you, leaving the programmer the only task to prepare the right command sequence in the right way for the device to operate.

    SCSI2 command set reference

    SCSI2 specification alone is not sufficient for the programmer to deal with a SCSI2 device. Fortunately each device has its own SCSI2 command set reference, and you can ask it to the manufacturer or download it from its site. I got the copies for the devices I was interested in directly from Fujitsu, Bell+Howell, Plasmon and Pioneer. They are usually happy to send it to you.

    On the contrary I could never get the SCSI2 command set reference that I asked to the italian representative of Ricoh. He made me subscribe a non-disclosure agreement (?!?) and then never sent anything to me. This is why I never bought a scanner from Ricoh.

    SCSI2 device types

    There are 10 different device types defined in the standard (see at the end of SCSIDEFS.INC):
    • Direct access devices, like the well known SCSI2 hard disks
    • Sequential access devices, like magnetic tape recording units
    • Printer devices
    • Processor devices
    • WORM devices, the write-once read-multiple optical disk units
    • CD-ROM devices
    • Scanner devices
    • Optical memory devices
    • Medium changer devices, like juke boxes
    • Communication devices
    A chapter is dedicated to each device in the SCSI2 specification. Any chapter is roughly divided into two sections: the model and the command set.

    In the model section (the first paragraph at the beginning of each chapter) the description and the theory of operations for each particular device type are given. Each manufacturer should design and build that particular device conforming to the model provided.

    So if you were a SCSI2 CD-ROM manufacturer you would look at chapter 14, paragraph 1 of the SCSI2 specification to know how to design your devices (chapter 14 is dedicated to CD-ROM devices).

    In the command set section of the chapter a complete list of commands for each particular device type is given.

    SCSI2 commands

    Some SCSI2 commands are valid for *any* device type. Test unit ready, e.g., is a command that every SCSI2 device must support.

    Some other commands are specific to a particular device type. Object position, e.g., is a command supported only by scanner devices. Rezero unit, e.g., is a command supported only by medium changer devices (juke boxes).

    Each manufacturer should conform to the commands requirements and sintax in the list provided for each device type.

    SCSI2 commands can be broken into 3 categories:

    • mandatory: the device must support that command
    • optional: the device can support that command
    • vendor specific: to satisfy particular manufacturer's needs
    Four mandatory commands are valid for *any* device type:
    • Test unit ready
    • Request sense
    • Inquiry
    • Send diagnostic
    Any SCSI2 device worth of its name must support these commands.

    SCSI2 devices interchangeability

    According to what I said so far it seems that programming a SCSI2 device by means of only its mandatory commands would provide a sort of interchangeability between models from different manufacturers.

    It is both true and not true, because some details in the implementation of the commands are left to the manufacturer. So as a general rule of thumb it is true, but do not be surprised if not. Later on I will point out some potential differences, so that you will be able to judge yourselves.

    SCSI2 targets

    As you know more than one device can be attached to the SCSI2 bus. A device receiving a command is often referred to as the target because it is individually reached among all the other attached devices.

    Targeting a particular device in the SCSI2 chain can be done because each device has its own SCSI2 address (ID and LUN). Any device will not respond to a command sent to a different address.

    Remember that any SCSI2 device has its own intelligence, that resides in its embedded controller. This intelligence allows for the independence of SCSI2 devices from the Personal Computer they are attached to.

    Sending SCSI2 commands

    To send SCSI2 commands to SCSI2 devices make use of the ASPI manager invented and provided by Adaptec for the programmer to use.

    Error reporting

    Error reporting is of vital importance when dealing with SCSI2 devices. Each time a SCSI2 command goes wrong it is because the device has undergone a contingent allegiance condition. In these cases you should send a request sense command to the target device to know what happened. The device responds sending back the so called sense data, i.e. a set of bytes that provide detailed information about the device.

    Three items are important to check in the sense data: the sense key, the additional sense code (ASC) and the additional sense code qualifier (ASCQ).

    The sense key is a one-digit hex number that indicates the category of the allegiance condition that occurred to the device. Please refer to the SCSI2 specification for a complete description. Here I will give you only some codes to let you understand the type of information provided:

    • 1h - RECOVERED ERROR: indicates that the last command completed successfully with some recovery action performed by the target
    • 2h - NOT READY: indicates that the target cannot be accessed, and some operator's intervention may be required to correct this condition
    • 3h - MEDIUM ERROR: indicates that the command terminated with a non-recovered error caused by a flaw in the medium (the medium depends on the device type)
    • 4h - HARDWARE ERROR: the target detected a non-recoverable hardware failure during the self test or the execution of any command
    • 5h - ILLEGAL REQUEST: indicates that the target can't perform the received command, usually because of a wrong parameter passed
    • 6h - UNIT ATTENTION: indicates that the removable medium has been changed or the target device has been reset
    • 7h - DATA PROTECT: indicates that a command that reads or writes to a medium was attempted on a block that is protected from this operation
    The ASC (additional sense code) and the ASCQ (additional sense code qualifier) are two hex numbers that precisely indicate the error that occurred to the target device. Many of these numbers are defined by the manufacturer, so this would be a cause of no compatibility between two devices of the same type.

    This is also one of the reasons to keep at hand the SCSI2 command set reference of any SCSI2 device you are going to send commands to. The SCSI2 specification alone is not sufficient.

    Differences between devices of the same type

    The programmer should take into account some differences between devices of the same type that can affect programming for equipments coming from different manufacturers.

    A first thing to avoid is using vendor specific commands. Also avoid using optional SCSI2 commands. But this would be a simplicistic approach to the problem because, as we are going to see, there are some other issues that can't be avoided and must be individually solved.

    Furthermore avoiding optional SCSI2 commands might result in using expensive devices at their very basic capabilities.

    Two of the main concerns the programmer should take care of are:

    • the parameters passed to the target with each command sent to it
    • the ASC and ASCQ returned in the sense data returned by the target in case of a contingent allegiance condition
    These problems can be overcome by accurately planning the list of the equipment to be supported by an application program, and by managing each individual difference with a corresponding group of statements.

    This requires being in posses of the SCSI2 command set reference for any equipment in the list.

    Other issues to concern of may depend on particular types of SCSI2 devices.

    This is the case with medium changer devices (juke boxes). A juke box consists of four different elements inside: the disk parking area, the drives, the import/export drawer, and the transport unit. Each location is referred to by its individual number. But there is no guarantee that juke boxes from different manufacturers support the same numbering scheme.

    I wrote some programs for the Plasmon D-series of medium changer devices. This family supports 4 different numbering schemes, I know it because I got my copy of its SCSI2 command set reference. But I don't know whether my programs would work with a Kodak or a Pioneer juke box, in fact I would need to read their SCSI2 command set references to discover their own numbering schemes.

    Other big differences you can find among the category of CD-R writers. At the time SCSI2 specification was written I don't think CD-R writers were born, so if you look at the standard no SCSI2 CD-R writer device type is defined.

    If you ask a SCSI2 CD-R writer which device type it belongs to it responds it is a CD-ROM device type. In fact it behaves like that category of SCSI2 devices, with the difference that it has some commands more to provide the writing capability.

    The big problem with CD-R writers is that each manufacturer invented its own command set for the purpose of burning CD-R discs. There are at least five different command sets, but since the beginning of 1999 many manufacturers agreed to use the emerging SCSI3-MMC (Multi Media Commands) standard command set.

    Working with SCSI ? This is the book to buy: