Giter Club home page Giter Club logo

usbreset's Introduction

Linux USB Device Reset Application

This application can be used to perform resets on USB devices. This README describes the steps to compile, run, and then automate execution of this application to reset a USB wireless adapter with a greater degree of authority than is available using ifdown wlan0/ifup wlan0.

Credit to Alan Stern for developing this program, as retrieved from: http://marc.info/?l=linux-usb&m=121459435621262&w=2

The following sequence is adequate to execute the program:

  1. Compile the program:

    cc usbreset.c -o usbreset

  2. Set the permissions on the executable:

    chmod +x usbreset

  3. Get the Bus and Device ID of the USB device you want to reset:

    lsusb
    

    which provides output:

    Bus 001 Device 007: ID 050d:945a Belkin Components F7D1101 v1 Basic Wireless Adapter [Realtek RTL8188SU]
    Bus 001 Device 003: ID 0403:6014 Future Technology Devices International, Ltd FT232H Single HS USB-UART/FIFO IC
    Bus 001 Device 002: ID 0bc2:5031 Seagate RSS LLC FreeAgent GoFlex USB 3.0
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 002 Device 002: ID 046d:c06b Logitech, Inc. G700 Wireless Gaming Mouse
    Bus 002 Device 003: ID 413c:2106 Dell Computer Corp. Dell QuietKey Keyboard
    Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    

    where the device of interest is on Bus 001 identified as Device 007 (our USB wireless adapter).

  4. Execute the program with sudo privilege or as the root user, making necessary substitution for with the Bus and Device ids as found by running the lsusb command:

    sudo ./usbreset /dev/bus/usb/Bus/Device

    or in our case

    sudo ./usbreset /dev/bus/usb/001/007

    Now, we can automate execution with the following inline Perl command (assuming that usbreset is in the $PATH):

  5. Execute or embed in a script:

    echo $(lsusb | grep "Wireless Adapter"); wifipath=$( lsusb | grep "Wireless Adapter" | perl -nE "/\D+(\d+)\D+(\d+).+/; print qq(\$1/\$2)") sudo usbreset /dev/bus/usb/$wifipath

    which was inspired by the code provided by knb at http://askubuntu.com/questions/645/how-do-you-reset-a-usb-device-from-the-command-line

usbreset's People

Contributors

jkulesza avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.