USB Host Shield - Problems with Code from Felis-Github

Hi,

I recently purchased a USB Host Shield from sparkfun electronics. I have soldered all the connections and now i was trying to check for the code. I tried to complie the code but it gives me a bunch of errors. I will provide the below mentioned examples

I downloaded the library from the below mentioned link

and then i placed it with the name of USBHostShield1 at the below mentioned location in my arduino folder

Desktop\arduino-1.0\libraries\UsbHostShield1

Then i opened up the arduino software and opened the below mentioned sketch

When I compiled it, I got a bunch of errors mostly from the header files

descriptor_parser.cpp:2:17: error: Spi.h: No such file or directory
descriptor_parser.cpp: In function 'void setup()':
descriptor_parser.pde:-1: error: 'class MAX3421E' has no member named 'powerOn'
descriptor_parser.cpp: In function 'byte getdevdescr(byte)':
descriptor_parser.pde:-1: error: invalid conversion from 'char*' to 'uint8_t*'
descriptor_parser.pde:-1: error: initializing argument 4 of 'uint8_t USB::getDevDescr(uint8_t, uint8_t, uint16_t, uint8_t*)'
descriptor_parser.cpp: In function 'byte getstrdescr(byte, byte)':
descriptor_parser.pde:-1: error: invalid conversion from 'char*' to 'uint8_t*'
descriptor_parser.pde:-1: error: initializing argument 6 of 'uint8_t USB::getStrDescr(uint8_t, uint8_t, uint16_t, uint8_t, uint16_t, uint8_t*)'
descriptor_parser.pde:-1: error: invalid conversion from 'char*' to 'uint8_t*'
descriptor_parser.pde:-1: error: initializing argument 6 of 'uint8_t USB::getStrDescr(uint8_t, uint8_t, uint16_t, uint8_t, uint16_t, uint8_t*)'
descriptor_parser.pde:-1: error: invalid conversion from 'char*' to 'uint8_t*'
descriptor_parser.pde:-1: error: initializing argument 6 of 'uint8_t USB::getStrDescr(uint8_t, uint8_t, uint16_t, uint8_t, uint16_t, uint8_t*)'
descriptor_parser.pde:-1: error: invalid conversion from 'char*' to 'uint8_t*'
descriptor_parser.pde:-1: error: initializing argument 6 of 'uint8_t USB::getStrDescr(uint8_t, uint8_t, uint16_t, uint8_t, uint16_t, uint8_t*)'
descriptor_parser.cpp: In function 'byte getconfdescr(byte, byte)':
descriptor_parser.pde:-1: error: invalid conversion from 'char*' to 'uint8_t*'
descriptor_parser.pde:-1: error: initializing argument 5 of 'uint8_t USB::getConfDescr(uint8_t, uint8_t, uint16_t, uint8_t, uint8_t*)'
descriptor_parser.pde:-1: error: invalid conversion from 'char*' to 'uint8_t*'
descriptor_parser.pde:-1: error: initializing argument 5 of 'uint8_t USB::getConfDescr(uint8_t, uint8_t, uint16_t, uint8_t, uint8_t*)'
descriptor_parser.cpp: In function 'void printhid_descr(char*)':
descriptor_parser.pde:-1: error: 'bmREQ_HIDREPORT' was not declared in this scope
descriptor_parser.pde:-1: error: 'HID_DESCRIPTOR_REPORT' was not declared in this scope
descriptor_parser.pde:-1: error: 'USB_NAK_LIMIT' was not declared in this scope
descriptor_parser.cpp: At global scope:
descriptor_parser.pde:-1: error: 'USB_NAK_LIMIT' was not declared in this scope
descriptor_parser.cpp: In function 'byte ctrlXfer(byte, byte, byte, byte, byte, byte, unsigned int, uint16_t, void ()(uint8_t), uint16_t)':
descriptor_parser.pde:-1: error: 'EP_RECORD' was not declared in this scope
descriptor_parser.pde:-1: error: 'ep_rec' was not declared in this scope
descriptor_parser.pde:-1: error: 'class USB' has no member named 'getDevTableEntry'
descriptor_parser.pde:-1: error: invalid conversion from 'char' to 'uint8_t*'

descriptor_parser.pde:-1: error: initializing argument 3 of 'uint8_t* MAX3421e<SS, INTR>::bytesWr(uint8_t, uint8_t, uint8_t*) [with SS = TPin<Portb, 2u>, INTR = TPin<Portb, 1u>]'
descriptor_parser.cpp: In function 'void printProgStr(const char*)':
descriptor_parser.pde:-1: error: 'BYTE' was not declared in this scope
As of Arduino 1.0, the 'BYTE' keyword is no longer supported.
Please use Serial.write() instead.

Then I tried the USB Host Shield 2.0 and I tried to compile a sample example by the name of USB_DESC and I got the below mentioned errors

In file included from \arduino-1.0\libraries\UsbHostShield1\Max3421e.cpp:4:Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:9:22: error: WProgram.h: No such file or directory
IDesktop\arduino-1.0\libraries\UsbHostShield1\Max3421e.cpp:4:
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:16: error: 'byte' does not name a type
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:18: error: 'byte' has not been declared
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:18: error: 'byte' has not been declared
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:19: error: expected ';' before '(' token
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:20: error: 'byte' has not been declared
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:21: error: 'byte' does not name a type
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:22: error: expected ';' before '(' token
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:23: error: 'byte' does not name a type
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:24: error: 'boolean' does not name a type
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:25: error: 'boolean' does not name a type
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:28: error: 'byte' does not name a type
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:29: error: 'byte' does not name a type
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:30: error: 'byte' does not name a type
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h: In static member function 'static void MAX3421E::spi_init()':
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:33: error: 'uint8_t' was not declared in this scope
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:33: error: expected `;' before 'tmp'
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:35: error: 'OUTPUT' was not declared in this scope
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:35: error: 'pinMode' was not declared in this scope
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:37: error: 'INPUT' was not declared in this scope
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:39: error: 'HIGH' was not declared in this scope
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:39: error: 'digitalWrite' was not declared in this scope
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:41: error: 'SPCR' was not declared in this scope
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:42: error: 'SPSR' was not declared in this scope
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:44: error: 'tmp' was not declared in this scope
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:45: error: 'SPDR' was not declared in this scope
Desktop\arduino-1.0\libraries\UsbHostShield1\Max3421e.cpp: At global scope:
Desktop\arduino-1.0\libraries\UsbHostShield1\Max3421e.cpp:7: error: 'byte' does not name a type
\arduino-1.0\libraries\UsbHostShield1\Max3421e.cpp: In constructor 'MAX3421E::MAX3421E()':
\arduino-1.0\libraries\UsbHostShield1\Max3421e.cpp:15: error: 'INPUT' was not declared in this scope
\Desktop\arduino-1.0\libraries\UsbHostShield1\Max3421e.cpp:15: error: 'pinMode' was not declared in this scope
\Desktop\arduino-1.0\libraries\UsbHostShield1\Max3421e.cpp:17: error: 'OUTPUT' was not declared in this scope
Desktop\arduino-1.0\libraries\UsbHostShield1\Max3421e.cpp:18: error: 'HIGH' was not declared in this scope

Please help in guiding me where am i going wrong. The code has been used by a number of people so it must be right ?

Where you are going wrong is you are not reading the "read before posting" sticky post at the top of the page.

My eyes! I can't read yellow on gray, sorry.

Hi,

I recently purchased a USB Host Shield from sparkfun electronics. I have soldered all the connections and now i was trying to check for the code. I tried to complie the code but it gives me a bunch of errors. I will provide the below mentioned examples

I downloaded the library from the below mentioned link

and then i placed it with the name of USBHostShield1 at the below mentioned location in my arduino folder

Desktop\arduino-1.0\libraries\UsbHostShield1

Then i opened up the arduino software and opened the below mentioned sketch

When I compiled it, I got a bunch of errors mostly from the header files

descriptor_parser.cpp:2:17: error: Spi.h: No such file or directory
descriptor_parser.cpp: In function 'void setup()':
descriptor_parser.pde:-1: error: 'class MAX3421E' has no member named 'powerOn'
descriptor_parser.cpp: In function 'byte getdevdescr(byte)':
descriptor_parser.pde:-1: error: invalid conversion from 'char*' to 'uint8_t*'
descriptor_parser.pde:-1: error: initializing argument 4 of 'uint8_t USB::getDevDescr(uint8_t, uint8_t, uint16_t, uint8_t*)'
descriptor_parser.cpp: In function 'byte getstrdescr(byte, byte)':
descriptor_parser.pde:-1: error: invalid conversion from 'char*' to 'uint8_t*'
descriptor_parser.pde:-1: error: initializing argument 6 of 'uint8_t USB::getStrDescr(uint8_t, uint8_t, uint16_t, uint8_t, uint16_t, uint8_t*)'
descriptor_parser.pde:-1: error: invalid conversion from 'char*' to 'uint8_t*'
descriptor_parser.pde:-1: error: initializing argument 6 of 'uint8_t USB::getStrDescr(uint8_t, uint8_t, uint16_t, uint8_t, uint16_t, uint8_t*)'
descriptor_parser.pde:-1: error: invalid conversion from 'char*' to 'uint8_t*'
descriptor_parser.pde:-1: error: initializing argument 6 of 'uint8_t USB::getStrDescr(uint8_t, uint8_t, uint16_t, uint8_t, uint16_t, uint8_t*)'
descriptor_parser.pde:-1: error: invalid conversion from 'char*' to 'uint8_t*'
descriptor_parser.pde:-1: error: initializing argument 6 of 'uint8_t USB::getStrDescr(uint8_t, uint8_t, uint16_t, uint8_t, uint16_t, uint8_t*)'
descriptor_parser.cpp: In function 'byte getconfdescr(byte, byte)':
descriptor_parser.pde:-1: error: invalid conversion from 'char*' to 'uint8_t*'
descriptor_parser.pde:-1: error: initializing argument 5 of 'uint8_t USB::getConfDescr(uint8_t, uint8_t, uint16_t, uint8_t, uint8_t*)'
descriptor_parser.pde:-1: error: invalid conversion from 'char*' to 'uint8_t*'
descriptor_parser.pde:-1: error: initializing argument 5 of 'uint8_t USB::getConfDescr(uint8_t, uint8_t, uint16_t, uint8_t, uint8_t*)'
descriptor_parser.cpp: In function 'void printhid_descr(char*)':
descriptor_parser.pde:-1: error: 'bmREQ_HIDREPORT' was not declared in this scope
descriptor_parser.pde:-1: error: 'HID_DESCRIPTOR_REPORT' was not declared in this scope
descriptor_parser.pde:-1: error: 'USB_NAK_LIMIT' was not declared in this scope
descriptor_parser.cpp: At global scope:
descriptor_parser.pde:-1: error: 'USB_NAK_LIMIT' was not declared in this scope
descriptor_parser.cpp: In function 'byte ctrlXfer(byte, byte, byte, byte, byte, byte, unsigned int, uint16_t, void ()(uint8_t), uint16_t)':
descriptor_parser.pde:-1: error: 'EP_RECORD' was not declared in this scope
descriptor_parser.pde:-1: error: 'ep_rec' was not declared in this scope
descriptor_parser.pde:-1: error: 'class USB' has no member named 'getDevTableEntry'
descriptor_parser.pde:-1: error: invalid conversion from 'char
' to 'uint8_t*'
descriptor_parser.pde:-1: error: initializing argument 3 of 'uint8_t* MAX3421e<SS, INTR>::bytesWr(uint8_t, uint8_t, uint8_t*) [with SS = TPin<Portb, 2u>, INTR = TPin<Portb, 1u>]'
descriptor_parser.cpp: In function 'void printProgStr(const char*)':
descriptor_parser.pde:-1: error: 'BYTE' was not declared in this scope

As of Arduino 1.0, the 'BYTE' keyword is no longer supported.
Please use Serial.write() instead.

Then I tried the USB Host Shield 2.0 and I tried to compile a sample example by the name of USB_DESC and I got the below mentioned errors

In file included from \arduino-1.0\libraries\UsbHostShield1\Max3421e.cpp:4:Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:9:22: error: WProgram.h: No such file or directory
IDesktop\arduino-1.0\libraries\UsbHostShield1\Max3421e.cpp:4:
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:16: error: 'byte' does not name a type
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:18: error: 'byte' has not been declared
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:18: error: 'byte' has not been declared
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:19: error: expected ';' before '(' token
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:20: error: 'byte' has not been declared
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:21: error: 'byte' does not name a type
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:22: error: expected ';' before '(' token
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:23: error: 'byte' does not name a type
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:24: error: 'boolean' does not name a type
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:25: error: 'boolean' does not name a type
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:28: error: 'byte' does not name a type
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:29: error: 'byte' does not name a type
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:30: error: 'byte' does not name a type
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h: In static member function 'static void MAX3421E::spi_init()':
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:33: error: 'uint8_t' was not declared in this scope
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:33: error: expected `;' before 'tmp'
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:35: error: 'OUTPUT' was not declared in this scope
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:35: error: 'pinMode' was not declared in this scope
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:37: error: 'INPUT' was not declared in this scope
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:39: error: 'HIGH' was not declared in this scope
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:39: error: 'digitalWrite' was not declared in this scope
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:41: error: 'SPCR' was not declared in this scope
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:42: error: 'SPSR' was not declared in this scope
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:44: error: 'tmp' was not declared in this scope
Desktop\arduino-1.0\libraries\UsbHostShield1/Max3421e.h:45: error: 'SPDR' was not declared in this scope
Desktop\arduino-1.0\libraries\UsbHostShield1\Max3421e.cpp: At global scope:
Desktop\arduino-1.0\libraries\UsbHostShield1\Max3421e.cpp:7: error: 'byte' does not name a type
\arduino-1.0\libraries\UsbHostShield1\Max3421e.cpp: In constructor 'MAX3421E::MAX3421E()':
\arduino-1.0\libraries\UsbHostShield1\Max3421e.cpp:15: error: 'INPUT' was not declared in this scope
\Desktop\arduino-1.0\libraries\UsbHostShield1\Max3421e.cpp:15: error: 'pinMode' was not declared in this scope
\Desktop\arduino-1.0\libraries\UsbHostShield1\Max3421e.cpp:17: error: 'OUTPUT' was not declared in this scope
Desktop\arduino-1.0\libraries\UsbHostShield1\Max3421e.cpp:18: error: 'HIGH' was not declared in this scope

Please help in guiding me where am i going wrong. The code has been used by a number of people so it must be right ?

Please help in guiding me where am i going wrong. The code has been used by a number of people so it must be right ?

Have you read the sticky!!
It tells you what to do about the missing WProgram.h.

http://arduino.cc/forum/index.php/topic,97455.0.html

Agreed. Actually painful.

Well I have changed the Wprogram.h with Arduino and the spi with SPI.h and the corresponding errors were removed. But the rest of the errors still remain.

Anyone who has worked with this code or anybody who can help me why the errors are coming. Am i missing something ?

The errors are comming from the fact that you hav arduino release 1.0 and the libaries you are using were designed for version 0023.
Thera have been changes in 1.0 that are not reflected in the code.

i downloaded the version 0023 and the code 1 is working fine with it. I actually got the description of the USB device.

The second code is working fine with IDE 1.0.I was putting the two libraries together in one folder and it was causing an issue.

Thanks for the help everybody !