简体   繁体   English

有什么办法可以在Linux上实时查看USB设备吗?

[英]Is there any way to see on linux the USB devices on realtime?

My question is simple, is there a way to see in a terminal what usb devices do I have connected to my computer in real time? 我的问题很简单,是否可以在终端中查看我已实时将哪些USB设备连接到计算机? I already know lsusb, but it just show me the devices on the moment I ask it, I would like to be able to see if one connects and disconects at some point. 我已经知道lsusb了,但是它只是在我询问设备时向我显示设备,我希望能够看到某个时刻是否已连接并断开连接。

Edit : Thought the answer marked underneath gives a good alternative, in order to debug the program I was working on I found usefull useing the C++ function 编辑 :以为下面标记的答案是一个很好的选择,为了调试我正在研究的程序,我发现使用C ++函数很有用

std::system("lsusb");

This way I could check if I had lost or not the USB device. 这样,我可以检查我是否丢失了USB设备。

Sure there is, you can use the udev device manager for kernel. 当然可以,您可以将udev设备管理器用于内核。

Moreover you can define rules to detect plugged/unplugged devices you are interested eg in your case usb devices. 此外,您可以定义规则来检测您感兴趣的插入/未插入设备,例如您的USB设备。

Here is a tutorial on how to write a udev rule 是有关如何编写udev rule的教程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM