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. 资源管理与调度系统-YARN的资源调度器

    资源管理与调度系统-YARN的资源调度器 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 资源调度器是Hadoop YARN中最核心的组件之一,它是ResourceManager中的 ...

  2. Redis锁机制的几种实现方式

    1. redis加锁分类 redis能用的的加锁命令分表是INCR.SETNX.SET 2. 第一种锁命令INCR 这种加锁的思路是, key 不存在,那么 key 的值会先被初始化为 0 ,然后再执 ...

  3. Codeforces D. Color the Fence(贪心)

    题目描述: D. Color the Fence time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

  4. A Beginner’s Guide to Webpack 4 and Module Bundling

    原文: https://www.sitepoint.com/beginners-guide-webpack-module-bundling/ ----------------------------- ...

  5. Java静态代理与动态代理 理解与应用场景

    角色 抽象角色:接口类 实现角色: 实现类 代理角色:代理实现的类,最终使用的对象 静态代理 1. 接口 /** * description * * @author 70KG * @date 2018 ...

  6. Django REST framework认证权限和限制和频率

    认证.权限和限制 身份验证是将传入请求与一组标识凭据(例如请求来自的用户或其签名的令牌)相关联的机制.然后 权限 和 限制 组件决定是否拒绝这个请求. 简单来说就是: 认证确定了你是谁 权限确定你能不 ...

  7. linux学习6 Linux系统组成及初始

    一.linux发行版回顾 1.版本回顾 2.Linux基础 a.CPU架构 32位CPU: X86 64位CPU:X64因为最早的X64位CPU是amd公司生产的所以也叫 amd64(可以兼容X86) ...

  8. .net大文件分块上传断点续传demo

    IE的自带下载功能中没有断点续传功能,要实现断点续传功能,需要用到HTTP协议中鲜为人知的几个响应头和请求头. 一. 两个必要响应头Accept-Ranges.ETag 客户端每次提交下载请求时,服务 ...

  9. 鼠标经过图片会移动(css3过渡,overflow:hidden)

    效果图如下: 代码: <body> <div><img src="jd.jpg"></div> </body> img{ ...

  10. AtCoder Grand Contest 010题解

    传送门 \(A\) 判一下奇数的个数就行了 const int N=1e5+5; int a[N],n,res; int main(){ scanf("%d",&n); f ...