Hi,

Alan Stern wrote:
On Mon, 20 Dec 2004, Sara Fonseca wrote:
How does the pen drive tells the scsi that it
is empty? ( maybe answering the read command with a sense data  BLANK
CHECK?


If you have to respond with a failure, you can use Sense Key = 0x03 (Medium error) with ASC = 0x12 or 0x13 (Address mark not found for ID or Data field). But if there's data you can read then you should use it.

Interesting that this came up at this time. I'm developing a usb-storage subdriver for a compact flash reader and was just about to ask the same thing, while trying to implement the ability to plug the device in with no media without it going mad.


Alan, I tried what you have said and it's not working as expected, probably something simple that I'm doing wrong. Would you mind taking a quick glance over this?

Although its an extension to the usbat subdriver, the transport function is based almost entirely on the jumpshot_transport code.

Here is the relevant section of the transport function:

if (srb->cmnd[0] == READ_CAPACITY) {
info->ssize = 0x200; // hard coded 512 byte sectors as per ATA spec

// Handle the situation where no media is present
rc = usbat_read_user_io(us, &status);
if (status & USBAT_UIO_UI0) {
US_DEBUGP("usbat02_transport: no media detected\n");
info->sense_key = 0x03;
info->sense_asc = 0x12;
info->sense_ascq = 0x00;
return USB_STOR_TRANSPORT_FAILED;
}

rc = usbat02_id_device(us, info);
US_DEBUGP("usbat02_transport: READ_CAPACITY: %ld sectors, %ld bytes per sector\n",
info->sectors, info->ssize);

// build the reply
((u32 *) ptr)[0] = cpu_to_be32(info->sectors - 1);
((u32 *) ptr)[1] = cpu_to_be32(info->ssize);
usb_stor_set_xfer_buf(ptr, 8, srb);
return USB_STOR_TRANSPORT_GOOD;
}


I get this in the logs:

Dec 21 00:38:39 dsd usb-storage: Command READ_CAPACITY (10 bytes)
Dec 21 00:38:39 dsd usb-storage: 25 00 00 00 00 00 00 00 00 00
Dec 21 00:38:39 dsd usb-storage: usb_stor_ctrl_transfer: rq=82 rqtype=c0 value=0000 index=00 len=1
Dec 21 00:38:39 dsd usb-storage: Status code 0; transferred 1/1
Dec 21 00:38:39 dsd usb-storage: -- transfer complete
Dec 21 00:38:39 dsd usb-storage: usbat02_transport: no media detected
Dec 21 00:38:39 dsd usb-storage: -- transport indicates command failure
Dec 21 00:38:39 dsd usb-storage: Issuing auto-REQUEST_SENSE
Dec 21 00:38:39 dsd usb-storage: usbat02_transport: REQUEST_SENSE.
Dec 21 00:38:39 dsd usb-storage: -- Result from auto-sense is 0
Dec 21 00:38:39 dsd usb-storage: -- code: 0xf0, key: 0x3, ASC: 0x12, ASCQ: 0x0
Dec 21 00:38:39 dsd usb-storage: (Unknown Key): (unknown ASC/ASCQ)
Dec 21 00:38:39 dsd usb-storage: scsi cmd done, result=0x2
Dec 21 00:38:39 dsd usb-storage: *** thread sleeping.


This repeats a few times, then it tries to read the partition table anyway. The card reader isn't too happy about this.

What am I missing?

Thanks,
Daniel


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to