6

I'm trying to make a project using the arduino ADK board http://arduino.cc/en/Main/ArduinoBoardADK and a Sony Ericsson Xperia Play running android 2.3.4. For starters all I want to do is blink a led from my android device, using the nice tutorial found here http://allaboutee.com/2011/12/31/arduino-adk-board-blink-an-led-with-your-phone-code-and-explanation/ .I managed to compile the android app but I'm having big difficulties on the arduino sketch, I can't resolve the imports and it won't compile on Windows7. I understand there are some arduino IDE version issues. I tried compiling both on 0022, 0023 and on 1.0. The furthest I could go with the code I was getting these compile errors after editing the AndroidAccessory.h:

D:\arduino-0023\libraries\AndroidAccessory/AndroidAccessory.h:37: error: 'EP_RECORD' does not name a type

D:\arduino-0023\libraries\AndroidAccessory/AndroidAccessory.h:50: error: 'EP_RECORD' has not been declared

D:\arduino-0023\libraries\AndroidAccessory/AndroidAccessory.h:50: error: 'EP_RECORD' has not been declared

D:\arduino-0023\libraries\AndroidAccessory/AndroidAccessory.h:64: error: 'USB_NAK_LIMIT' was not declared in this scope

I think I read the whole documentation and I can't find a solution to my problem. Setting this up is such a pain... I really need to make this work. Thank you in advance! :)

---------------------------------------------------------------------------------------------------------------------------

EDIT1: The solution which worked for me was to compile the sketch on Linux (Ubuntu)

---------------------------------------------------------------------------------------------------------------------------

EDIT2: Once again using the newest USB library from arduino website the code DOESN'T compile. I tried compiling on IDE v22 and v1.0.2 running both Windows 8 and Ubuntu 12.10 with the following errrors:

E:\Development\arduino-1.0.2\libraries\UsbHost/AndroidAccessory.h: In function 'void setup()':

E:\Development\arduino-1.0.2\libraries\UsbHost/AndroidAccessory.h:68: error: 'void AndroidAccessory::powerOn()' is private
sketch_jan10a:16: error: within this context

E:\Development\arduino-1.0.2\libraries\UsbHost/AndroidAccessory.h: In function 'void loop()':

E:\Development\arduino-1.0.2\libraries\UsbHost/AndroidAccessory.h:66: error: 'int AndroidAccessory::read(void*, int, unsigned int)' is private
sketch_jan10a:23: error: within this context
androidu
  • 4,678
  • 6
  • 36
  • 51

7 Answers7

3

The library was written and tested in:

Arduino Alpha 0022

Have you tried adding this to ArduinoAccessory.h?

#if defined(ARDUINO) && ARDUINO >= 100
  #include "Arduino.h"
#else
  #include "WProgram.h"
#endif 

Also I would recommend reading through this as well:

http://developer.android.com/guide/topics/usb/adk.html#installing

It specifically mentions you need the CapSense library as well for the Android shield on an Arduino:

http://www.arduino.cc/playground/Main/CapSense

It also mentions that you need to install avr-libc as well:

sudo apt-get install avr-libc

MAC OS X:

fink install avr-libc avr-gcc avr-binutils avrdude 
gotnull
  • 26,454
  • 22
  • 137
  • 203
  • 1
    yes I did :( this small header edit got me this far but still left me with the errors you see above... – androidu Jan 30 '12 at 09:35
  • 1
    Well I also tried it on version 0022 and I get the same error... I don't understand what I am doing wrong... – androidu Jan 30 '12 at 18:43
  • 1
    @MarciCăşvan See my updated answer for a link to documentation on installing the necessary libraries. – gotnull Feb 06 '12 at 09:15
  • I followed all the steps necessary for the installation, except for the avr-libc because I run the IDE on Windows not on Linux, and on Windows its not needed to install the avr-libc... My problem still remains :( – androidu Feb 06 '12 at 09:35
  • 1
    @MarciCăşvan Are you adding my above code to `ArduinoAccessory.h`? Also try including `#include ` in your sketch as well. – gotnull Feb 06 '12 at 09:50
  • yes yes and yes, I tried all the possible combinations... still the same compiler errors. I'm going crazy – androidu Feb 06 '12 at 10:22
  • 2
    @MarciCăşvan I know it may be a pain. However, I'm having no problems whatsoever on a Mac OS X Lion environment an an Ubuntu 11.10 environment. Could you consider installing one of those operating systems? – gotnull Feb 06 '12 at 10:28
  • In that case either I'm doing something wrong here or one of the libraries is buggy or not the right version for the code to compile.. Also I'm not the only one to have these errors, I read multiple posts on the net with the same errors but couldn't find a solution. I guess I'll keep trying... I don't know.. what arduino IDE version did you try to compile the code on? 0022? – androidu Feb 06 '12 at 10:34
3

EP_RECORD is defined as part of the USB Host Shield 1.0. However, it is being removed in USB Host Shield 2.0 library.

See the announcement here: http://www.circuitsathome.com/mcu/usb-host-shield-library-version-2-0-released

So the error messages you have with EP_RECORD will surface again if you ever upgrade to 2.0. Also check out the adk.h and adk.cpp from version 2.0 on GitHub. The updated DemoKit 2.0 example no longer use the AndroidAccessory.h/.cpp.

Glorithm
  • 361
  • 5
  • 18
1

Place this code where other defines are in Usb.h

#define USB_NAK_LIMIT       32000   //NAK limit for a transfer. 0 means NAKs are not counted 

Place this just after SETUP_PKT's typedef in Usb.h

/* Endpoint information structure               */
/* bToggle of endpoint 0 initialized to 0xff    */
/* during enumeration bToggle is set to 00      */
typedef struct {        
    byte epAddr;        //copy from endpoint descriptor. Bit 7 indicates direction ( ignored for control endpoints )
    byte Attr;          // Endpoint transfer type.
    unsigned int MaxPktSize;    // Maximum packet size.
    byte Interval;      // Polling interval in frames.
    byte sndToggle;     //last toggle value, bitmask for HCTL toggle bits
    byte rcvToggle;     //last toggle value, bitmask for HCTL toggle bits
    /* not sure if both are necessary */
} EP_RECORD;
Orman
  • 34
  • 3
  • Good answer if it solves the problem, though you may want to explain what's wrong and why your solution is required. – Tass Mar 07 '13 at 05:40
  • The definitions are missing from the headers, I don't know why, so I digged into the older code and found them. Right now I'd recommend installing the Macroduino libraries as they ran without any issues. http://practicalmaker.com/projects/macroduino-project-page – Orman Mar 22 '13 at 01:18
1

Sounds to me like you're just missing the USB_Host_Shield/Usb.h header, which defines those constants.

Zenexer
  • 18,788
  • 9
  • 71
  • 77
  • I did import the USB_Host_Shield and USB libraries too...There has to be a library version conflict somewhere... I'll double check – androidu Feb 09 '12 at 13:07
  • 1
    @MarciCăşvan I think that's definitely where your problem lies. Something is preventing that header from being included properly. – Zenexer Feb 09 '12 at 13:55
0

I think if we really know what this EP_Record epRecord[8]; is all about that might help. EP_Record has not been declared in this file. Therefore, it does not have a type. When I gave USB_NAK_LIMIT a type of int that error went away. I have no idea what type to give to EP_Record? The only thing I can think of is that it might be an array epRecord[8]; looks like an array.

While the Android Developer's site is useful it does lack in many ways. One would be some online help for developers. This seems the be the only source for answers to questions and most of them do not really solve the problems.

EdB
  • 16
0
  1. Install ArduinoADK BETA 001 which is the latest ADK available till date.

  2. Unzip it and in the arduino folder you will find libraries and libraries-V2.

  3. If you copy USB host in libraries you will get androidaccessory.h read private error

  4. Copy USB host from libraries V 2 you should be able to compile successfully. I was.

Jan Rüegg
  • 9,587
  • 8
  • 63
  • 105
0

This sounds kind of like a issue I had a while ago. (so I used microbridge not the ADK with a USBDroid) I had to go into 3 libraries, The error message pointed me to them

//(Note:Which were copied into the the general arduino sketch folder not the arduino normal libraries location) That may be your issue?)

I then replace wiring.h with Arduino.h in each.(Note Make a backup of all to save some stuffing around if this is not your issue) Copy then into a folder named the same but with a number before the name that way when you restart the arduino software you will get a error ignore this and compile.

The result was working USBdroid as seen at http://www.youtube.com/watch?v=h7aa_6PNdRI Still a Work in progress but made me happy. I still have a few buggs to work out.

Cheers, Al

Alex
  • 9
  • 1