阅读:1442回复:5
关于USB字节发送的一个小问题
我知道USB接受的时候是先LSB,MSB ,但是我要是在驱动里面通过 USBD 发送数据的时候该怎么发送呢?
比如:要发送的是 0000 0001(B) 是不是写成 1000 0000 (B), 如果要发送一个LONG 形式的数据 比如: 0X 00 00 00 24 是不是该怎么写啊? 还是在程序里面该怎么写就怎么写,顺序的问题有固件来解决呢? |
|
沙发#
发布于:2005-04-26 07:52
0x01就是0x01,不用写成0x80
0x1234和发送程序有关,先送低字节。 对吗? |
|
板凳#
发布于:2005-04-26 08:14
照你说的,那发送一个LONG 形的,怎么写啊?
0X 00 00 00 24?就这么直接写? 还是写成 0X 24 00 00 00 ?是跟机器有关吗?我的是塞羊的CPU |
|
地板#
发布于:2005-04-26 09:11
这个要看你的处理器是little endian 还是big endian了,楼主查查前面的帖子,好像有的,我记得有人和我说过intel的cpu是little endian,不能肯定,你再查查吧。 ;)
|
|
地下室#
发布于:2005-04-26 10:16
是little endian 的
再问一下:我的U盘支持Bulk_Only的, 可是我在usb里面构造struct _URB_BULK_OR_INTERRUPT_TRANSFER 调用USBD发送 send (INQUERY SCSI)的时候,再调用USBD接受数据的时候,总是没有,status为103,这是怎么回事啊? 谁能描述一下这个发送接受的过程,在驱动的层次上? typedef struct _CBW { unsigned long dCBWSignature; unsigned long dCBWTag; unsigned char dCBWDataTransferLength[4]; unsigned char bmCBWFlags; unsigned char bCBWLUN; unsigned char bCBWLength; unsigned char bCBWCB[16]; }CBW,*PCBW; CBW send; send.dCBWSignature = 0x55534243; send.dCBWTag = 0x2845cb84; send.dCBWDataTransferLength[0] = 0x24; send.dCBWDataTransferLength[1] = 0; send.dCBWDataTransferLength[2] = 0; send.dCBWDataTransferLength[3] = 0; send.bmCBWFlags = 0x80; send.bCBWLUN = 0; send.bCBWLength = 0x06; send.bCBWCB[0] = 0x12; send.bCBWCB[4] = 0x24; |
|
5楼#
发布于:2005-04-26 13:10
\"Little Endian\" means that the low-order byte of the number is stored in memory at the lowest address, and the high-order byte at the highest address. (The little end comes first.) For example, a 4 byte LongInt
Byte3 Byte2 Byte1 Byte0 will be arranged in memory as follows: Base Address+0 Byte0 Base Address+1 Byte1 Base Address+2 Byte2 Base Address+3 Byte3 Intel processors (those used in PC\'s) use \"Little Endian\" byte order. \"Big Endian\" means that the high-order byte of the number is stored in memory at the lowest address, and the low-order byte at the highest address. (The big end comes first.) Our LongInt, would then be stored as: Base Address+0 Byte3 Base Address+1 Byte2 Base Address+2 Byte1 Base Address+3 Byte0 Motorola processors (those used in Mac\'s) use \"Big Endian\" byte order. My msn: jgw2008@hotmail.com |
|
|