Can't send data to device

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

Can't send data to device

Post by phil » Wed May 07, 2008 6:00 pm

Hi,

I'm stuck at receiving data using the AVR-USB.
My HID is simulating a gamepad with ATMega16 @ 12Mhz.

My Code:

Code: Select all

int test1=0;
int test2,test3;

uchar usbFunctionSetup(uchar data[8])
{
static uchar replyBuf[2];

 usbMsgPtr = replyBuf;
 test1++;
 test2 = data[0];
 test3 = data[1];

 return 0;
}

[...]

usbPoll();
if(usbInterruptIsReady()){
 reportBuffer[0]=test1;
 reportBuffer[1]=test2;
 reportBuffer[2]=test3;
 usbSetInterrupt(reportBuffer,3);
}


So, you see, a very basic program. I just want to send something to my µC, and the device should return it.
For testing I'm using the SimpleHIDWrite Programm from the HidPage (as LibUsb32 causes some trouble with Windows Vista).

My Problem:
It doesn't matter, what I send to the device. "data" will always be "21 09 00 02 00 00 02 00". So test2==21, test3 ==09. test1 increments everytime I send some bytes.

What am I doing wrong
:?

Thanks for your help!

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

Post by christian » Thu May 08, 2008 10:55 am

In usbFunctionSetup(), you receive the setup command, not the data sent to the device. You must implement usbFunctionWrite() to receive the data part. See the Automator example for how this is done in a HID compliant way.

phil
Posts: 1
Joined: Thu May 08, 2008 7:23 am

Post by phil » Thu May 08, 2008 12:34 pm

:idea:

I got to work right. Thank you so much!

Post Reply