在Linux上读取USB输入流
我正在嵌入式 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(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:
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:
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
查看
/dev/input/by-path
并查找您的usb-0000:00:0f.4-1
。在我的 Ubuntu 盒子上,这是设备的符号链接。Check out
/dev/input/by-path
and look for yourusb-0000:00:0f.4-1
. On my Ubuntu box that's a symbolic link to the device.您尝试过使用 mdev 吗?它是 udev 的轻量级替代品,并且填充 /dev。如果未启用热插拔,您可能需要手动运行它。
要扫描 /sys 并创建设备,请尝试:
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: