如何设置界面备用设置

时间:2017-12-06 10:34:19

标签: linux-kernel usb driver libusb ioctl

我正在尝试使用USBFS IOCTL调用设置接口的备用设置。

以下是我的代码段。

    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);,备用设置就会重置为第一个altset。

根据libusb API Doc,libusb_release_interface会将备用设置重置为第一个备用设置。 请帮助我了解IOCTL要求我遵循的内容。

1 个答案:

答案 0 :(得分:0)

您无法从el.dispatchEvent(new Event('input')); 永久更改it('should display original title', () => { const fixture = TestBed.createComponent(TestComponent); fixture.detectChanges(); const app = fixture.debugElement.componentInstance; const el = fixture.nativeElement.querySelector('input'); el.value = 'something'; el.dispatchEvent(new Event('input')); fixture.detectChanges(); fixture.whenStable().then(() => { expect(app.data).toBe('newvalue'); }); }); 。 可以从alt setting永久更改。

我建议您关闭端点的使用,关闭后内核会将其设置为零带宽接口。