Page 1 of 1
how can i transfer data by usb_control_msg from host to avr
Posted: Fri Nov 30, 2007 7:18 pm
by sidneyren
how can i transfer data by usb_control_msg from host to avr,in the host i use
the function usb_control_msg, i want to send 44bytes, can you give me a example.thank you
Posted: Sat Dec 01, 2007 1:57 pm
by christian
Here's an example:
Code: Select all
char buffer[44];
/* fill buffer with data here... */
nBytes = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE
| USB_ENDPOINT_OUT, MY_REQUEST_ID, 0, 0, buffer, 44, 5000);
if(nBytes < 0)
fprintf(stderr, "USB error: %s\n", usb_strerror());
How can I collect data that is rcvd from Host
Posted: Fri Jul 18, 2008 3:42 pm
by Ajay
I want to xfer some data to avr from Host. I am able to send but how can I collect the same data at avr side. I mean usb_ctrl_request has only request fileds I want the same data in avr. How do it. help greatly appreciated. Thanks in advance
Posted: Fri Jul 18, 2008 3:57 pm
by christian
The example above is for sending data from the host to the AVR, as you requested. On the AVR side, you need to implement usbFunctionWrite(). See the hid-data example which ships with the driver for details.
How can I collect data that is rcvd from Host
Posted: Fri Jul 18, 2008 4:18 pm
by Ajay
Thanks for the immediate response. I am running linux on AVR. all I have to do is get some data from host to target. I am able recieve struct usb_ctrlrequest on target, but i dont know how to collect data that was sent by my usb_control_msg from user space. Can u tell me How to collect data apart reqst type, wvalue, windex. I didnt find any usbFuncwrite in code.. Thanks in advance
Posted: Fri Jul 18, 2008 4:22 pm
by christian
Please download the latest driver and see the hid-data example in the examples directory. Or read the documentation for usbFunctionWrite() in usbdrv.h.