Pages: [1] 2   Go Down
Author Topic: help for USB 2.0  (Read 2916 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
[https://github.com/felis/USB_Host_Shield_2.0]

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

Thanks in advance
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: January 11, 2012, 08:09:22 am by dxw00d » Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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???
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Jr. Member
**
Karma: 0
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?? 
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 616
Posts: 49442
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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?

Code:
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.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: January 12, 2012, 02:45:56 am by dxw00d » Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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??
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.

Quote
could u tell me what happened in this sketch

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

Offline Offline
Jr. Member
**
Karma: 0
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 616
Posts: 49442
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

here the code which i m try to sketch...
Code:
#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. 
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 616
Posts: 49442
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
    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"?

Quote
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...
Logged

Pages: [1] 2   Go Up
Jump to: