Berserker
Berserker

Reputation: 21

Writing raw data to the Android Serial Port (USB)

I need to write some "raw" data to the usb port for a project of mine (no prob if root should be required).

I found a port of libusb for Android and managed to compile it with NDK. I linked the library to an executable of mine (executed as root), but the function "libusb_init" always returns an error (LIBUSB_ERROR_OTHER).

I found that the problem (by now...) is in the file "linux_usbfs.c", more precisely in this function:

static const char *find_usbfs_path(void)
{
    const char *path = "/dev/bus/usb";
    const char *ret = NULL;

    if (check_usb_vfs(path)) {
        ret = path;
    } else {
        path = "/proc/bus/usb";
        if (check_usb_vfs(path))
            ret = path;
    }

    usbi_dbg("found usbfs at %s", ret);
    return ret;
}

/dev/bus/usb obviously doesn't exist on my N1.

Upvotes: 1

Views: 5674

Answers (1)

Karibe
Karibe

Reputation: 155

Why not try pyserial? python seems simpler for me. You need either a kernel with usb host mode or your phone supports serial over a ttyMSM0 natively, which you need to find out. Once you are sure you have a serial port on your phone, look at this link which is meant for huawei ideos U8150, but the pyserial stuff done using python for android is the alternative I am suggesting.

Upvotes: 1

Related Questions