Thursday, May 26, 2011

Connecting usb stuff to the Xoom and debug through wifi!


Today I played a lot with my Motorola Xoom trying to connect different devices.

Games
We started connecting the tablet to the television using the hdmi output. We installed Snes9x EX and played some snes games. The great thing about Snes9x is that it allows to connect Wiimotes. The screen over the right shows a Killer Instinct fight!

Kinect
Today at work they bought a Kinect to test stuff. Android 3.1 + usb host == kinect? I entered the freenode irc chat of the openkinect guys. They give me some excellent support but they doubted that it would work. I will try it out. If I found something useful I will do a blogpost about it.

USB keyboard/mouse
The usb keyboard worked fine but the mouse didn't. The mouse turns on, but the pointer doesn't appear in the screen.

Other Android devices
One of the samples of android-12 is called AdbTest. You can connect an android device and it will read the logs. I connect my nexus one and it worked fine.

Hacking
Cool. Good results so far but I felt disappointed with the mouse, so I decided to try to read what the usb say for that device. When I was going to connect the mouse I discovered that I was missing an extra slot for debugging. I first based my code in the AdbTest and place my logs in the TextView.

After failing trying to get the device name I started reading the documentation, and I found there were Debugging considerations when using the USB Host and Accessory. There are five easy steps you need to do to debug without a usb cable.
  1. Connect the Android-powered device via USB to your computer.
  2. From your SDK platform-tools/ directory, enter adb tcpip 5555 at the command prompt.
  3. Enter adb connect device_ip:5555 You should now be connected to the Android-powered device and can issue the usual adb commands like adb logcat.
  4. To set your device to listen on USB, enter adb usb.
It does work!

I needed to post this before continue coding :)

9 comments:

  1. I try to do the same for about 2 weeks now, but I have a problem with USB host mode on my Xoom 3.1 Build HMJ37. I can use mouse, keyboard and USB storage but i cant find any device (smart card reader, webcam, usb-serial) with the sample code to enumerate devices. Also the MissleLauncher sample is not running,i have compared the vendor- and product-id from the sample code with the missle launcher, they are equal. Which Build and Kernel are you using ? If mouse and keyboard work shouldn't it be possible to find all devices which are connected ?

    Thanks in advance

    Rony

    ReplyDelete
  2. I already connected a Kinect and I can read it. Are you sure your code is using 3.1? I have the same build as you.

    ReplyDelete
  3. How did you manage to read data from Kinect?
    I tried various examples (including OpenNI samples), even simple usb device listing and PowerAMP app from Android market but none of theese worked with my Xoom 3.1 (non-rooted & rooted) When connected the Kinect's light starts blinking but that's all. Also Kinect is connected with adapter to external power source.
    Is there any magic to do to get this usb thing running? (:

    ReplyDelete
  4. Marius:

    You will still need to follow the kinect usb api.

    I started to use https://github.com/OpenKinect/libfreenect with the help of the NDK but I don't have a kinect anymore :(

    ReplyDelete
  5. I'll give it a try. But do you have any publicly available working source code of your projects? [:

    ReplyDelete
  6. Here's the link to the src code.
    http://dl.dropbox.com/u/12706953/hello-jni.zip

    Don't expect much from it :(

    ReplyDelete
  7. Well that was a bit of help, as after modifying your code just a little I managed to list all the devices connected to Xoom :)

    ReplyDelete
  8. @Marius: Cool! Will you try to continue porting the kinect code?

    ReplyDelete
  9. Right now I've been really busy with trying to run OpenNI + Kincet with Android. It seems a bit tricky, as OpenNI is written mostly with c++ and only way to debug is through ndk-gdb (which is slow and unstable :( ) For now I think the problem is with OpenNI module registration but not sure about the drivers for kincet

    ReplyDelete