cquwyb
驱动牛犊
驱动牛犊
  • 注册日期2002-05-10
  • 最后登录2010-10-23
  • 粉丝0
  • 关注0
  • 积分160分
  • 威望16点
  • 贡献值0点
  • 好评度16点
  • 原创分0分
  • 专家分0分
阅读:2287回复:9

USB应用程序及其驱动程序的疑问:给分!

楼主#
更多 发布于:2002-11-04 23:35
各位大侠:小弟实在闹不清楚如下问题(或许不是这样的问题)
USB应用程序只能通过ReadFile,WriteFile,DeviceIoCtrol
来与设备交互数据,那问题在于:应用程序是不是不能指定对某个
特定的端口(endpoint),这样一来endpoint的传输方式(中断
,块传输,同步传输)对应用程序不是没有意义了吗?
    另外请详细解释应用程序如何使用CreateFile来找到并
打开驱动程序?
    实在困惑,谢谢大家指点◎J◎

最新喜欢:

BeshyBeshy
HonestTreee
fly_zho
驱动小牛
驱动小牛
  • 注册日期2002-12-03
  • 最后登录2008-02-27
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2002-11-05 09:14
应用程序要调用驱动,首先要用CreateFile打开驱动,CreateFile的第一个参数是文件名,这个文件名可以是在驱动程序中使用内核函数IoCreateDevice注册的,也可以在应用程序中通过一连串Setup函数得到。
CreateFile函数返回一个关于驱动程序的句柄。如果你用DeviceIoControl向usb设备发一个IOCTL_CODE,直接把刚才得到的据柄作为DeviceIoControl的第一个参数即可。
如果要使用管道0、管道1之类进行readfile或writefile传输,则要在刚才得到的句柄后面加上\"//PIPE00\"或“//PIPE01\"之类的东东,具体可参考ddk里的帮助文件。

我是小龙女! 靠!你不信,不信拉倒! 反正我们恐龙家的女儿也不愁嫁...
rayyang2000
管理员
管理员
  • 注册日期2001-03-23
  • 最后登录2012-09-13
  • 粉丝3
  • 关注0
  • 积分1036分
  • 威望925点
  • 贡献值3点
  • 好评度823点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2002-11-05 12:07
传输方式和app本来就没有必然的联系!也不会直接打交道。
天天coding-debugging中----超稀饭memory dump file ======================================================== [b]Windows Device Driver Development and Consulting Service[/b] [color=blue][url]http://www.ybwork.com[/url][/color] ========================================================
cquwyb
驱动牛犊
驱动牛犊
  • 注册日期2002-05-10
  • 最后登录2010-10-23
  • 粉丝0
  • 关注0
  • 积分160分
  • 威望16点
  • 贡献值0点
  • 好评度16点
  • 原创分0分
  • 专家分0分
地板#
发布于:2002-11-05 13:41
传输方式和app本来就没有必然的联系!也不会直接打交道。

斑竹,这个我能理解,但是,那APP是否能够选择和哪一个端口进行
交换呢,如果可以又怎样进行?
    请过来人不吝赐教,谢谢◎!◎
HonestTreee
cquwyb
驱动牛犊
驱动牛犊
  • 注册日期2002-05-10
  • 最后登录2010-10-23
  • 粉丝0
  • 关注0
  • 积分160分
  • 威望16点
  • 贡献值0点
  • 好评度16点
  • 原创分0分
  • 专家分0分
地下室#
发布于:2002-11-05 13:53
 :o请教请教,怎样给分啊,好像同一帖子,只能给一次是吗?
HonestTreee
cquwyb
驱动牛犊
驱动牛犊
  • 注册日期2002-05-10
  • 最后登录2010-10-23
  • 粉丝0
  • 关注0
  • 积分160分
  • 威望16点
  • 贡献值0点
  • 好评度16点
  • 原创分0分
  • 专家分0分
5楼#
发布于:2002-11-05 14:01
 :(我考,给过一次分之后,第一个帖子底下再也没有“给分”和
“改分”的图标!!!!!!!!!!!
HonestTreee
rayyang2000
管理员
管理员
  • 注册日期2001-03-23
  • 最后登录2012-09-13
  • 粉丝3
  • 关注0
  • 积分1036分
  • 威望925点
  • 贡献值3点
  • 好评度823点
  • 原创分0分
  • 专家分0分
6楼#
发布于:2002-11-06 12:24
可以做到,但具体的实现还是在driver里面,根据不同的DeivceIoControl使用不同的pipe而已。
天天coding-debugging中----超稀饭memory dump file ======================================================== [b]Windows Device Driver Development and Consulting Service[/b] [color=blue][url]http://www.ybwork.com[/url][/color] ========================================================
cquwyb
驱动牛犊
驱动牛犊
  • 注册日期2002-05-10
  • 最后登录2010-10-23
  • 粉丝0
  • 关注0
  • 积分160分
  • 威望16点
  • 贡献值0点
  • 好评度16点
  • 原创分0分
  • 专家分0分
7楼#
发布于:2002-11-06 12:29
3x,i got it untill now can i really understand it.i got it from the DDK DOC,so if u get any question,u can almost find
it out in the fucking ddk
u USB Driver
The kernel-mode still image driver for USB buses supports a single control endpoint, along with multiple interrupt, bulk IN, and bulk OUT endpoints. The control and interrupt endpoints are accessible using I/O control codes and DeviceIoControl. The bulk endpoints are accessible using ReadFile and WriteFile.
Before calling DeviceIoControl, ReadFile, or WriteFile, you must call CreateFile to obtain a device handle. For devices that support no more than one of each endpoint type (control, interrupt, bulk IN, bulk OUT), a single call to CreateFile opens transfer pipes to each endpoint.
For devices that support multiple interrupt or bulk endpoints, a single call to CreateFile opens transfer pipes to the highest numbered endpoint of each type. If you want to use a different endpoint, you must do the following:
1. Call DeviceIoControl, specifying an I/O control code of IOCTL_GET_PIPE_CONFIGURATION, to determine a port\'s endpoint index numbers (that is, indices into the returned USBSCAN_PIPE_INFORMATION structure array). Note that these index numbers are not the endpoint numbers described in the Universal Serial Bus Specification.
2. Append a backslash and the endpoint\'s index number to the port name returned by IStiDeviceControl::GetMyDevicePortName when calling CreateFile.
For example, suppose a device (with a port name of \"usbscan0\") has two endpoints of each type (interrupt, bulk IN, bulk OUT), with index numbers as follows:
Index Type Endpoint#
0 Interrupt 0x01
1 Bulk IN 0x82
2 Bulk IN 0x83
3 Bulk OUT 0x04
4 Bulk OUT 0x05
5 Interrupt 0x06

If you call CreateFile with a port name of \"usbscan0\", the function will open transfer pipes to endpoints with index values of 2, 4, and 5, plus the control endpoint.
If you call CreateFile with a port name of \"usbscan0\\1\", the function will open transfer pipes to endpoints with index values of 1, 4, and 5, plus the control endpoint.
For this device, if you want to use interrupt endpoint 0, bulk IN endpoint 1, and bulk OUT endpoint 3, you have to call CreateFile three times, specifying port names of \"usbscan0\\0\", \"usbscan0\\1\", and \"usbscan0\\3\". This will create three device handles. Whenever a subsequent call to DeviceIoControl, ReadFile, or WriteFile is made, the device handle associated with the desired pipe should be specified.
Because only one control endpoint is supported, specifying any I/O control code that uses the control pipe will cause the driver to use the proper endpoint, regardless of which endpoint (if any) was specified to CreateFile.
For descriptions of all I/O control codes, see USB Still Image I/O Contol Codes in STI documentation.
The kernel-mode USB driver does not implement a package or message protocol. Read operations do not require any particular packet alignment, but better performance can be achieved if read requests are aligned to maximum packet size boundaries. The maximum packet size can be obtained using the IOCTL_GET_CHANNEL_ALIGN_RQST I/O control code.
 
HonestTreee
jasmine_wu001
驱动小牛
驱动小牛
  • 注册日期2002-04-26
  • 最后登录2010-09-20
  • 粉丝0
  • 关注0
  • 积分169分
  • 威望107点
  • 贡献值0点
  • 好评度17点
  • 原创分0分
  • 专家分0分
8楼#
发布于:2002-11-11 14:51
能不能用中文的
lgasj
驱动中牛
驱动中牛
  • 注册日期2002-07-12
  • 最后登录2006-01-23
  • 粉丝0
  • 关注0
  • 积分6分
  • 威望1点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
9楼#
发布于:2002-11-12 10:09
是啊!
游客

返回顶部