help for USB 2.0

Hi all,
i have mega ADK, so i want work on USB host library can any one tell me how could i start because i my new for this protocol.
here the new library
[GitHub - felis/USB_Host_Shield_2.0: Revision 2.0 of USB Host Library for Arduino.]

and also give me demo code so i could test with my board.

Thanks in advance

There are examples on the github page. Have you tried them? One of them seems to enumerate the usb devices connected, and there are some which read keyboards and mice. That should give you a start.

i tried but lots of confusions .....
so give me simple examples so i can try more easily. as like just sending data via usb and see some application or tool.
or also told me how can i use this library???

It depends on what you want to send data to, and what format the attached device expects it to be in.

just random data or default data like my name and address in any format.

is any application which give me the freedom to see my usb data??

The shield acts as a USB host, like a PC does. You connect USB peripheral devices to it - usually, in the case of the ADK, an Android phone. You can't connect another USB host device to it.

just random data or default data like my name and address in any format.

That you'd like to write to the camera that you have attached to the shield? Get real.

What are you trying to communicate with?

i tried but lots of confusions .....

Well, we can't help with general cluelessness, but if you explain what happened, what you saw, and what you did not understand, THAT we can help with.

ok lets start with few questions

  1. Mega ADK is act like USB host ... so can we try to make act like USB client???
  2. at first i want to start just sending data from my ADK (in any mode like host or client) and see this data on some application or simulate so i can get some clues how this usb works...
  1. No. It's entire purpose in life is to be a usb host. The arduino is already a usb client, so you wouldn't need a shield for that. The arduino generally acts as a virtual serial port, but newer arduinos that use the Atmega8U2/Atmega16U2 as a usb/serial converter can have that chip reprogrammed to act as different usb devices.
  2. You could attach an android based phone/tablet to it, download the android open accessory development kit from google and write a quick android app that would see the data. I believe that there are usb loopback devices that can be attached, that simply send back whatever they receive. Don't forget that most usb devices, other than HIDs like keyboards and mice, will require you to write the equivalent of a driver to communicate with them.

thanks
can we use our MEGA ADK as USB-OTG???

when i dump USBHIDmouse sketch in my ADK kit then output is showing on serial monitor OSC is not start ...... could u tell me what happened in this sketch??

can we use our MEGA ADK as USB-OTG???

USB On-the-go is a way of allowing devices that would normally be clients to act as hosts. The ADK is already a host.

could u tell me what happened in this sketch

Sorry, no. I don't have an ADK.

thanks

could you tell me which way i have to use for learning process... i m trying HID code but that code not with my board even single code so may be i m doing in wrong direction. so guide me how could i use in general term.

i m trying HID code but that code not with my board even single code so may be i m doing in wrong direction.

Clearly, English is not your native language. But, just randomly trying out code is not useful. It's hard to understand why you bought the Mega ADK if you are not trying to interface with an Android device.

If you are, then you need to tell us what that device is, what code you are running, what you expect to see happen, and what actually happens.

here the code which i m try to sketch...

#include <avr/pgmspace.h>
#include <avrpins.h>
#include <max3421e.h>
#include <usbhost.h>
#include <usb_ch9.h>
#include <Usb.h>
#include <usbhub.h>
#include <avr/pgmspace.h>
#include <address.h>
#include <hidboot.h>
#include <printhex.h>
#include <message.h>
#include <hexdump.h>
#include <parsetools.h>

class MouseRptParser : public MouseReportParser
{
protected:
	virtual void OnMouseMove	(MOUSEINFO *mi);
	virtual void OnLeftButtonUp	(MOUSEINFO *mi);
	virtual void OnLeftButtonDown	(MOUSEINFO *mi);
	virtual void OnRightButtonUp	(MOUSEINFO *mi);
	virtual void OnRightButtonDown	(MOUSEINFO *mi);
	virtual void OnMiddleButtonUp	(MOUSEINFO *mi);
	virtual void OnMiddleButtonDown	(MOUSEINFO *mi);
};
void MouseRptParser::OnMouseMove(MOUSEINFO *mi)	
{
    Serial.print("dx=");
    Serial.print(mi->dX, DEC);
    Serial.print(" dy=");
    Serial.println(mi->dY, DEC);
};
void MouseRptParser::OnLeftButtonUp	(MOUSEINFO *mi)	
{
    Serial.println("L Butt Up");
};
void MouseRptParser::OnLeftButtonDown	(MOUSEINFO *mi)
{
    Serial.println("L Butt Dn");
};
void MouseRptParser::OnRightButtonUp	(MOUSEINFO *mi)
{
    Serial.println("R Butt Up");
};
void MouseRptParser::OnRightButtonDown	(MOUSEINFO *mi)
{
    Serial.println("R Butt Dn");
};
void MouseRptParser::OnMiddleButtonUp	(MOUSEINFO *mi)
{
    Serial.println("M Butt Up");
};
void MouseRptParser::OnMiddleButtonDown	(MOUSEINFO *mi)
{
    Serial.println("M Butt Dn");
};

USB     Usb;
USBHub     Hub(&Usb);
HIDBoot<HID_PROTOCOL_MOUSE>    Mouse(&Usb);

uint32_t next_time;

MouseRptParser                               Prs;

void setup()
{
    Serial.begin( 115200 );
    Serial.println("Start");

    if (Usb.Init() == -1)
        Serial.println("OSC did not start.");
      
    delay( 200 );
  
    next_time = millis() + 5000;
  
    Mouse.SetReportParser(0,(HIDReportParser*)&Prs);
}

void loop()
{
  Usb.Task();
}

then two message came into serial terminal

  1. start
  2. OSC did not start.

so what should i have to do to use this code..???
i m trying this thing right now
mouse--->ADK--->serial--->PC

adk connected to PC via serial. and mouse connected to ADK via USB host.

    if (Usb.Init() == -1)
        Serial.println("OSC did not start.");

If the Usb instance's call to Init() failed, why are you printing "OSC did not start"?

and mouse connected to ADK via USB host.

Is the mouse a furry thing with teeth on the end? Or some specific kind of mouse? Perhaps a picture...

That's one of the example sketches from the github link. It does say "OSC did not start".

this is the code provied in USB 2.0 library .......

i am using normal USB mouse whom compatible with PC.
could u tell me how Usb.Init() function will be work......??

ambuj:
thanks

could you tell me which way i have to use for learning process... i m trying HID code but that code not with my board even single code so may be i m doing in wrong direction. so guide me how could i use in general term.

Learning process should focus on all electrical connections and then finding out WHY Usb.Init() failed.
You have the library and documents/sites, some difference between what You Have and What Is Supposed To Work should show with enough You Doing The Looking. You are the only one with your hardware. Don't assume everything is right. When there's a problem check 3 times and check again.

can any one tell me how this library work.....???
any related document any kind of flow of this library...???

any kind of manual how this library works....what is the all function which covers by this library any thing then please give to me

if anyone tell me what is the work of basic function then it will be more use full for me...

Perhaps start here http://www.circuitsathome.com/arduino_usb_host_shield_projects as they wrote the library.

What did you plan to do with it when you purchased it?