【发布时间】:2018-05-20 04:59:33
【问题描述】:
我正在尝试使用 USBFS IOCTL 调用设置接口的备用设置。
以下是我的代码 sn-p。
int interface = 3;
struct usbdevfs_ioctl command;
struct usbdevfs_getdriver getdrv;
getdrv.interface = interface;
ret = ioctl(fd, USBDEVFS_GETDRIVER, &getdrv);
if (ret < 0)
{
print((" get driver failed %d %d", ret, errno));
}
command.ifno = interface;
command.ioctl_code = USBDEVFS_DISCONNECT;
command.data = NULL;
ret = ioctl(fd, USBDEVFS_IOCTL, &command);
if (ret < 0)
{
print((" detach driver failed %d %d", ret, errno));
}
ret = ioctl(fd, USBDEVFS_CLAIMINTERFACE, &interface);
if (ret < 0)
{
print(("claim interface failed %d %d", ret, errno));
}
si.interface = 3;
si.altsetting = setZerobandwidth;
ret = ioctl(fd, USBDEVFS_SETINTERFACE, &si);
if (ret < 0)
{
print(("set interface ioctl failed %d %d", ret, errno));
}
ret = ioctl(fd, USBDEVFS_RELEASEINTERFACE, &interface);
if (ret < 0)
{
print(("release interface ioctl failed %d %d", ret, errno));
}
command.ifno = interface;
command.ioctl_code = USBDEVFS_CONNECT;
command.data = NULL;
ret = ioctl(fd, USBDEVFS_IOCTL, &command);
if (ret < 0)
{
print(("attach driver ioctl failed %d %d", ret, errno));
}
但是ret = ioctl(fd, USBDEVFS_SETINTERFACE, &si) 工作正常,但是一旦我释放接口ret = ioctl(fd, USBDEVFS_RELEASEINTERFACE, &interface); 备用设置正在重置为第一个替代设置。
根据 libusb API 文档,libusb_release_interface 会将备用设置重置为第一个备用设置。 请帮助我了解我需要遵循的 IOCTL 调用。
【问题讨论】:
标签: linux-kernel usb driver libusb ioctl