Reputation: 1218
I want to create Linux app responsible to get/set some usb settings especially settings responsible of followings:
USB ports
USB Host controller and USB driver
USB devices
I followed the linux api document: https://www.kernel.org/doc/html/v4.14/driver-api/usb/usb.html I found that it can be done through ioctl I found a list of ioctl requests, for example USBDEVFS_GETDRIVER.
I found that if I want a first small test it can be like that:
struct usbdevfs_getdriver usbdriver;
int fd = open("device_file_name", O_RDWR);
ioctl(fd, USBDEVFS_GETDRIVER, (struct usbdevfs_getdriver*) &usbdriver);
Is that the right way? What should be the device_file_name in the second line of my code?
Upvotes: 2
Views: 1247
Reputation: 306
The device_file_name: should be the file where usb is mounted. In general it is under /mnt/. You can use command dmesg.
Upvotes: 0
Reputation: 87486
The string device_file_name
should be replaced with the path to a USB device node file. The document you mentioned explains that the path to such a file looks like /dev/bus/usb/BBB/DDD
.
You should check the values returned by both open
and ioctl
to see if the operations succeeded.
Upvotes: 1