-1

私はこのようにAndroidでftdiカーネルドライバーをデタッチしようとしました(libftdi-0.xコード):

#ifdef LIBUSB_HAS_GET_DRIVER_NP
// Try to detach ftdi_sio kernel module.
// Returns ENODATA if driver is not loaded.
//
// The return code is kept in a separate variable and only parsed
// if usb_set_configuration() or usb_claim_interface() fails as the
// detach operation might be denied and everything still works fine.
// Likely scenario is a static ftdi_sio kernel module.
fprintf(stderr, "detaching kernel driver... \n");
if (ftdi->module_detach_mode == AUTO_DETACH_SIO_MODULE)
{
    fprintf(stderr, "usb_detach_kernel_driver_np() ...\n");
    if (usb_detach_kernel_driver_np(ftdi->usb_dev, ftdi->interface) != 0 && errno != ENODATA) {
        fprintf(stderr, "failed to detach\n");
        detach_errno = errno;
    }
}
#endif

デバイスの次の呼び出しはすべてエラー = 32 (EPIPE)で失敗するため、実際には切り離されていないと思います。

fprintf(stderr, "ftdi set configuration\n");
    if (dev->descriptor.bNumConfigurations > 0)
    {
        // libusb-win32 on Windows 64 can return a null pointer for a valid device
        if (dev->config) {
            config_val = dev->config[0].bConfigurationValue;
            fprintf(stderr, "trying to set configuration %i\n", config_val);
        }

        if (usb_set_configuration(ftdi->usb_dev, config_val) && errno != EBUSY)
        {
            ftdi_usb_close_internal (ftdi);
            if (detach_errno == EPERM)
            {
                ftdi_error_return(-8, "inappropriate permissions on device!");
            }
            else
            {
                ftdi_error_return(-3, "unable to set usb configuration. Make sure the default FTDI driver is not in use");
            }
        }
    }

ログ:

08-08 11:40:54.197: WARN/System.err(31772): trying to set configuration 1
08-08 11:40:54.197: WARN/System.err(31772): libusb-compat debug: usb_set_configuration: configuration 1
08-08 11:40:54.197: WARN/System.err(31772): libusb: 0.005311 debug [libusb_set_configuration] configuration 1
08-08 11:40:54.197: WARN/System.err(31772): libusb: 0.007173 error [op_set_configuration] failed, error -1 errno 32

上記のコメントによると、実際には切り離されていないようですが、結果は大丈夫です。

少なくともそれを切り離すか、実際の結果を得る方法についてのアイデアはありますか? ウォークアラウンドはありますか?

更新:私は、2つの異なるFTDIデバイスを備えたAndroid 4.0.xとAndroid 4.1でUSBホストをサポートする2つのAndroidデバイスで試しました。

更新: Android の問題を作成しました

4

1 に答える 1

1

少し前に以下のスレッドに出くわしました:

http://developer.intra2net.com/mailarchive/html/libftdi/2011/msg00024.html

デタッチには、適切に機能するためにルート権限が必要な場合があると述べました。では、ルート化されたデバイスで実行した場合、結果は同じでしょうか?

于 2013-08-08T07:25:27.400 に答える