mrd_request_sense - Get the status of a medium changer. Windows NT mrd.dll UNIX /usr/lib/libmrd.a OpenVMS MRD$RTL.EXE #include <mrd_common.h> #include <mrd_message.h> int mrd_request_sense( robot_info_t *robot_info, dev_status_t *dev_status, int os_status);
1 – Parameters
o robot_info - This is the address of a robot_info_t structure initialized using mrd_startup(3mrd) or mrd_show(3mrd). This data structure contains the element starting address and counts for each type of element, which are needed to map an absolute element to the correct zero relative address and type. o dev_status - The dev_status is the address of a dev_status_ t structure, which is used to pass back detailed error information in the event of a command failure. o os_status - When mrd_request_sense(3mrd) is used directly by an application, this argument should be MRD_CHECK_SENSE, or the operating system specific error code that indicates a device failure. On Digital UNIX this is EIO.
2 – Description
This routine performs a SCSI Request Sense command, or equivalent if some other I/O architecture is supported. It is used by all MRD API routines to determine the cause of a command failure. The robot_info is the address of a robot_info_t structure that has been opened by mrd_startup(3mrd). If the medium changer isn't opened, the Request Sense command will fail with the operating system error for trying to use an unopened device. The dev_status_t structure includes the code, os_status, and SCSI error fields. The following describes how to decode errors with the dev_status_t structure. SCSI Errors SCSI errors are indicated when the value of the valid field of the SCSI error is not equal to 0. The key, asc, and ascq fields provide additional information to help determine the cause of the error. The code usually maps the Additional Sense Code and Additional Sense Code Qualifier (ASC/ASCQ) values to an MRD error. The asc and ascq values are copied from the request sense data returned by the target. The Additional Sense Code (asc) indicates further information related to the error or exception condition reported in the sense key field. The Additional Sense Code Qualifier (ascq) indicates detailed information related to the additional sense code. For more information, consult the SCSI-2 Specification. Operating System Errors Operating system errors are indicated when the value of the valid field of the SCSI error is equal to 0 and the value of the os_ status field is not equal to 0. This result is most likely caused by an operating system error, and probably has a mapped error in MRD. MRD Errors MRD errors are indicated when the value of the os_status field is 0, and the value of the valid field of the SCSI error is 0. This result is most likely caused when MRD encounters its own failure. In typical usage by MRD, the os_status argument will be an operating system specific code. However, The SCSI-2 specification allows Request Sense to be used at any time to obtain status information about a device. To support this feature, the MRD implementation of mrd_reqeust_sense(3mrd) can be called with the code MRD_CHECK_SENSE to force a Request Sense command.
3 – Example
/* * This is an example of using mrd_request_sense(3mrd) * to see what state a medium changer is in. The MRD * implementation of Request Sense only collects the * Sense Key, Additional Sense Code and Additional Sense * Code Qualifier. * * Usage: * * mrd_request_sense robot [ more-robots... ] */ #ifndef lint static char SccsId[] = "@(#)mrd_request_sense.c 1.1 4/16/97" ; #endif #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <mrd_common.h> #include <mrd_message.h> char *device_sense = "Sense data for %s: %s (%d,0x%x,0x%x).\n" ; char *sense_failed = "Request Sense failed on %s: %s.\n" ; main(int argc, char *argv[]) { int rc ; /* counter */ int status ; /* return status */ char *robot ; /* Robot to open */ robot_info_t robot_info ; /* Robot data */ dev_status_t dev_status ; /* Device status */ char log_info[MRD_MAX_LOG_STRING+1] ; /* * Check that there are enough arguments. */ if( argc < 2 ) { printf("usage: %s robot [ robot... ]\n", argv[0]) ; exit(1) ; } /* * Initialize the channel field of the robot_info, so * mrd_startup(3mrd) will actually open the robot. */ robot_info.channel = BAD_CHANNEL ; for(rc = 1; rc < argc; rc++) { /* * The robot for this command. */ robot = argv[rc] ; status = mrd_startup(robot, &robot_info, log_info) ; if( status != MRD_STATUS_SUCCESS ) { printf("Startup failed on %s: %s.\n", robot, mrd_strstatus(status)) ; continue ; } memset((void *)&dev_status, 0, sizeof(dev_status)) ; /* * mrd_request_sense(3mrd) will never return * MRD_STATUS_SUCCESS. If no Request Sense data * is available, it will return MRD_STATUS_NO_SENSE. */ status = mrd_request_sense(&robot_info, &dev_status, MRD_CHECK_SENSE) ; /* * Print the Key/ASC/ASCQ data for device errors. */ if( dev_status.valid ) printf(device_sense, robot, mrd_strstatus(status), dev_status.key, dev_status.asc, dev_status.ascq) ; /* * Just print the MRD error. */ else printf(sense_failed, robot, mrd_strstatus(status)) ; (void)mrd_shutdown(&robot_info) ; } return 0 ; }
4 – Return Values
The routine mrd_request_sense(3mrd) never returns MRD_STATUS_ SUCCESS. If the os_status isn't the operating system specific code that forces a Reqeust Sense command or MRD_CHECK_SENSE, mrd_map_os_error(3mrd), is used to map the os_status to an MRD status code. Otherwise, a Request Sense (or equivalent) is performed and the result mapped to an MRD status code with mrd_ scsi_decode(3mrd).
4.1 – MRD_STATUS_PARAM
This error is returned when a pointer argument passed to an MRD routine is NULL, unless the routine is documented as one allowing a NULL pointer.
4.2 – MRD_STATUS_NO_SENSE
This error is returned by mrd_scsi_decode(3mrd) when the asc, ascq and key values are all zero (0). It is also returned when the key value is less than zero or greater than 15.
4.3 – MRD_STATUS_RECOVERED_ERROR
This error occurs when a SCSI device returns only a sense key of 1h. This indicates that although a command successfully completed, the target device had performed some internal error recovery.
4.4 – MRD_STATUS_MEDIUM_ERROR
This error occurs when ASC and ASCQ are zero, but the sense key is 3h. This occurs when the target encounters a nonrecoverable error due to a flaw in the medium.
4.5 – MRD_STATUS_ROBOT_HW_ERROR
This error occurs when ASC and ASCQ are zero, but the sense key is 4h. This occurs when the target encounters a nonrecoverable hardware error.
4.6 – MRD_STATUS_ROBOT_ILLEGAL_REQUEST
This error occurs for a variety of reasons. It is used when a sanity check fails in the code that attempts to move a cartridge to the Pass-Through Mechanism, when the robot type isn't a TL82n. It is used in the mrd_lock(3mrd) code when the value is not one of ALLOW_REMOVAL or PREVENT_REMOVAL. It is used when the medium changer does not support the Prevent /Allow Medium Removal command or the lock value is not one or zero. The specific cause can be determined by examining the ASC /ASCQ values in the status data. It is used when a call to mrd_initialize_element(3mrd) is issued against a medium changer that does not support the Initialize Element Status command. It is used when the medium changer does not support the Position To Element command. The seven and five slot DLT loaders do not support the command, though the TL820 and TL810 family libraries do. Some models of TLZ6L and TLZ7L do not support the command and may take a long time to fail. It is used when the medium changer does not support the Ready Inport command. The TL820 family of DLT libraries support this command. The TL810 family of DLT libraries allows this command to succeed, but it doesn't perform any function. It is also used for a SCSI command failure, when the ASC is set to one of: o 0x1A - Parameter list length error o 0x20 - Invalid command operation code o 0x22 - Unsupported command o 0x24 - Illegal field in CDB o 0x25 - Logical unit not supported o 0x26 - Threshold parameters not supported o 0x28 - Import or Export element accessed o 0x2C - Command sequence error o 0x39 - Saving parameters not supported o 0x3D - Invalid bits in Identify message o 0x53 - Medium removal prevented This status is also returned when the ASC and ASCQ are zero, but the key is five (5).
4.7 – MRD_STATUS_ROBOT_ATTENTION
This error occurs when a SCSI command fails with the ASC set to one of 0x29, 0x2A or 0x2F. The log_info contains the ASCQ. The SCSI translations for these error codes are: o 0x29 - Power-on, Reset or Bus device reset occurred o 0x2A - Mode Parameters Changed o 0x2F - Command cleared by another initiator This error also occurs when the ASC and ASCQ are zero, but the SCSI sense key is 6h.
4.8 – MRD_STATUS_DATA_PROTECT
This error is returned by mrd_scsi_decode(3mrd) when the asc and ascq are zero, but the key value is seven (7).
4.9 – MRD_STATUS_BLANK_CHECK
This error is returned by mrd_scsi_decode(3mrd) when the asc and ascq are zero, but the key value is eight (8).
4.10 – MRD_STATUS_VENDOR_UNIQUE_ERROR
This error occurs when the internal routine used to decode SCSI- 2 errors encounters an error that it has not been written to antipicate. This error also returned when the ASC is zero and the ASCQ is not one of zero or six, and when ASC/ASCQ are both zero and the key is 9h.
4.11 – MRD_STATUS_COPY_ABORTED
This error is returned by mrd_scsi_decode(3mrd) when the asc and ascq are zero,
4.12 – MRD_STATUS_SENSE_EQUAL
This error is returned by mrd_scsi_decode(3mrd) when the asc and ascq are zero, but the key value is Ch (12).
4.13 – MRD_STATUS_VOLUME_OVERFLOW
This error is returned by mrd_scsi_decode(3mrd) when the asc and ascq are zero, but the key value is Dh (13).
4.14 – MRD_STATUS_MISCOMPARE
This error is returned by mrd_scsi_decode(3mrd) when the asc and ascq are zero, but the key value is Eh (14).
4.15 – MRD_STATUS_SENSE_RESERVED
This error is returned by mrd_scsi_decode(3mrd) when the asc and ascq are zero, but the key value is Fh (15).
4.16 – MRD_STATUS_ROBOT_COMM_ERROR
This error also occurs as the result of a SCSI command failure, when the ASC is set to one of: o 0x08 - Logical unit communcation errors. o 0x43 - Message error o 0x45 - Select or Reselect failure o 0x47 - SCSI parity error o 0x48 - Initiator detected error message received o 0x49 - Invalid message error o 0x4A - Command phase error o 0x4B - Data phase error o 0x4E - Overlapped commands attempted o 0x54 - SCSI to host system interface failure
4.17 – MRD_STATUS_ROBOT_MECH_ERROR
This error occurs as the result of a SCSI command failure, when the ASC is set to one of: o 0x15 - Positioning error. o 0x8B - Vendor unique; Pass-through mechanism errors on the TL82n
4.18 – MRD_STATUS_AUTOCLEAN
This error occurs when a SCSI command fails with the ASC set to 0x30 and the ASCQ set to 0x3. On TL8nn libraries supporting Auto-clean, it indicates that a command was attempted while an auto-clean was in progress.
4.19 – MRD_STATUS_CART_DAMAGED
This error occurs when a SCSI command fails with the ASC set to 0x30, but the ASCQ is NOT a value of 0x3. The log_info will contain the ASCQ.
4.20 – MRD_STATUS_ELEMENT_INVALID
This error occurs when a SCSI command fails with the ASC set to 0x21. The log_info will contain the ASCQ. This indicates that an invalid element address reached the medium-changer. For example, specifying the 13th slot when only 12 slots are present.
4.21 – MRD_STATUS_CART_NOT_AVAIL
This error can occur on the TL81n and TL82n family of DLT libraries when the source of a move is a drive and the cartridge in the drive is still on-line. These robots do not allow moving the cartridge until the drive is taken offline.
4.22 – MRD_STATUS_DESTINATION_FULL
On routines that perform a SCSI Move Medium command, this error indicates that the destination element already has a cartridge in it.
4.23 – MRD_STATUS_SOURCE_EMPTY
On routines that perform a SCSI Move Medium command, this error indicates that the source element is empty.
4.24 – MRD_STATUS_ROBOT_DOOR_OPENED
This occurs when a SCSI command fails with the ASC set to 0x80 and the ASCQ set to 0x0. On TL8nn libraries this typically indicates that the cabinet door was opened during a command operation.
4.25 – MRD_STATUS_DEVICE_INVALID
This error code is used when an OpenVMS system service fails with the status SS$_NOSUCHDEV or SS$_IVDEVNAM. This will typically occur in mrd_startup(3mrd) when the caller tries to open a device which doesn't exist or uses an invalid device name. This error also occurs when the routine is called on behalf of a device controlled by the JU driver. The Media Robot Utility no longer uses the JU driver.
4.26 – MRD_STATUS_ROBOT_NOT_READY
Under OpenVMS and Digital UNIX, this error occurs as the result of a SCSI command failure, when the ASC is set to one of: o 0x80 - When the ASCQ is not zero (0). o 0x81 - Vendor unique; gripper errors on the TL82X and TL81X o 0x04 - Logical unit not ready o 0x3E - Logical unit has not been self configured o 0x40 - Diagnostic failure; ASCQ indicates component o 0x42 - Power-on self test failure o 0x44 - Internal target failure o 0x46 - Unsuccessful soft reset o 0x4C - Logical unit failed self-configuration This status is also returned when the ASC and ASCQ are zero, but the key is two (2).
4.27 – MRD_STATUS_ROBOT_CMD_ABORTED
This error code is used when an OpenVMS system service fails with the status SS$_ABORT.
5 – Related Functions
Functions: o mrd_move(3mrd) o mrd_load(3mrd) o mrd_unload(3mrd) o mrd_inject(3mrd) o mrd_eject(3mrd) o mrd_show(3mrd) o mrd_ready_inport(3mrd) o mrd_position(3mrd) o mrd_initialize(3mrd) o mrd_home(3mrd) o mrd_find_cartridge(3mrd) o mrd_startup(3mrd) o mrd_shutdown(3mrd) o mrd_lock(3mrd)