Thursday 15 March 2012

Bridged !

Finally, the tablet and the (new) kitchen node are talking. I say new kitchen node, as I've had to switch to a Arduino Mega ADK. It's not connected through ADK (we've already established that the tablet doesn't support that), but through something called Microbridge. Microbridge is a client to Android's ADB debugging interface - it can do a subset of the things the normal ADB client can do, including tunnelling TCP streams.

It didn't all go smoothly, both the Microbridge library and the example sketches need modifications before they work. I'll describe the changes that need to be done, and will link a zip of the modified files.

  • wiring.h The cpp files include wiring.h. This has been superseded by Android.h
  • Mega ADK hardware description:  max3421e.h has a section of definitions protected by #ifdef ADK_REF_BOARD. The contents of this section is correct for the board, but is not compiled. I don't know what the correct symbol for the board is, I just got rid of the #ifdef and corresponding #endif.
  • The board initialization in max3421e.cpp is not working correctly, it should look like this (change in the last line, see also this post):
     SPI.begin();
     pinMode(PIN_MAX_INT, INPUT);
     pinMode(PIN_MAX_GPX, INPUT);
     pinMode(PIN_MAX_SS, OUTPUT);
     DDRJ |= _BV (PJ2);
     
  • The examples use serial -> print, it should be serial -> write. Otherwise you get just random numbers.
  • The WriteFile example doesn't work for me, as the location used for creating the file  (/sdcard/hello) is mounted write-only. Since this example doesn't read back the result, you won't see an error message.
  •  The LogCat demo appears to be working fine (with the print/write change). You may have to unplug/replug your connection to the tablet to make sure it's in debug mode.
  • The Shell example has two problems. First, it checks the status of the connection before writing, but does not allow for ADB_RECEIVING. So it will incorrectly complain about the shell not being open.
  • The other Shell problem is that it does not send a carriage-return symbol at the end of a transmission. So you can type 'ls' into the serial monitor, but that never gets executed.
I still have to try the proper TCP transmission, but things look good so far.

Update: I've put a tar file of the modified microbridge library here. There's still something wrong with the LogCat example: you need to re-plug USB to get the tablet into USB debug mode, but that somehow immediately get cancelled again. If you first run the shell example and then the logcat example, it works. 

No comments:

Post a Comment