• 重启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;
    }
  • 相关阅读:
    布隆过滤器解决缓存穿透问题
    查询指定距离内的快递柜或者店铺
    各注册中心consul eureka 以及nacos的服务发现原理
    consul注册中心服务注册过程源码分析
    consul注册中心如何自动剔除下线服务
    svn执行reflash/cleanup报错wc.db解决办法
    第二章
    第一章 JVM和Java体系架构
    2、操作系统-中断
    1、操作系统-启动
  • 原文地址:https://www.cnblogs.com/rohens-hbg/p/15637262.html
Copyright © 2020-2023  润新知