• 重启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;
    }
  • 相关阅读:
    PyTorch-->Tensors(张量)
    Pytorch-->PyTorch学习(1)
    信息安全四大顶会!!!
    2020春季数据库-->关系演算安全性的理解
    2020春季数据库-->三级模式和两层映像
    2020寒假->Web编程(1)
    Httprequseter 插件使用
    YII2 客户端验证
    谷歌网页全屏截图
    后台新订单提醒
  • 原文地址:https://www.cnblogs.com/rohens-hbg/p/15637262.html
Copyright © 2020-2023  润新知