USB CDC 设备驱动程序

发布于 2025-01-07 11:00:54 字数 1356 浏览 1 评论 0原文

我有 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

渔村楼浪 2025-01-14 11:00:54

您说的是台式机和笔记本电脑,但我认为计算机的形状并不重要。一个是 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文