Go Down

Topic: USB receive (Read 1 time) previous topic - next topic

Zenzizenzizenzic

In short, how the heck do you get an output report back on the Leonardo?

My _hidReportDescriptor from HID.cpp:
Code: [Select]

0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
0x09, 0x04,                    // USAGE (Joystick)
0xa1, 0x01,                    // COLLECTION (Application)
0x85, 0x03,    //   REPORT_ID (3)  (This is important when HID_SendReport() is called)
//Buttons:
0x05, 0x09, // USAGE_PAGE (Button)
0x19, 0x01, // USAGE_MINIMUM (Button 1)
0x29, 0x08, // USAGE_MAXIMUM (Button 8)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x75, 0x01, // REPORT_SIZE (1)
0x95, 0x08, // REPORT_COUNT (8)
0x55, 0x00, // UNIT_EXPONENT (0)
0x65, 0x00, // UNIT (None)
0x81, 0x02, // INPUT (Data,Var,Abs)

0x05, 0x08,                    //   USAGE_PAGE (LEDs)
0x09, 0x48,                    //   USAGE (Red)
0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
0x25, 0x01,                    //   LOGICAL_MAXIMUM (1)
0x75, 0x08,                    //   REPORT_SIZE (8)
0x95, 0x01,                    //   REPORT_COUNT (1)
0x91, 0x02,                    //   OUTPUT (Data,Var,Abs)
0xc0                           // END_COLLECTION

The keyboard and mouse descriptors are unchanged, and the rawhid descriptor is commented out

How do I receive on the Leonardo?
I currently have
Code: [Select]

int data = USB_Recv(HID_FIRST_ENDPOINT);
if(data > 0)
{
digitalWrite(13, HIGH);
}
delay(500);


I'm using Florian Leitner's USBHIDDriver here: http://www.florian-leitner.de/index.php/projects/usb-hid-driver-library/

My C#:
Code: [Select]

        USBInterface usbinterface = new USBInterface("vid_2341", "pid_8036");

        public MainWindow()
        {
            InitializeComponent();
            string[] devices = usbinterface.getDeviceList();
            if (usbinterface.Connect())
            {
                if (usbinterface.write(new byte[] { 255 }))
                {
                    Thread.Sleep(2500);
                    usbinterface.write(new byte[] { 0 });
                    Thread.Sleep(2500);
                }
            }
        }
  The write just fails...I thought I had to specify a report # and whatnot to communicate going in either direction and now I'm just confused - there are no examples of this stuff anywhere.  This can't possibly be that difficult! :-P

Go Up