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. python 内建属性

    在python中创建一个类,它不仅有我们自定义的属性和方法,还有与生俱来的一些属性和方法,我们叫它内建属性. 下面是类常用内建属性列表. 常用专有属性 说明 触发方式 __init__ 构造初始化函数 ...

  2. Python学习日记(四) 集合和元祖

    元祖的特性:是一个只读列表.可以循环.可以切片,修改数据遵循'儿子'不能改但'孙子'可能可以改. iterable:可迭代对象(元祖.列表.字串.集合) 元祖宣告方式: tu = (1,2,3,['a ...

  3. ldconfig 让安装的 php 的rdkafka生效

    原文:https://www.cnblogs.com/schips/p/10183111.html linux中ldconfig的使用介绍   ldconfig是一个动态链接库管理命令,其目的为了让动 ...

  4. Caused by: java.lang.IllegalStateException: Ambiguous mapping found

    Caused by: java.lang.IllegalStateException: Ambiguous mapping found. Cannot map ‘myCockpitMgrControl ...

  5. java中List集合

    List集合是一个元素有序可以重复的集合,集合中每个元素都有其对应的顺序索引.List集合允许使用重复集合,前面博客写到Set不允许有重复集合.List集合可以通过索引来访问指定位置的集合元素. Li ...

  6. 抖音热门BGM爬虫下载

    下午无聊在某网上刷了会儿抖音,发现有些音乐还是挺好听的,可以用来做手机铃声,于是想办法从某网上把歌曲爬下来 附上代码: #!/usr/bin/env python # -*- coding: utf- ...

  7. [python]赶集网二手房爬虫插件【可用任意扩展】

    最近应一个老铁的要求,人家是搞房产的,所以就写了这个二手房的爬虫,因为初版,所以比较简单,有能力的老铁可用进行扩展. import requests import os   from bs4 impo ...

  8. szwyadmin程序漏洞拿shell【方法笔记】

    我们在Google中搜索关键词 关键字:inurl:szwyadmin/login.asp 任意打开一个搜索结果,打开登录界面后在地址栏中输入下面的代码: 代码: javascript:alert(d ...

  9. 为什么在项目中data需要使用return返回数据呢?

    问:为什么在项目中data需要使用return返回数据呢? 答:不使用return包裹的数据会在项目的全局可见,会造成变量污染:使用return包裹后数据中变量只在当前组件中生效,不会影响其他组件.

  10. norm()函数

    n = norm(v) 返回向量 v 的欧几里德范数.此范数也称为 2-范数.向量模或欧几里德长度. 例1: K>> norm([3 4]) ans = 5