windows usb 驱动 DLL APP 框架
windows-x86 这块 做 host
freertos-stm32-usb-msc 这块 做 device
- 整体框架
python -> pyusb -> pyusb backend -> usb devicepython代码 : https://blog.csdn.net/weixin_42967006/article/details/108755972或全局搜索 python代码pyusb的安装pip install pyusbpyusb backend 包括如下 // 现(2021-7-29 14:15:46) 主要由两个组织提供,仅需安装即可usb 驱动// 安装驱动成功后才能(在设备插入usb时)在设备管理器的通用串行总线控制器中查找到 该设备 usb dll// 和 usb 驱动进行通信
谁能提供 usb dll 和 usb driver
Cypress 公司
Cypress是一个公司 //an Infineon Technologies CompanyEZ-USB是 CyPress 开发的 8051 单片机 的 一个系列名参考 https://www.keil.com/dd/chip/3190.htmThe Cypress EZ-USB (AN21XX) is a High-speed 8051-based USB Device with Two UARTs, Dual DPTRs, 13 Interrupts / 4 Priority Levels, 24 I/O Lines, 3 Timers/Counters, 3.3V Operation, ROMless, 256 Bytes On-chip RAM, and 4K or 8K Bytes XRAM.CyPress 公司 的USB驱动 有两种cyusb.sys 是 新的USB驱动 规范ezusb.sys 是很久以前推出的USB驱动规范cyusb是CyPress 公司新的USB驱动规范文件包括cyusb.sys和cyusb.inf和cyusb.catsys是驱动程序二进制文件inf是驱动程序的配置文件cat是驱动程序的数字证书其中cyusb.inf文件中没有默认指定任何VID&PID,相关数字都以XXXX代替Cypress 给开发者提供了什么接口1.0 时代驱动 : cyusb.sys2.0 时代 // Cypress USBSuite驱动 : cyusb.sysC++ : cyapi.lib // 封装了驱动 C# : cyusb.dll // 封装了驱动 // C# 不能直接调用 cyapi.lib// C++ 能直接调用 cyapi.lib 和 cyusb.dll// 对于C++ 来说, cyapi.lib 提供 静态链接, cyusb.dll 提供动态链接Cypress 提供 dll 吗?提供,名称叫 CyUSB.dllhttps://www.cypress.com/file/121076/downloadEZ-USB FX3 Software Development Kit https://www.cypress.com/documentation/software-and-drivers/ez-usb-fx3-software-development-kitCypress 支持 linux 吗?支持 ,在 https://www.cypress.com/documentation/software-and-drivers/ez-usb-fx3-software-development-kit 中有 SDK "EZ-USB FX3 SDK 1.3.4 for Linux"
libwdi:debug [wdi_create_list] Hardware ID: USB\VID_20B4&PID_0002&REV_0200
libwdi:debug [wdi_create_list] Compatible ID: USB\Class_00&SubClass_06&Prot_50
libwdi:debug [wdi_create_list] Driver version: 1.2.3.14
libwdi:debug [wdi_create_list] CYUSB3 USB device (1): USB\VID_20B4&PID_0002\5&19353383&0&2
libwdi:debug [wdi_create_list] Device description: 'DX1'
zadig 组织
- 第一种方法
WinUSB(libusb) + libusb // libusb 需要额外安装winusb(libusb) 提供 driverlibusb 提供 dll // https://github.com/libusb/libusb/wiki/Windows
- 第二种方法
libusb-win32提供了 driver 和 dll
- 第三种方法
libusbK提供了 driver 和 dll
调试工具
Bus Hound
非官方的基于tk的pywinusb hid调试工具
zadig
选项框 // More informationWinUSB(libusb) // WinUSB (v6.1.7600.16385)// 包括驱动(仅支持NOT HID) // 驱动支持 libusb// 不包括 DLLlibusb-win32 is a Windows only project which provide libusb-0.1 API compatible library for Windows and the associated kernel driver libusb0.sys.libusb-win32 // libusb-win32 (v1.2.6.0)// 包括 驱动(支持HID)和DLLTo use libusb-win32 in your own programs include the supplied header file usb.h, and link against the import library (libraries for GCC, BCC, and MSVC 32bit/64bit are available).To avoid any version conflicts, DO NOT include the DLL libusb0.dll in your application's directory. The DLL is part of the driver and installed automatically to the Windows system directory.libusbK // libusbK (v3.0.7.0)// 包括 驱动(支持HID) 和DLLlibusbK is a complete driver/library solution for vendor class usb device interfaces. If you are a usb developers or usb device manufacturer seeking a driver solution for a new USB widget then libusbK could be for you.libusbK encompasses a 100% WinUSB compatible api/funtion set. All WinUSB power/pipe polices are fully supported by the libusbK driver. In Addition, libusbK has full support for isochronous endpoints and an extensive set of additional modules to simplify development.libusbK is a Windows only project which provides a new set of API for Windows (supporting WinUSB, libusb0.sys and libusbk.sys) and kernel driver libusbK.sys.libusbK (http://libusbk.sourceforge.net/UsbK3/index.html) is the next-generation libusb-win32 kernel driver and associated library. The kernel driver (libusbK.sys) is based on KMDF and it will work with either libusb-win32 API or native libusbK API. The library (libusbK.dll) works with libusb0.sys, libusbK.sys and winusb.sys . It has dual licenses (Modified BSD and GPL).Currently libusbK is under active development. On the other hand, libusb0.sys and libusb-win32 API will still be supported (bug fix mode) even though no new features will be added.NO // WinUSB(Microsoft)WinUSB is a generic driver for USB devices that is included with all versions of Windows since Windows Vista. It includes:A kernel-mode driver (Winusb.sys)A user-mode dynamic link library (Winusb.dll) that exposes WinUSB functions described in winusb.h. You can use these functions to manage USB devices with user-mode software.By default, Winusb.sys is installed in the device's kernel-mode stack as an upper filter driver, and apps communicate with the device's UMDF function driver to issue read, write, or device I/O control requests. In this configuration, Winusb.sys serves as the device stack's Plug and Play and power owner.Alternatively, you can install Winusb.sys as the function driver for a USB device.USB Serial (CDC) // NO...
参考资料
-
什么情况下不需要自己编写USB驱动,Windows自带哪些USB驱动
-
libusb Zadig pyusb
-
【USB】Zadig 工具的使用说明与下载
-
Windows环境下基于Python的PyUSB库开发USB通讯
-
通过libusb实现PC与ZYNQ之间的USB通信
-
windows平台USB驱动接口开发之libusb以及pyUSB安装使用要点
-
python libusb_使用python开发usb的两种方式(windriver与pyusb)
python代码
#运行以下脚本进行测试
#usb.core.find(idVendor= 0x1908, idProduct= 0x0222)中的
#idVendor和idProduct改成上面查询到的VID和PID:import usb.core
import usb.utildev = usb.core.find(idVendor= 0x1908, idProduct= 0x0222)
if dev is None:raise ValueError('Device not found')
print(dev)
# set the active configuration. With no arguments, the first
# configuration will be the active one
dev.set_configuration()# get an endpoint instance
cfg = dev.get_active_configuration()
intf = cfg[(0,0)]ep = usb.util.find_descriptor(intf,# match the first OUT endpointcustom_match = \lambda e: \usb.util.endpoint_direction(e.bEndpointAddress) == \usb.util.ENDPOINT_OUT)
print(ep)
assert ep is not None# write the data
ep.write('test')
————————————————
版权声明:本文为CSDN博主「老孟(MLY)」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_42967006/article/details/108755972