Android Question How to restart USB device

rtek1000

Active Member
Licensed User
Longtime User
Hello everyone,

I need to install an application on Android 5.

This application communicates via serial port.

But the serial port only works if I remove the cable from the USB port and plug it back.

If I compile the App with autostart, the App will start, but the serial port will not work.

Does anyone know if you have any way to force the USB device to reboot without disconnecting from USB?

This application uses FT232-based serial port.

This app works well on a Tablet with Android 4.4.

I'm using an intent filter.

I found the command line 'modprobe -r' for Linux, but for Android I did not find it.

And the library is UsbSerial library 2.0
https://www.b4x.com/android/forum/threads/usbserial-library-2-0-supports-more-devices.28176/
 

rtek1000

Active Member
Licensed User
Longtime User
usb-ttl-ft232rl-pinout - Cópia.png
Hello again,

I solved my problem, by hardware, if I turn off the power supply of FT232RL (serial port chip) Android will disconnect from the device.

And after turning on the FT232RL, Android will reconnect and my app will launch properly.

For the timeout of this operation, I will use an Arduino or other microcontroller like PIC12F675.

Thank you.
 
Upvote 0

rtek1000

Active Member
Licensed User
Longtime User
Hello,

I used different gadgets to test. And only Android 4.4 properly open my serial port of the usb device, after the boot.

For example, on a TV-BOX RK3229, I even changed the ROM, with rom 5.1, does not open the USB serial port after the boot,

but with ROM 4.4 the USB serial port is opened properly, after boot, the app open automatically.

With ROM Android version 5, after the boot, it is as if the cable was not connected, I need to remove and plug again to work, then the app is opened.

I'm developing a system that needs serial communication, and only Android 4.4 works correctly.

Do you have a command that does a refresh on the usb port, to simulate unplugging and plugging again?

Thank you.
 
Upvote 0

rtek1000

Active Member
Licensed User
Longtime User
Well, if App can not switch the USB by code, I understand, thank you.

----

I think I've found a bug here, but I think it's on Android 5, because Android 4 works.

I use a motorola lapdock to display the screen by HDMI cable. And your keyboard (and touchpad) over USB.

I tested it for the same device (TV box RK3229) it has 4 USB ports, one of them can work as a device to be connected to the PC (similar to Tablet).

----

With ROM Android 5.1:

For App without "Start At Boot": The Lapdock has blocked the serial cable. (App and its service are not started after initialization).

If I use a USB HUB to lapdock, the serial cable works.If I use a USB HUB for lapdock and the same HUB for the serial cable, the serial cable works as well.

The application service has been activated (after boot), the cable LED indicator blinks, but the activity is not displayed (with USB HUB or not).

For App with "Start at startup" (true): The LED indicator flashes (service activated after startup) and Activity is not yet displayed, and then after a few moments Activity is shown.

If I leave only the serial cable connected to the USB port, without the Lapdock, the cable will work.

----

With Android 4.4:Lapdock did not block the serial cable (Start At Boot: true or false).

After the startup, the App service starts and Activity is displayed normally, the LED indicator flashes normally.

----

Note: For another ROM, with Android 5.1, the service was terminated after returning to Home, but I believe it is an error of this ROM. For other ROMs the service was not terminated.

----

I have a gadget with Android 6, but I still have not been able to activate the USB host, if I can test, I put the result.

----

I have seen that the usb device / host mode configuration option, forces the reboot of this USB port, it's present in the Android 4.4 or Android 5.1 settings (for TV box). Maybe the App of user have some way to access this setting, as it is available for the App Settings.

Thank you.
 

Attachments

  • Screenshot_1970-01-02-00-58-10[1].png
    Screenshot_1970-01-02-00-58-10[1].png
    65.8 KB · Views: 1,015
Upvote 0
Top