ASPI ActiveX Control

Updated May 17, 1997

Introduction

ASPI.OCX is an ActiveX control allowing high-level languages such as Visual Basic to execute SCSI commands and therefore execute operations such as reading and writing non-FAT/NTFS disks, communications with tape devices and so on.

The ASPI ActiveX Control is shareware software. The Evaluation Edition is licensed for 15 days. If you find the control useful, a registration fee of $99 is required. Source code is available for $199. Registered users get a version of the control without the nag screen and an on-line help facility. Additionally, when asynchronous operation is supported, all registered users will receive a free upgrade.

For registration information, please see our Order Page.

SCSI - History

SCSI was designed originally by Shugart Associates and was named SASI. The specification called for a 50 pin cable with a parallel data bus of eight bits. Up to eight devices could be interconnected to the same cable because every device connecting to the cable drove it using open-collector drivers. Because every other wire on the cable was grounded, SASI could achieve close to 3MB/sec on a nine foot cable.

When ANSI ratified the specification, SCSI came into play and added a host of new features to the original specification. These included disconnect/reconnect where a device that was busy could free the bus for other devices to use and then reconnect when it's task was completed, and synchronous transfers where data could be burst on the cable at high data rates, therefore allowing other devices on the bus greater access.

The latest ANSI specification, SCSI-2 added features such as:

Command tagged queuing adds multi-tasking capabilities to each device. This scheme allows up to 255 commands to be sent to a device with the device (and not the host operating system) deciding the best possible order in which to execute them.

SCSI-3 is still in the design stages but will probably add:

ASPI - Advanced SCSI Programmer Interface

ASPI was developed by Adaptec in order to prevent vendors of SCSI software (such as tape backup programs) from having to support different SCSI drivers for each type of SCSI interface card. With only one other standard in place (CAM) at it's specification time, ASPI has become the de-facto standard of specifying application to peripheral SCSI interconnectivity.

Installation

Currently, there is no flashy installation program. In order to install ASPI.OCX, follow these steps:

REGSVR32 ASPI.OCX

ASPI.OCX also requires that a 32-bit ASPI manager be present in the system. With Windows 95, this is included with the operating system and is installed automatically. Windows NT does not contain an ASPI manager, so this must be downloaded from the Adaptec bulletin-board via the Adaptec Web Site. The file needed is called ASPI32.EXE . Installation instructions are included from Adaptec.

ASPI.OCX Programmers Interface

Parameters (properties):

AdapterCount - integer

Returns the number of SCSI host adapters present in the system. Read-only.

ASPIManagerName - string

Returns the name of the ASPI manager operating in the system. Read-only. This will normally return "ASPI for Win32".

AsyncMode - boolean

Not currently used. Future versions will contain support for asynchronous operation.

CDBSize - integer

Specifies the size of the SCSI command being sent. Typically, this will either be 6, 10 or 14. For example:

ASPI1.SCSIID = 0
ASPI1.HostAdapter = 0
ASPI1.CDBSize = 6
ASPI1.CDB = Chr$(0) & Chr$(0) & Chr$(0) & Chr$(0) & Chr$(0) & Chr$(0) ' test unit ready
On Error Resume Next
ASPI1.Execute

CDB - string

Contains the SCSI command (CDB = CommanD Block). For example:

ASPI1.CDBSize = 6
ASPI1.CDB = Chr$(8) & Chr$(0) & Chr$(0) & Chr$(0) & Chr$(1) & Chr$(0) ' read block zero
Buffer = ASPI1.ExecuteIn(512)

HostAdapter - integer

Specifies the host adapter for which the current command is intended. The first host adapter in the system is number zero. For example:

For HA = 0 to ASPI1.AdapterCount- 1
ASPI1.HostAdapter = HA
...
...
Next

HostAdapterMaxBuffer - long

Returns the maximum data transfer length supported by the host adapter. Read-only.

HostAdapterMaxSCSIID - integer

Returns the maximum number of SCSI peripherals that can be addressed by the current host adapter. This is a count, rather than a particular address, therefore subtract one for the highest address. Read-only. For example:

For ID = 0 to ASPI1.HostAdapterMaxSCSIID- 1
If ID <> ASPI1.HostAdapterSCSIID Then
...
...
End If
Next

HostAdapterName - string

Returns the internal description of the host adapter. Read-only.

HostAdapterSCSIID - integer

Returns the SCSI ID of the host adapter. Commands sent to this address will return a SCSI bus time-out (SCSI does not allow devices to "talk to themselves"). Read-only.

Inquiry - string

Returns the results of a 36-byte SCSI inquiry command for the device currently specified in the SCSIID property. If no device is found at the current SCSI address, Inquiry raises an error. For example:

ASPI1.SCSIID = 0
On Error Resume Next
Buffer = ASPI1.Inquiry
If Err = 0 then
Debug.Print Mid$(Buffer,9,36-9)
Else
Debug.Print "Timeout"
Endif

SCSIID - integer

Sets the SCSI address to which commands are sent.

SenseBuffer - string

Contains error information after a command fails. When an error occurs, ASPI automatically sends the SCSI Request Sense command. 16 bytes of sense information are returned in this buffer. If additional sense information is needed, another Request Sense can be sent manually.

Commands (methods):

Execute - Sends a command without data

The Execute method sends the command specified in CDB with length of CDBSize to the SCSI peripheral selected. No data transfer occurs with this command, therefore care must be taken to issue only commands that do not require data, such as Test Unit Ready, Load, Re-Zero and so on.

ASPI1.SCSIID = 0
ASPI1.HostAdapter = 0
ASPI1.CDBSize = 6
ASPI1.CDB = Chr$(1) & Chr$(0) & Chr$(0) & Chr$(0) & Chr$(0) & Chr$(0) ' rewind command
On Error Resume Next
ASPI1.Execute

ExecuteIn(BufferSize as Integer) as String - Sends a command with data transfer to the PC.

ExecuteIn is used when a SCSI command will transfer data to the PC. Examples of commands like this are Read, Inquiry, Request Sense etc. Care must be taken to use ExecuteIn only with commands that will transfer data to the system. For example:

ASPI1.SCSIID = 5
ASPI1.HostAdapter = 1
ASPI1.CDBSize = 6
ASPI1.CDB = Chr$(8) & Chr$(0) & Chr$(0) & Chr$(1) & Chr$(1) & Chr$(0) ' read one block
' from block 1
On Error Resume Next
Buffer = ASPI1.Execute(512)

ExecuteOut Buffer as string, BufferSize as long - Sends a command with data transfer from the PC.

ExecuteOut is used to execute SCSI commands with data transfer from the PC such as the Write command. Care must be taken to only use ExecuteOut when a data transfer towards the peripheral will occur. For example:

ASPI1.SCSIID = 4
ASPI1.HostAdapter = 0
ASPI1.CDBSize = 6
ASPI1.CDB = Chr$(&HA) & Chr$(0) & Chr$(0) & Chr$(1) & Chr$(1) & Chr$(0) ' write one block
'to block 1
On Error Resume Next
Buffer = Space$(512)
ASPI1.Execute Buffer, 512

Handling Errors:

The commands Execute, ExecuteIn, ExecuteOut and Inquiry can all fail for a number of reasons. ASPI.OCX generates trapable runtime errors when commands do not execute correctly. The errors are:

ASPI_TIMEOUT (Err = 1000)

The SCSI peripheral at address SCSIID is not present.

ASPI_SENSE (Err = 1001)

A sense error has occurred. Depending on the command and the target, the command may have completed or may not. The sense information returned by the SenseBuffer property should be checked to determine the error that occurred. SCSI interface documentation for the device in question should be consulted for information on any recovery techniques.

ASPI_BUFFER_TOO_BIG (Err = 1002)

During the ExecuteIn or ExecuteOut command, the buffer supplied was larger than the host adapter supports. Check the HostAdapterMaxBuffer property for the maximum length that may be transferred.

ASPI_GENERAL (Err = 1003)

An error other than the above occurred. Please let us know if you encounter this error along with a description of what caused it.