zoukankan      html  css  js  c++  java
  • USB相关的sysfs文件

    主要来自driver/usb/core/sysfs.c:

    1.bConfigurationValue
    RW,W时调用了usb_set_configuration()实时设置配置。根据USB规范(例如第9.1.1.5节),configuration values必须是非零值,值为零表示设备处于未配置状态。但是,某些设备错误地使用0作为其配
    置值之一。 为帮助管理此类设备,此函数将接受@configuration = -1,表示设备应处于未配置状态。
    未授权的设备(dev->authorized == 0)将仅被设置为未配置模式。
    # echo 0 > bConfigurationValue 此时U盘的设备文件消失
    # echo 1 > bConfigurationValue 此时从新进行类似的U盘插入识别过程

    配置这个文件就可以实现U盘的模拟插拔!!
    /sys/devices/platform/soc/ee080100.usb/usb1/1-1/bConfigurationValue

    配置这个文件就可以实现Android Carlife的模拟插拔!!
    /sys/devices/platform/soc/ee080100.usb/usb1/(1-1/)bConfigurationValue


    2.# cat ./1-1/power/connected_duration
    记录了从USB设备连接上后到现在持续的事件

    3.# cat ./1-1/power/active_duration
    active状态持续的时间

    4.# cat ./1-1/power/level
    RW,设置autosuspend模式是on还是auto

    5.authorized
    RW,同样能起到模拟U盘插拔的效果
    Move the USB device to a very basic state where interfaces are disabled and the device is in fact unconfigured and unusable.

    6.remove
    W,安全的移除设备。
    # echo 1 > remove
    UDEV [4921.100082] remove /devices/platform/soc/ee080100.usb/usb1/1-0:1.0 (usb)
    移除了root-hub,然后USB接口就不识别了,不接恢复,目前只能掉电。移除U盘U盘就需要重新插拔才能识别。

    7.modalias
    R,此文件只有接口有
    usb1/1-1# cat ./1-1:1.0/modalias
    eg:U盘:usb:v0951p1666d0001dc00dsc00dp00ic08isc06ip50in00
    拆分如下:v0951 p1666 d0001 dc00 dsc00 dp00 ic08 isc06 ip50 in00

    static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf)
    {
        struct usb_interface *intf;
        struct usb_device *udev;
        struct usb_host_interface *alt;
    
        intf = to_usb_interface(dev);
        udev = interface_to_usbdev(intf);
        alt = ACCESS_ONCE(intf->cur_altsetting);
    
        return sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02Xin%02X
    ",
                le16_to_cpu(udev->descriptor.idVendor),
                le16_to_cpu(udev->descriptor.idProduct),
                le16_to_cpu(udev->descriptor.bcdDevice),
                udev->descriptor.bDeviceClass,
                udev->descriptor.bDeviceSubClass,
                udev->descriptor.bDeviceProtocol,
                alt->desc.bInterfaceClass,
                alt->desc.bInterfaceSubClass,
                alt->desc.bInterfaceProtocol,
                alt->desc.bInterfaceNumber);
    }
    
    
    New USB device found, idVendor=0951, idProduct=1666
  • 相关阅读:
    微信小程序开发工具 POST net::ERR_PROXY_CONNECTION_FAILED 代理问题
    微信小程序 带参调用后台接口 循环渲染页面 wx.request wx:for
    三下乡感悟心得体会
    Mysql通过Adjacency List(邻接表)存储树形结构
    java的List中使用filter过滤出符合特定条件的元素List
    mybatis报表,动态列与查询参数+行列转换
    mysql行转列转换
    spring配置jackson不返回null值
    mybatis动态列名
    查出最新记录
  • 原文地址:https://www.cnblogs.com/hellokitty2/p/9743516.html
Copyright © 2011-2022 走看看