USB CDC 设备驱动程序
我有 CDC 设备。我为他开发驱动程序。 ini 文件的一部分:
[ClassInstall32]
CopyFiles=ClassInstall.CopyFiles
AddReg=ClassInstall.AddReg
[ClassInstall.CopyFiles]
My_USBDriver.dll,,,0x2000
[ClassInstall.AddReg]
HKR,,,,%DEVICEMANAGERCATEGORY%
HKR,,Icon,,"102"
HKR,,Installer32,,"My_USBDriver.dll,MyUSBPortsClassInstaller"
HKR,,NoInstallClass,,1
[DriverInstall]
include=mdmcpq.inf
CopyFiles=DriverInstall.CopyFiles
AddReg=DriverInstall.AddReg
[DriverInstall.CopyFiles]
usbser.sys,,,0x2000
[DriverInstall.AddReg]
HKR,,DevLoader,,*ntkern
HKR,,NTMPDriver,,%DRIVERFILENAME%.sys
[DriverInstall.Services]
AddService=usbser, 0x00000002, DriverService
[DriverService]
DisplayName=%SERVICE%
ServiceType=1
StartType=3
ErrorControl=1
ServiceBinary=%12%\%DRIVERFILENAME%.sys
安装程序函数有代码:
c->ConnectionIndex = iPort;
c->SetupPacket.bmRequest = 0x80;
c->SetupPacket.wValue = (USB_STRING_DESCRIPTOR_TYPE<<8)|descriptorNum;
c->SetupPacket.wLength = n;
Success = DeviceIoControl(
hRoot,
IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION,
c, n,
c, n,
&returnBytes,
NULL);
///Sometime GetLastError == 31 // Device not working
该代码始终在桌面(PC)上正常工作,但有时在安装设备期间仅在笔记本电脑(笔记本)上工作(由系统调用安装函数)。这些机器的操作系统是Windows7。 但是,如果我从我的程序(为 debuggin 创建)调用安装函数,则此代码始终可以正常工作(在笔记本电脑和 PC 上)。 有人对这个问题有想法吗?
I have CDC device. I develop driver for him.
Part of ini file:
[ClassInstall32]
CopyFiles=ClassInstall.CopyFiles
AddReg=ClassInstall.AddReg
[ClassInstall.CopyFiles]
My_USBDriver.dll,,,0x2000
[ClassInstall.AddReg]
HKR,,,,%DEVICEMANAGERCATEGORY%
HKR,,Icon,,"102"
HKR,,Installer32,,"My_USBDriver.dll,MyUSBPortsClassInstaller"
HKR,,NoInstallClass,,1
[DriverInstall]
include=mdmcpq.inf
CopyFiles=DriverInstall.CopyFiles
AddReg=DriverInstall.AddReg
[DriverInstall.CopyFiles]
usbser.sys,,,0x2000
[DriverInstall.AddReg]
HKR,,DevLoader,,*ntkern
HKR,,NTMPDriver,,%DRIVERFILENAME%.sys
[DriverInstall.Services]
AddService=usbser, 0x00000002, DriverService
[DriverService]
DisplayName=%SERVICE%
ServiceType=1
StartType=3
ErrorControl=1
ServiceBinary=%12%\%DRIVERFILENAME%.sys
Installer function have code:
c->ConnectionIndex = iPort;
c->SetupPacket.bmRequest = 0x80;
c->SetupPacket.wValue = (USB_STRING_DESCRIPTOR_TYPE<<8)|descriptorNum;
c->SetupPacket.wLength = n;
Success = DeviceIoControl(
hRoot,
IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION,
c, n,
c, n,
&returnBytes,
NULL);
///Sometime GetLastError == 31 // Device not working
This code normal work on desctop(PC) always, but only sometime work on laptop(notebook) during the installation the device(installation function calling by system). OS of these mashines is Windows7.
BUT if i call installation function from my progrm(created for debuggin) this code always work correctly (on notebook and on pc).
Does anyone have ideas on this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您说的是台式机和笔记本电脑,但我认为计算机的形状并不重要。一个是 32 位操作系统,另一个是 64 位操作系统?我没有看到 64 位 INF 部分。
You said Desktop and Laptop, but I don't think the shape of the computer matters. Is one 32 bit OS and the other is 64 bit? I don't see the 64bit INF section.