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;
    }
  • 相关阅读:
    MapReduce Demo
    Hadoop Api 基本操作
    Dapper with MVC MiniProfiler
    使用Azure Blob存储
    Tables without a clustered index are not supported in this version of SQL Server. Please create a clustered index and try again.
    Netbeans导入Nutch1.2
    Error 2103 “Unhandled Error in Silverlight Application“ 解决办法
    读取nutch爬取内容方法
    转 nutch网页快照乱码解决方法
    fast neural style transfer图像风格迁移基于tensorflow实现
  • 原文地址:https://www.cnblogs.com/rohens-hbg/p/15637262.html
Copyright © 2011-2022 走看看