PORTS Forum
Ports and Interfaces => USB => Topic started by: tbol.inq on February 17, 2015, 07:12:55 am
-
Hi there,
I'm trying to create a Command Block Wrapper (CBW) with a Command Descriptor Block (CDB) for the SCSI Command: Inquiry and I don't know how to get the dCBWDataTransferLength value of it.
I'v read in "USB Mass Storage Devices - Designing and Programming Devices and Embedded Hosts":
The dCBWDataTransferLength field indicates how many bytes the host will send or how many bytes the host expects to receive.
and
The response to an INQUIRY command is at least 36 bytes. [...]
Is it enough to initialize with:
struct cbw {
...
uint32_t dCBWDataTransferLength;
...
}cbw_inquiry;
...
cbw_inquiry->dCBWDataTransferLength = 36;
Or better using
#define INQUIRY_RESPONSE_LENGTH 0x00000024
cbw_inquiry->dCBWDataTransferLength = INQUIRY_RESPONSE_LENGTH;
How to initalize?
EDIT:
Just one more Question, I've read (http://"http://www.shakthimaan.com/downloads/usb/usb-msc-0.2.pdf") that the Inquiry Command consists of three transport phases:
- Command Transport
- Data Transport
- Status Transport
I created a URB with a CBW(and a CDB for an Inquiry Command) and submitted it to the out endpoint. Is that the Command Transport Phase?
What I have to do for receiving the Data? Will it be enough to create a CSW (Command Status Wrapper) and listening on the IN endpoint?
-
You can use an explicit value or constant to specify 36 bytes.
Yes, the command is the Command Transport phase.
To read data in the Data Transport phase, send IN token packets to the bulk IN endpoint.
The Status Transport phase follows the Data Transport phase.
-
You can use an explicit value or constant to specify 36 bytes.
Yes, the command is the Command Transport phase.
[...]
The Status Transport phase follows the Data Transport phase.
Thank you, Now I've finished the Command Transport Phase correctly.
[...]
To read data in the Data Transport phase, send IN token packets to the bulk IN endpoint.
[...]
What do you mean when saying "IN token packets"?
Is it right to put a struct of type INQUIRY-DATA Format into a CDB and send it to the bulk IN endpoint or how to grab the Data from the IN-Endpoint?
-
No, to receive data, the host sends IN token packets to the bulk IN endpoint, and in response, the IN endpoint sends data or NAK to the host. The host ACKs any received data.
A host can't send data to an IN endpoint.