SEND DIAGNOSTIC

25 Mar

SEND DIAGNOSTIC
The SEND DIAGNOSTIC command requests the device to test itself, a logical unit, or both. For SBC devices, support for a default, vendor-specific self test is mandatory. The host requests the default test by setting SELFTEST = 1, SELF-TEST CODE = zero, and PARAMETER LIST LENGTH = zero. On receiving the command, a device begins the self test in the background (without using bus bandwidth). On completion of the test, the device returns a CSW with status information.

While a background test is in progress, on receiving most commands, the device should suspend testing within two seconds and respond to the command. SBC devices don’t need to service FORMAT UNIT or START STOP UNIT commands while self-testing. To terminate testing, a host can issue a SEND DIAGNOSTIC command with SELF-TEST CODE = 100b.

Hosts rarely use this command. Some devices support the command by returning success immediately, without performing a test.

TEST UNIT READY
The host issues a TEST UNIT READY command to find out if a storage device is ready for use. The command has no data-transport phase. If the media isn’t ready, the device updates its sense data and returns a CSW with the bCSWStatus field set to 01h to indicate that the command failed. The host can then request sense data by issuing a REQUEST SENSE command. All SBC devices must support this command.

For devices with removable media, some hosts issue periodic TEST UNIT READY commands to find out if the media is still present. A successful TEST UNIT READY response doesn’t guarantee that the next READ or WRITE command will succeed, however. Instead of periodic TEST UNIT READY commands, a host can just attempt to read or write to the media as needed. If the media has been removed, the READ or WRITE command fails, and a REQUEST SENSE command can obtain the reason.

The MSDTestUnitReadyHandler function resets the sense data in the gblSenseData structure and calls the DetectSDCard function from Chapter 5 to determine if a MultiMediaCard or SD Card is present. If a card isn’t detected, the function sets data in the appropriate fields in the Request- SenseResponse structure. The function also sets the CSWStatus and CSWDataResidue fields in the CSW.

void MSDTestUnitReadyHandler()
{
msd_csw.bCSWStatus=0×0;
ResetSenseData();
if (!DetectSDCard()) {
gblSenseData.SenseKey = S_UNIT_ATTENTION;
gblSenseData.ASC = ASC_MEDIUM_NOT_PRESENT;
gblSenseData.ASCQ = ASCQ_MEDIUM_NOT_PRESENT;
msd_csw.bCSWStatus = 0×01;
}
msd_csw.dCSWDataResidue = 0×00;
return;
}


Random Posts

No comments yet

Leave a Reply

You must be logged in to post a comment.