vt52-fpga  1.0.0 Initial
vt52-fpga is a serial terminal implemented on a FPGA
usbreset.c
Go to the documentation of this file.
1 /* usbreset -- send a USB port reset to a USB device */
2 
3 #include <stdio.h>
4 #include <unistd.h>
5 #include <fcntl.h>
6 #include <errno.h>
7 #include <sys/ioctl.h>
8 
9 #include <linux/usbdevice_fs.h>
10 
11 
12 int main(int argc, char **argv)
13 {
14  const char *filename;
15  int fd;
16  int rc;
17 
18  if (argc != 2) {
19  fprintf(stderr, "Usage: usbreset device-filename\n");
20  return 1;
21  }
22  filename = argv[1];
23 
24  fd = open(filename, O_WRONLY);
25  if (fd < 0) {
26  perror("Error opening output file");
27  return 1;
28  }
29 
30  printf("Resetting USB device %s\n", filename);
31  rc = ioctl(fd, USBDEVFS_RESET, 0);
32  if (rc < 0) {
33  perror("Error in ioctl");
34  return 1;
35  }
36  printf("Reset successful\n");
37 
38  close(fd);
39  return 0;
40 }
int main(int argc, char **argv)
Definition: usbreset.c:12