I have a USB dongle that uses ethernet over USB to act as a network adapter. On Ubuntu it makes use of the usbnet driver and as soon as I plug the dongle in, the OS recognizes it and gets a new network interface. However, on Android Things it only get recognized as a USB device.
I installed busybox and tried using modprobe to activate g_ether or usbnet but modprobe complains that /lib/modules doesn't exist. Furthermore, I tried using the lsmod command to find out which drivers are active but lsmod doesn't work either because /proc/modules doesn't exist.
I have located the directories /sys/module/usb_f_rndis and /sys/bus/usb/drivers/cdc_ether which leads me to believe that it should be possible to somehow activate the ethernet over USB functionality.
Does anyone have any experience working with ethernet over USB on Android Things? Can anyone guide me through the process of activating the necessary drivers to make this work? Do I have to rebuild the kernel? Thank you for any advice you can offer.
Seems You can't do it now: only when support of USB<->Ethernet devices will be implemented in Android Things or the source code of Android Things becomes available (then You can add Your USB driver support manually as You wrote).
Related
My MacBook computer battery is broken and somehow it has not enough power to power device by usb-c adapter so I cannot connect anything and only have to use android emulator. But I need to debug on real device while testing some ocr sdk that obviously don't want to recognize anything in android emulator virtual scene. I asked other question about that but still I am puzzled by this inability to use WIFI for usb debugging because sdk runs fine on my phone but to debug using fabric and APK deployment is really horrible dev experience and productivity.
Is there some way I can setup WIFI debugging without cable at all... Maybe I need to root my device but again how to do it without cable, it seems impossible either way. I feel in like in dead and but still asking question here. I have computer and phone but cannot connect them for debugging by wifi.
Afraid I don't have an easy wireless solution. The closest thing I could find is that android wearables may have a debug over bluetooth feature, but it's built to route through another (wired) android device.
There is likely a feasible wired solution though- you can hook the device to a powered hub and the hub to the computer.
You could also use an adapter of sorts. They were built for printers and such before everything came with wifi and could get a proper wireless setup going without either side realizing they aren't directly connected over USB (OS still knows that some funky usb drivers are loaded and a separate application may need to run to connect), but again more hardware. A decent Wireless "USB Device Server" seems to run ~$100 while wired ones are cheaper, but not as cheap as a powered usb hub.
If you have another machine, you can use it to enable wireless debugging on your Android phone. See https://developer.android.com/studio/command-line/adb#wireless. Once wireless debugging is enabled, you can connect to it from your Mac without using USB. You still need USB for enabling wireless debugging though, but you can do it from a different machine. This should work on all Android phones, root is not required.
Update [2021]:
Things have developed since this question was asked. WiFi Debugging is a first class option now on newer devices. See https://developer.android.com/studio/run/device.html#wireless for details.
I'd like to power on and off a USB device in Android. I know the method on Linux and it is pretty straightforward (see https://loginroot.com/power-off-and-on-usb-device-in-linux-ubuntu/). Unfortunately the command lsusb -t does not work on Android terminal.
Do you know how to deactivate a specific USB port on Android? Alternatively, getting the USB device tree should be enough, but I don't know how to achieve that either.
Device : Google Nexus 5 (Un-rooted)
Host Machine : Window 7
I want to Access Android Device as a Modem (using COM or Modem Port) and eventually pass AT Commands using HyperTerminal/Teraterm.
So after connecting the device to a Windows Box, The Device gets detected under Device Manager, but doesn't show any COM Port (other than the default COM0).
On right click and update driver, It shows it cannot find drivers.
I have tried the following options, but no luck with any.
Tried this on a rooted Nexus 5, but doesn't expose which /dev/smdX to use. Tried all combinations, didn't work.
Tried the Google USB Drivers from the Google Android's Website. No changes.
From here. I Installed drivers from LG Electronics, No changes in COM Port.
Universal Naked Driver helped me get to ADB Shell interface, but
thats not what I want.
In all of the Above procedure USB Debugging was enabled (Just saying).
I also heard the phone has to put into Modem mode to fire AT Commands.
If so, How do I do that ?
Or Is this a device driver Issue ?
Conclusion:
I want to access the Modem of the Android Device and fire AT Commands to it.
Could you please tell what am I missing ?
Any help on this would be really appreciated.
It's difficult to give an exact answer to this question, because it depends on how the manufacturer has implemented the device drivers. Unfortunately, there is a lot of information that isn't in the public domain.
It is possible, that the manufacturer has implemented some code to convert the device to a modem. Doing this yourself is device-specific, and proprietary. You might be able to get hold of a converter, for example bundled with the manufacturer's dashboard application for the PC, if such a thing exists.
Some devices don't expose the modem port at all. They may be visible as a network adapter, or as an always-connected LAN connection. If the device is visible as a network adapter, then you can access it via Windows Mobile Broadband API, or via MBIM for some newer devices.
To check if the device is visible as a network adapter, and get information about it, open a cmd box and type
netsh mbn show interfaces
Windows Mobile Broadband API doesn't give as many details as a good AT command set, but performs basically the same functions. MBIM is an industry standard interface with similar functionality, available on the Windows 8+ desktop via the Mobile Broadband DeviceServices API, for devices that support it.
If the device shows as an always-on LAN connection, there is probably a proprietary, high level interface for mobile functionality.
Driver behaviour can differ for different operating systems. If you have the chance to try the device on Windows Vista, 7 and 8, you may see different behaviour.
I've been able to find a few posts on StackOverflow about how to control USB devices using an Android phone -- which I understand is impossible (The Android being a USB device and all.)
However, I would be perfectly happy to set up my application to communicate with the other computer (a Linux host) as a USB device. (Like a really expensive mouse...)
Does anybody have information about how to set up an Android app/phone to use the USB connection and exchange data with a host computer. Obviously, it already works at some level -- it's how Eclipse and Android SDK/debugger do what they do, but I'm still looking for some way to do this in an application.
(My current phone, BTW, is a Droid Incredible.)
Thanks,
R.
Basically you'd need to install the USB device driver and the ADB toolsuite from the SDK, either that or reverse engineer their functionality and build it into something else.
Then you enable USB debugging on the phone.
And then you can do something like an adb port forward to allow an application on the pc to connect to a network socket listener on the phone. Note that connections cannot be made in the other direction, but once a connection is made it is bidirectional.
If your version of android supports tethering over USB, you could also leverage that to implicitly create a network between the PC and the phone, at which point you can make connections in either direction. Just make sure nothing starts accidentally pumping lots of data through the phone's mobile network!
(Many android phones actually can experimentally function as USB hosts, but you have to compile new drivers into the kernel, install the new version, and make up a cable to provide USB power to the device as the phone cannot. Also you lose the ADB over USB channel which makes debugging a pain)
What would be the best way to access the USB as a serial port on an Android device (HTC Magic)?
I am thinking about an OBD-II interface. Can I do this on a standard phone or more likely will I need a modified firmware?
According to this post, Matt Porter presented a review of Android at the Embedded Linux Conference Europe. I mention this mostly because of the example used to describe the current state of Android.
"Just one more practical example: You cannot even plug a USB drive to an android system, since /dev/sd* is not an expected device name in their hardcoded hotplug management.
Executive summary: Android is a screwed, hard-coded, non-portable abomination."
I'm sure someone's working on it, but I'm afraid for now you're out of luck unless you're willing to go low-level and edit the OS.
PSFreedom (project to jailbrack Playstation 3) has list of controllers which support usb host mode which then translate to supported Android devices.
My own expirience is that usb host works on HTC Dream/G1 without problems.
For OBD-II I would suggest bluetooth ODB-II dongle which side-stepps problem with usb host adapter.
Depending on the USB chip in your particular phone, it may be possible to rebuild the kernel to support USB Host mode or USB On-The-Go (Host + Gadget modes) instead of the normal USB Gadget mode. I've found some people speculating that it could be possible on the HTC Dream. Assuming you could reconfigure the USB port in Host mode a USB to serial, ODB-II, or CAN should be doable.
From what I can tell Android is Linux of some sort, to have USB device which would apear as serial port, you should write a driver for that device. I don't know much about OBD-II interface but i am guesing they use some sort of USB driver for windows, same is for android, not mentioning the application to handle the driver.
I don't think the current Android devices can act as a USB host only as a USB device when attached to a host. So using the USB port as a serial port is not likely.
Get a hostmode kernel for your device and you can use python for android and the pyserial library to talk to the serial over USB. I did this with Huawei Ideos U8150 (here is the post) for a loopback test.