Created
January 5, 2016 19:35
-
-
Save rlonstein/16b947c3ded26038ab49 to your computer and use it in GitHub Desktop.
usb reset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* usbreset.c | |
* | |
* posted 2007-01-08 by Alan Stern <stern@roland.harvard.edu> | |
* to linux-usb-users@lists.sourceforge.net | |
* | |
*/ | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <fcntl.h> | |
#include <errno.h> | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
#include <sys/ioctl.h> | |
#include <linux/usbdevice_fs.h> | |
void main(int argc, char **argv) | |
{ | |
const char *filename; | |
int fd; | |
if (argc < 2) { | |
printf("Give USB device name as parameter\n"); | |
exit(1); | |
} | |
filename = argv[1]; | |
fd = open(filename, O_WRONLY); | |
if (fd == -1) { | |
perror("USB device open failed"); | |
exit(2); | |
} | |
if (ioctl(fd, USBDEVFS_RESET, 0) == -1) { | |
perror("USBDEVFS_RESET device ioctl failed"); | |
exit(3); | |
} | |
close(fd); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment