Offline
Jr. Member
Karma: 0
Posts: 60
|
 |
« on: January 11, 2012, 08:00:00 am » |
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
Faraday Member
Karma: 19
Posts: 3118
|
 |
« Reply #1 on: January 11, 2012, 08:06:09 am » |
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
Jr. Member
Karma: 0
Posts: 60
|
 |
« Reply #2 on: January 11, 2012, 08:15:36 am » |
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
Faraday Member
Karma: 19
Posts: 3118
|
 |
« Reply #3 on: January 11, 2012, 08:17:31 am » |
It depends on what you want to send data to, and what format the attached device expects it to be in.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 60
|
 |
« Reply #4 on: January 11, 2012, 08:21:27 am » |
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
Faraday Member
Karma: 19
Posts: 3118
|
 |
« Reply #5 on: January 11, 2012, 08:33:30 am » |
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
Offline
Brattain Member
Karma: 311
Posts: 35470
Seattle, WA USA
|
 |
« Reply #6 on: January 11, 2012, 08:35:55 am » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 60
|
 |
« Reply #7 on: January 12, 2012, 12:23:43 am » |
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
Faraday Member
Karma: 19
Posts: 3118
|
 |
« Reply #8 on: January 12, 2012, 02:25:00 am » |
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
Jr. Member
Karma: 0
Posts: 60
|
 |
« Reply #9 on: January 12, 2012, 03:12:47 am » |
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
Faraday Member
Karma: 19
Posts: 3118
|
 |
« Reply #10 on: January 12, 2012, 03:20:28 am » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 60
|
 |
« Reply #11 on: January 12, 2012, 03:27:32 am » |
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
Offline
Brattain Member
Karma: 311
Posts: 35470
Seattle, WA USA
|
 |
« Reply #12 on: January 12, 2012, 05:58:42 am » |
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
Jr. Member
Karma: 0
Posts: 60
|
 |
« Reply #13 on: January 12, 2012, 06:16:35 am » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 311
Posts: 35470
Seattle, WA USA
|
 |
« Reply #14 on: January 12, 2012, 07:01:29 am » |
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...
|
|
|
|
|
Logged
|
|
|
|
|
|