udev会生成by-path路径,根据这个就可以判断

dev目录下

[toybrick@localhost dev]$ find | grep platform-fe3c0000
./disk/by-path/platform-fe3c0000.usb-usb-0:1.2:1.0-scsi-0:0:0:0-part1
./disk/by-path/platform-fe3c0000.usb-usb-0:1.2:1.0-scsi-0:0:0:0
./input/by-path/platform-fe3c0000.usb-usb-0:1.1:1.0-event-mouse
./input/by-path/platform-fe3c0000.usb-usb-0:1.3:1.0-event-kbd
[toybrick@localhost dev]$ find | grep platform-fe380000
./serial/by-path/platform-fe380000.usb-usb-0:1.3:1.0-port0
./serial/by-path/platform-fe380000.usb-usb-0:1.2:1.0-port0
./serial/by-path/platform-fe380000.usb-usb-0:1.1:1.0-port0

https://stackoverflow.com/questions/33140787/determine-usb-device-file-path

14

So which device file is used for USB? How can i indentify it?

What you see behind /sys/ is mainly configuration/information about devices. /dev/bus/usb is what you are looking for. I think that the following article can help you

http://www.linuxjournal.com/article/7466?page=0,0

Is quite old, but still it can help you. (In the article they speak about /proc/bus/usb, today we have /dev/bus/usb)

Further more, could you explain to me the number 1-1:1.0? What does it mean?

The generic form is

X-Y.Z:A.B

Each field identify the connection point of your device. The first two field are mandatory:

  • X is the USB bus of your motherboard where is connected the USB system.
  • Y is the port in use on the bus system

So the USB device identified with the string 3-3 is the device connected on the port 3 of the bus 3.

If you connect an USB hub, you are extending the connection capability of a single USB port. The Linux kernel identify this situation by appending the Z field.

  • Z is the port is use on an hub

So, the USB device identified with the string 1-2.5 is the device connected on the port 5 of the hub connected on the port 2 of the bus 1.

USB specification allow you to connect in cascade more then one USB hub, so the Linux kernel continue to append the port in use on the different hubs. So, the USB device identified with the string 1-2.1.1 is the device connected on the port 1 of the hub connected on the port 1 of the hub connected to the port 2 of the bus 1.

A fast way to retrieve these information is to read the kernel messages (if you can).

$ dmesg | grep usb
[... snip ...]
[ 2.047950] usb 4-1: new full-speed USB device number 2 using ohci_hcd
[ 2.202628] usb 4-1: New USB device found, idVendor=046d, idProduct=c318
[ 2.202638] usb 4-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 2.202643] usb 4-1: Product: Logitech Illuminated Keyboard
[ 2.202648] usb 4-1: Manufacturer: Logitech
[... snip ...]

Then, the last two fields of the pattern (after colon) identify an internal section of an USB device :

  • A is the configuration number of the device
  • B is the interface number of a configuration

So, the string 4-1:1.1 means: the interface 1, on configuration 1 that is connected on the port 1 of the bus 4.

You can retrieve these information with the command lsusb.

通过libusb操纵led

https://www.linuxjournal.com/article/7466?page=0,0

根据udev的信息判断设备物理路径的更多相关文章

  1. ASM下裸设备的路径更改是否会影响数据库的执行

    通过asm来存储数据库文件,在linux下能够通过asmlib的方式来管理块设备,也能够直接使用裸设备来建立asm磁盘.在asmlib方式下,磁盘设备启动顺序和名称的改变不会影响到asm的使用.但假设 ...

  2. Android之判断设备网络连接状态,并判断连接方式

    在Android开发过程中,对于一个需要连接网络的Android设备,对设备的网络状态检测是很有必要的!有很多的App都需要连接网络.判断设备是否已经连接网络,并且在连接网络的状态下判断是wifi无线 ...

  3. HTTP 错误 500.19 – Internal Server Error web.config 文件的 system.webServer/httpErrors 节中不允许绝对物理路径“C:\inetpub\custerr”[转]

    给ASP或者ASP.NET等需要配置IIS服务器的过程中,很可能会遇到以下两种错误.尤其是用Win7系统的,配置IIS7.0版本比用XP系统配置IIS5.1版本而言要复杂复杂一些.当同时需要配置ASP ...

  4. Asp.Net 获取物理路径

    一.AppDomain 1.AppDomin获取当前前程序域目录 2.不需要请求上线文实例,例如在Global.ascx中访问等 //网站物理目录 AppDomain.CurrentDomain.Ba ...

  5. asp.net文件压缩,下载,物理路径,相对路径,删除文件

    知识动手实践一次,就可以变成自己的了.不然一直是老师的,书本的. 这几天做了一个小小的项目,需要用到文件下载功能,期初想到只是单个的文件,后面想到如果很多文件怎么办?于是又想到文件压缩.几经波折实践, ...

  6. 百度编辑器UEditor修改成支持物理路径

    一.前言 我虽然工作了2年.有快1年没有做后台的开发了.最近要写个新项目用到富文本编辑器,然后选择用了百度的UEditor.在使用过程中感觉有些不太好.然后就自己手动改一下源码,写得不好请见谅.这只是 ...

  7. PHP判断设备访问来源

    /** * 判断用户请求设备是否是移动设备 * @return bool */ function isMobile() { //如果有HTTP_X_WAP_PROFILE则一定是移动设备 if (is ...

  8. 记一次 IIS 站点配置文件备份和还原,物理路径文件批量备份

    前言 上一篇文章实现了数据库的批量备份和还原,当然部署在服务器中的IIS站点备份也是一个十分繁琐的事,三四个数量不多的还好,像有一些服务器用了许久,承载几十个站点甚至更多,一个一个备份,再一个一个还原 ...

  9. IOS判断设备是否已越狱

    转自:http://www.cnblogs.com/supercheng/archive/2012/12/05/2804166.html - (BOOL)isJailbroken { BOOL jai ...

随机推荐

  1. js 判断数组中是否包含某个元素(转载)

    来源:https://www.cnblogs.com/yunshangwuyou/p/10539090.html 方法一:array.indexOf(item,start):元素在数组中的位置,如果没 ...

  2. python3+django+mysql

    django 连接mysql默认驱动是MySQLdb,MySQLdb没有支持python3的版本,如果使用python3.x版本时,django连接mysql的方法 1.使用pymysql替换MySQ ...

  3. ssh无密码连接

    1. 生成密钥对文件 [root@centos2 ~]# -t 指定加密类型 -b 指定密钥对加密长度 询问1:执行过程中会询问保存位置,一般默认保存在当前用户家目录下的.ssh/目录下 询问2:是否 ...

  4. 用java刷剑指offer(数字在排序数组中出现的次数)

    题目描述 统计一个数字在排序数组中出现的次数. 牛客网链接 java代码 //看见有序就用二分法 public class Solution { public int GetNumberOfK(int ...

  5. unity 之 场景切换进度条显示

    一.UI.建立slider适当更改即可: 二.新增loadScene脚本,用来进行场景切换,将其绑定任意物体上面.博主以放置主相机为例.参数分别为进度条(用来设置value值),显示进度文本text: ...

  6. java基础(10)---stream流

    一.stream的应用场景 for遍历的冗余场景:  stream的写法: 二.获取Stream流的常用方式 三.Stream的map映射方法 更简单的写法: 四.Stream的filter过滤方法 ...

  7. Kotlin伴生对象及其字节码内幕详解

    继续面向对象,开撸就是!! 接口: 我们知道对于JDK8之后接口中除了方法的声明之后还可以有default方法的,而在Kotlin中也类似,下面来看一下在Kotlin接口相关的东东: 很显然就是一个方 ...

  8. CheckList 如何梳理可减少上线的验证时间(总结篇)

    对CheckList的执行发起的思考? (1)功能越来越多,CheckList越补充越多,执行CheckList时间越来越长,如何减少上线的验证时间?(2)减少上线验证的时间外,如何保证质量?上线后少 ...

  9. Dubbo官方文档

    官方文档:http://dubbo.apache.org/en-us/docs/user/quick-start.html

  10. python中的一切皆对象

    python中一切皆对象是这个语言灵活的根本.函数和类也是对象,属于python的一等公民.包括代码包和模块也都是对象.python的面向对象更加彻底. 可以赋值给一个变量可以添加到集合对象中可以作为 ...