c - {USB Composite Device Kernel Module Driver Programming}多接口(interface)管理和 "no endpoint"处理

标签 c linux usb linux-device-driver

我正在尝试将 Pololu 的 mini maestro USB 伺服 Controller 驱动程序移植到 Linux 内核模块中(这是我第一次尝试编写内核模块)。 Pololu 的 Linux 驱动程序实际上使用单声道运行时环境,很多我认为是兼容层并且它是用 C# 编写的(我不知道),因此将它移植到 C 以将其编译到内核模块中这很重要,因为我希望其他程序使用管道与 USB 模块通信。

所以,这是交易,我使用 lsusb -vvv 列出了 Device Characteristics

但是最后一个界面声明:

 Interface Descriptor:
  bInterfaceNumber        4
  bNumEndpoints           0
  bInterfaceClass       255 Vendor Specific Class
  bInterfaceSubClass      4
  bInterfaceProtocol      1
  iInterface              2 Pololu Mini Maestro 18-Channel USB Servo Controller

我想不通的是:

  • 是否有可用于配置设备模式的未列出的控制端点?
  • 我能处理好吗?我该怎么做?

从复合设备本身:

  • 为每个接口(interface)运行一个内核驱动程序实例?
  • 如何捕获接口(interface)并确定如何管理它?
  • 如何处理接口(interface)关联?

最好的问候!

最佳答案

以下是对您问题的一些回答:

Is there a Non-listed Control endpoint that can be used for configuring Device mode? Can I handle it and how I can do it?

控制端点将始终为端点 0,您只需将设置数据包定向到此端点即可向设备传达控制请求。由于每个设备只有一个端点,您需要了解 Polulu 如何为指定的控制请求指定接口(interface),通常作为控制传输的 wIndex 值传入。

From the Composite device itself: A kernel driver instance is ran for each Interface? How can I catch an interface and identify how to manage it? How can I treat Interface Associations?

每个接口(interface)都将自己呈现为一些独特的 USB 接口(interface)。每个人都是独立的,并且会有自己的行为。例如,您可以拥有一个具有 3 个接口(interface)的复合设备:一个用于大容量存储设备的接口(interface)、一个用于 USB 音频设备的接口(interface)和一个供应商特定接口(interface)。其中每一个都会专门为该接口(interface)加载自己的驱动程序实例。前两个通常已经内置到现代操作系统和内核版本中,因为它们是定义的 USB 类。但是特定于供应商的设备可能必须为特定于供应商的驱动程序进行一些 VID/PID 匹配。如果您需要与上面显示的这个特定界面对话,这就是您的情况。

关于c - {USB Composite Device Kernel Module Driver Programming}多接口(interface)管理和 "no endpoint"处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20180566/

相关文章:

c - 释放 String 对象

c - 写入二维数组时出现段错误

linux - 错误 : modifier in $ (. )

java - Usb4java 库,在 Windows 机器上声明接口(interface)时出错

Android Studio - 未检测到 USB 设备

c++ - 如何确定正在使用哪个USB端口?

c - 访问 int (*foo)[3] 的索引 4 时没有警告

objective-c - C 函数调用 Objective-C 函数

linux - 仅从 linux 中的字符串中过滤掉子字符串一次

linux - 使用 autorid 在多个域的 Linux 客户端之间保持一致的 UID 和 GID