how can i transfer data by usb_control_msg from host to avr

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
sidneyren

how can i transfer data by usb_control_msg from host to avr

Post by sidneyren » Fri Nov 30, 2007 7:18 pm

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

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Sat Dec 01, 2007 1:57 pm

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());

Ajay

How can I collect data that is rcvd from Host

Post by Ajay » Fri Jul 18, 2008 3:42 pm

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

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Fri Jul 18, 2008 3:57 pm

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.

Ajay

How can I collect data that is rcvd from Host

Post by Ajay » Fri Jul 18, 2008 4:18 pm

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

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Fri Jul 18, 2008 4:22 pm

Please download the latest driver and see the hid-data example in the examples directory. Or read the documentation for usbFunctionWrite() in usbdrv.h.

Post Reply