Help me: How to issue standard SCSI command to USB Mass Storage?

183 views
Skip to first unread message

moon

unread,
Dec 7, 2009, 4:17:21 AM12/7/09
to ata-sc...@lists.apple.com
I need help!

In my application, I wanna to send the standard SCSI Command:(such as:12h Inquiry,  00h Test Unit Ready ...) to the USB Mass Storage, I have read and study the sample codes in the folder /Developer/Examples/IOKit/,  
The AuthoringUnitTestUnixTool example :
IOCreatePlugInInterfaceForService ( service,
kIOMMCDeviceUserClientTypeID,
kIOCFPlugInInterfaceID,
&plugInInterface,
&score );
  ( *plugInInterface )->QueryInterface ( plugInInterface,
CFUUIDGetUUIDBytes ( kIOMMCDeviceInterfaceID ),
  ( LPVOID ) &mmcInterface );
interface = (*mmcInterface)->GetSCSITaskDeviceInterface(mmcInterface);
   Sure, apple supplied a interface named "MMCDeviceInterface" for those MultiMedia Devices. But how about USB Mass Storage? Is there also a interface for USB something like 'USBDeviceInterface' or some others? 
   In my code, I try to use the 'kIOUSBDeviceInterfaceID' replace the 'kIOMMCDeviceInterfaceID', but in method QueryInterface(,,), the third parameter I use the MMCDeviceInterface with no change, this is realy a fault, in the following code when i type the code:
errr = ( *mmcInterface )->TestUnitReady ( interface, &taskStatus, &senseBuffer );
    I got a SIGBUS error, when set a breakpoint at 'errr = ( *mmcInterface )->TestUnitReady ( interface, &taskStatus, &senseBuffer );', the compile said:EXC_BAD_ACCESS. So I know, the MMCDeviceInterface cannot be used for USB.
    BUT what interface can use for USB? When I read the USBNotificationTool sample. I found that, the third parameter for method 'QueryInterface'  is: IOUSBDeviceInterface, so I learn it from the Documentation of XCode, this IOUSBDeviceInterface didnot support GetSCSITaskDeviceInterface(), so I cannot get the SCSITaskDeviceInterface, I cannot use the SCSITaskInterface to send SCSI command to Device.
 
   I need your help, I really appreciate your notice and please give me some sugguestion about this.

Best Regards.
   Z.Y. Zhou

Garth Cummings

unread,
Dec 7, 2009, 2:24:57 PM12/7/09
to moon, ata-sc...@lists.apple.com
Hi Moon,

On Dec 7, 2009, at 1:17 AM, moon wrote:

I need help!

In my application, I wanna to send the standard SCSI Command:(such as:12h Inquiry,  00h Test Unit Ready ...) to the USB Mass Storage, I have read and study the sample codes in the folder /Developer/Examples/IOKit/,  
...

    BUT what interface can use for USB? When I read the USBNotificationTool sample. I found that, the third parameter for method 'QueryInterface'  is: IOUSBDeviceInterface, so I learn it from the Documentation of XCode, this IOUSBDeviceInterface didnot support GetSCSITaskDeviceInterface(), so I cannot get the SCSITaskDeviceInterface, I cannot use the SCSITaskInterface to send SCSI command to Device.

Please see Technical Q&A QA1179 "Sending SCSI or ATA commands to storage devices"

Best regards,
--gc
____________________________________________________________________
Garth Cummings  gcum...@apple.com
Sr. Software Engineer
Apple Developer Technical Support



Joel Reymont

unread,
Dec 7, 2009, 3:07:29 PM12/7/09
to Garth Cummings, moon, ata-sc...@lists.apple.com

On Dec 7, 2009, at 7:24 PM, Garth Cummings wrote:

> Please see Technical Q&A QA1179 "Sending SCSI or ATA commands to storage devices"
> <http://developer.apple.com/mac/library/qa/qa2001/qa1179.html>.

Also, maybe this will help:

http://tinyco.de/2009/02/04/writing-a-mac-osx-usb-device-driver-with-scsi-pass-through.html

I wrote the driver a while ago but it does show how to send SCSI commands to USB storage devices.

---
Mac hacker with a performance bent
http://www.linkedin.com/in/joelreymont

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Ata-scsi-dev mailing list (Ata-sc...@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/ata-scsi-dev/ata-scsi-dev-garchive-72467%40googlegroups.com

This email sent to ata-scsi-dev-...@googlegroups.com

moon

unread,
Dec 7, 2009, 10:27:45 PM12/7/09
to Joel Reymont, ata-sc...@lists.apple.com
Hi, Joel Reymont
Thanks. When I search 'sending SCSI Command to USB in MAC' in
apple's mail list, I read your post. And I know you write a driver
for this. So glad of this. :)
What I want to know is that do I need to implement a driver when I
want to send standard SCSI command to the USB Device?

Best Regards.
--moon

moon

unread,
Dec 7, 2009, 10:27:51 PM12/7/09
to Garth Cummings, ata-sc...@lists.apple.com

On 2009年12月8日, at 上午3:24, Garth Cummings wrote:
Thank you Garth Cummings
I read that article before, one section write:"As was mentioned earlier, you will need to implement your own custom subclass of Apple's logical unit drivers to allow your application to send SCSI or ATA commands to devices not supported by the SCSITask User Client or the SMART device interface." Did the USB Mass Storage Divce not supported by the SCSITask User Client? And I can not use the SCSITaskDeviceInterface to communicate with the USB?
Glad for your help.
Best Regards.
---Moon
Reply all
Reply to author
Forward
0 new messages