在Linux上读取USB输入流

发布于 2024-09-24 01:57:28 字数 419 浏览 5 评论 0原文

我正在嵌入式 Linux 机器上工作并尝试读取 USB 设备输入流,但由于某种原因我的 /dev 目录中没有任何这样的东西。我假设它会像 /dev/ttyUSB01 或 /dev/input/usb 或类似的东西,但它不在那里。 dmesg 返回以下内容,

[ 195.863911] input: GIT GIT USB READER as /class/input/input2
[ 195.864259] generic-usb 0003:1234:5678.0001: input: USB HID v1.00 Keyboard [GIT GIT USB READER] on usb-0000:00:0f.4-1/input0

我已扫描过 /sys/class/input/input2 ,但我不太确定我在寻找什么。也许有人可以指出我正确的方向?

I'm working on an embedded linux machine and trying to read a USB devices input stream, but for some reason I don't have any such thing in my /dev directory. I would assume it would be something like /dev/ttyUSB01 or /dev/input/usb or something similar, but it's not there. dmesg returns the following

[ 195.863911] input: GIT GIT USB READER as /class/input/input2
[ 195.864259] generic-usb 0003:1234:5678.0001: input: USB HID v1.00 Keyboard [GIT GIT USB READER] on usb-0000:00:0f.4-1/input0

I've scanned through /sys/class/input/input2 and I am not really sure what I'm looking for. Maybe someone could point me in the right direction?

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

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

发布评论

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

评论(3

秉烛思 2024-10-01 01:57:28

几天前遇到了同样的问题,我们发现了这个解决方法。

您可以在终端执行以下命令:

cat /proc/bus/input/devices

这将列出您连接的设备,并且您的设备应该在列表中。例如,其中的一项对我来说是这样显示的:

I: Bus=0011 Vendor=0002 Product=000a Version=0000
N: Name="TPPS/2 IBM TrackPoint"
P: Phys=synaptics-pt/serio0/input0
S: Sysfs=/devices/platform/i8042/serio4/serio5/input/input15
U: Uniq=
H: Handlers=mouse1 event15 
B: PROP=0
B: EV=7
B: KEY=70000 0 0 0 0
B: REL=3

在“处理程序”下,您会注意到出现了 event15。在我的例子中,您可以通过引用 /dev/input/event15 来访问数据流。你必须弄清楚你的情况是什么

Had the same problem a few days ago and we discovered this workaround.

You could do the following command at the terminal:

cat /proc/bus/input/devices

This will list your devices connected, and your devices should be on the list. For instance, one item on there appears this way for me:

I: Bus=0011 Vendor=0002 Product=000a Version=0000
N: Name="TPPS/2 IBM TrackPoint"
P: Phys=synaptics-pt/serio0/input0
S: Sysfs=/devices/platform/i8042/serio4/serio5/input/input15
U: Uniq=
H: Handlers=mouse1 event15 
B: PROP=0
B: EV=7
B: KEY=70000 0 0 0 0
B: REL=3

Under Handlers, you'll notice that event15 shows up. You can access the data stream by referencing /dev/input/event15 in my case. You'll have to figure out what it is in your case

昇り龍 2024-10-01 01:57:28

查看 /dev/input/by-path 并查找您的 usb-0000:00:0f.4-1。在我的 Ubuntu 盒子上,这是设备的符号链接。

Check out /dev/input/by-path and look for your usb-0000:00:0f.4-1. On my Ubuntu box that's a symbolic link to the device.

梦幻之岛 2024-10-01 01:57:28

您尝试过使用 mdev 吗?它是 udev 的轻量级替代品,并且填充 /dev。如果未启用热插拔,您可能需要手动运行它。

要扫描 /sys 并创建设备,请尝试:

mdev -s

Have you tried using mdev? It's a lightweight alternative to udev and it populates /dev. If hotplugging is not enabled you might need to run it manually.

To scan /sys and create devices, try:

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