zoukankan      html  css  js  c++  java
  • 重启USB hbg

    /* usbreset -- send a USB port reset to a USB device */

    /*
    * Copyright (c) 2014, JSK Robotics Lab, Inc.
    * Copyright (c) 2016, Orbbec Ltd.
    * All rights reserved.
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions are met:
    *
    * * Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    * * Redistributions in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in the
    * documentation and/or other materials provided with the distribution.
    * * Neither the name of the Willow Garage, Inc. nor the names of its
    * contributors may be used to endorse or promote products derived from
    * this software without specific prior written permission.
    *
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
    * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    * POSSIBILITY OF SUCH DAMAGE.
    *
    * Author: Tim Liu (liuhua@orbbec.com)
    */

    #include <stdio.h>
    #include <unistd.h>
    #include <fcntl.h>
    #include <errno.h>
    #include <sys/ioctl.h>

    #include <linux/usbdevice_fs.h>


    int main(int argc, char **argv)
    {
    const char *filename;
    int fd;
    int rc;

    if (argc != 2) {
    fprintf(stderr, "Usage: usbreset device-filename\n");
    return 1;
    }
    filename = argv[1];

    fd = open(filename, O_WRONLY);
    if (fd < 0) {
    perror("Error opening output file");
    return 1;
    }

    printf("Resetting USB device %s\n", filename);
    rc = ioctl(fd, USBDEVFS_RESET, 0);
    if (rc < 0) {
    perror("Error in ioctl");
    return 1;
    }
    printf("Reset successful\n");

    close(fd);
    return 0;
    }
  • 相关阅读:
    几个生僻字:烎,囧、槑、玊、奣、嘦、勥、巭、嫑、恏、兲、氼、忈、炛
    移动互联网相关应用网站
    Android 布局简要范例
    参与了一次体验不好的产品体验
    ros6.44版本增加了测试出两台ROS之间的速度极限是多少
    mikrotik ros CVE-2019–3924 DUDE AGENT VULNERABILITY
    如何获取阿里云OSS上每个文件夹的大小
    USB-IF协会公布最新PD3.0(PPS)协议认证芯片和产品名单
    第一次有人把小米9快充讲的这么简单明了qc3.0 usb pd
    查看手机拍照性能排名以及电池排名的两个网站
  • 原文地址:https://www.cnblogs.com/rohens-hbg/p/15637262.html
Copyright © 2011-2022 走看看