将linux驱动程序转换为android usb api ch341

时间:2014-02-18 15:39:42

标签: android c linux-device-driver

那么,

我试图将ch341 linux驱动程序转换为android usb api。我非常了解这些司机的事情,我可以为下面的那些愚蠢的问题道歉。

CH341, know as usb serial cable hl-340 or even 0x1a86/0x7523, vid/pid.

我找到的驱动程序不是libusb,它是一个内核驱动程序(我认为更难阅读)。 https://github.com/torvalds/linux/blob/master/drivers/usb/serial/ch341.c

是否可以将内核驱动程序转换为Google USB API?

我的意思是,内核驱动程序所需的所有东西都可以完成,或者至少是针对这个特定的驱动程序?

我可以重新编码open,configure,controlIn和out。我不知道它是否有效,但我还没有收到错误消息。

controlIn代码部分:

private int controlIn(int request, int value, int index, byte[] buffer, int bufsize)
{
    int r;

    r = mConnection.controlTransfer(UsbConstants.USB_DIR_IN | 0x40, request, value, index,
            buffer, bufsize, DEFAULT_TIMEOUT);
    return r;
}

下面的代码,调用哪些函数来读写设备? 或者,读取和写入usb设备数据的过程是什么?

static struct usb_serial_driver ch341_device = {
    .driver = {
        .owner  = THIS_MODULE,
        .name   = "ch341-uart",
    },
    .id_table          = id_table,
    .num_ports         = 1,
    .open              = ch341_open,
    .dtr_rts       = ch341_dtr_rts,
    .carrier_raised    = ch341_carrier_raised,
    .close             = ch341_close,
    .set_termios       = ch341_set_termios,
    .break_ctl         = ch341_break_ctl,
    .tiocmget          = ch341_tiocmget,
    .tiocmset          = ch341_tiocmset,
    .tiocmiwait        = usb_serial_generic_tiocmiwait,
    .read_int_callback = ch341_read_int_callback,
    .port_probe        = ch341_port_probe,
    .port_remove       = ch341_port_remove,
    .reset_resume      = ch341_reset_resume,
};

由于

0 个答案:

没有答案