如何通过Linux USB_GADGET将功能报告发送到HOST_PC

发布于 2025-02-03 15:55:01 字数 1460 浏览 3 评论 0 原文

我对设备的这种配置 host_ps < -----> 发射器< ----- touch-screen

目前,我在发射机上创建了一个复合USB小工具设备,该设备最多包含5个HID设备(2MOUSE,2Keyboard,touch屏幕)。主机PC可以列举所有这些,并且一切正常。从发射器端,我正在编写从触摸屏到相应 /dev /hidg设备和主机PC的HID报告数据正确起作用的HID报告数据。 时,问题发生在问题

  1. 当我购买了新的USB_TouchScreen
  2. 。从该触摸屏中提取了报告描述符。
  3. 传递报告描述符和所有相应的数据( dev,no_out_endpoint,protocal,reports_desc,report_length,subclass )to /sys/kernel/kernel/kernel/config/usb_gadget/nhid /functions/hid.usb0/

在所有这些步骤之后,HOST_PC可以正确列举触摸屏,但Tocushes不起作用(我也知道原因)。 HOST_PC打印此消息 HID-MULTITOUCH XXX:YYY:ZZZ.UUU:无法获取功能7 。 一些使用功能报告允许主机具有可配置设备的触摸屏。如果我将触摸屏直接连接到PC,我可以在引擎盖下看到以下内容。在发送触摸屏的输入报告之前,我将描述最后一步。

  1. PC - >触摸屏(getDescriptor(report))
  2. PC - >触摸屏(getReport(功能eport))
  3. 触摸屏 - > pc(输入报告)这已经是隐藏的报告,它发送了触摸屏

问题 hid -multitouch xxx:yyy:zzz.uuu:zzz.uuu:失败了7 是我将报告描述符设置为USB_GADGET的HID设备并列举了host_ps,但我是 not 功能>“功能> feature” 在上面的步骤2中所要求的,

问题:

如果设备是USB_GADGET复合HID设备,则如何将功能报告从设备发送到Host_PC。在发送输入报告(隐藏数据)的通常情况下,我正在将触摸屏的传入数据写入相应的/dev/dev/hidg< n> 设备。

注意:

host_pc是linux(ubuntu,centos,...没有启动),我对窗口不感兴趣。

如果我将触摸屏直接连接到PC,则触摸屏完美。

我不想修改触摸屏的报告描述符,删除功能报告部分并解决此类问题。

ps: 我知道这有点复杂,但要提前。

I have this configuration of the devices HOST_PS <----> Transmitter<---- Touchscreen.

Currently on my transmitter I have created a composite USB gadget device which could contain up to 5 HID devices, (2Mouse, 2Keyboard, Touchscreen). HOST PC could enumerate all of them and everything is working properly. From transmitter side I am writing HID report data comeing from the touchscreen to the corresponding /dev/hidg device and Host PC acts correctly. The problem occurred when

  1. I have bought a new usb_touchscreen.
  2. Extracted the report descriptor from that touchscreen.
  3. Pass the report descriptor and all the corresponding data(dev, no_out_endpoint, protocol, report_desc, report_length, subclass) to /sys/kernel/config/usb_gadget/Nhid/functions/hid.usb0/.

After all this steps the HOST_PC could enumerate the touchscreen properly but the tocushes doesn't work(I also know why).
HOST_PC printing this message hid-multitouch xxx:yyy:zzz.uuu: failed to fetch feature 7.
Some touchscreens using Feature reports for allowing the HOST to have configurable device. If I connect the Touchscreen directly to the PC I can see the following under the hood. I'll describe the final steps before sending the input reports from the touchscreen.

  1. pc -> touchscreen (GetDescriptor(Report))
  2. pc -> touchscreen (GetReport(Feature eport))
  3. touchscreen ->pc (Input Report)This is already HID report that sends the touchscreen

The problem hid-multitouch xxx:yyy:zzz.uuu: failed to fetch feature 7 is though I am setting the report descriptor to USB_GADGET's HID device and HOST_PS enumerates it properly, I am not sending the feature report to the host as it requested in step 2 above.

QUESTION:

How to send feature report from device to HOST_PC, if the device is USB_GADGET composite HID device. In usual for sending the Input report (HID data) I am writing the incoming data from the touchscreen to the corresponding /dev/hidg<N> device.

NOTES:

The HOST_PC is Linux(Ubuntu, CentOS,... doesn't metter) and I ma not interested on Windows.

The Touchscreen works perfectly if I connect it to the PC directly.

I don't want to modify the touchscreen's report descriptor, remove feature report part and solve the problem like that.

PS:
I know this is a little bit complicated but Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

粉红×色少女 2025-02-10 15:55:01

如果某人将来会有这种问题。
这不是Linux USB_GADGET驱动程序中的错误,但老实说,这是未实现的缺失功能。这是指向未完成的地方的链接

如果某人想将功能_Report(s)从设备发送到主机,那么您可能需要在驱动程序中实现它。

这是我对USB_GADGET驱动程序的修改,它将允许将功能报告发送给主机。

PS。我没有足够的时间来创建拉动请求和其他人员将此补丁应用于内核。如果有人对此感兴趣,那么您可以使用我创建的补丁,请抛光代码并申请补丁。

In case someone would have this kind of problem in future.
This is not a bug in Linux USB_GADGET driver but I would honestly say that it is a missing feature which is not implemented. This is a link to the place where the implementation wasn't done
https://github.com/torvalds/linux/blob/master/drivers/usb/gadget/function/f_hid.c#L652.

If someone wants to send feature_report(s) from device to HOST, than you probably will need to implement it in driver.

This is my modification to USB_GADGET driver that will allow to send feature reports to the HOST.
https://github.com/torvalds/linux/compare/master...AydinyanNarek:patch-1

PS. I don't have enough time to create pull request and other staff for applying this patch to the kernel. If someone would be interested on this than you can take this patch that I have created, polish the code and apply for a patch.

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