I am trying to write an android app to read and write data from android tablet to our embedded device. The tablet and embedded device are connected via usb to serial converter. Is it possible to read data from the embedded device into our android tablet? Any sample code that I can take a look at?
To do this, your application has to: Discover connected USB devices by using an intent filter to be notified when the user connects a USB device or by enumerating USB devices that are already connected. Ask the user for permission to connect to the USB device, if not already obtained.
USB accessory mode allows users to connect USB host hardware specifically designed for Android-powered devices. The accessories must adhere to the Android accessory protocol outlined in the Android Accessory Development Kit documentation.
Try following methods. Go to Settings> Storage> More (three dots menu)> USB computer connection, choose Media device (MTP). For Android 6.0, go to Settings> About phone (> Software info), tap “Build number” 7-10 times. Back to Settings> Developer options, check “Select USB Configuration”, choose MTP.
USB host is the system that connects to multiple USB clients. For example, the PC is a USB host and it can connect to multiple USB clients like mice, keyboards, and mass storage devices.
I suggest using the ported usb-for-android lib, which has the PL2303 driver already implemented: https://code.google.com/r/felixhaedicke-usb-serial-for-android
I've used it successfully.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With