usb functino write on linux

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
ulao
Rank 4
Rank 4
Posts: 480
Joined: Mon Aug 25, 2008 8:45 pm

usb functino write on linux

Post by ulao » Tue Dec 15, 2015 2:55 am

Linux oes not seem to be replying to my usb function writes? Windows seems to be ok.

I do see this with usbmon
> e.g. status code "-115"
Assuming x86 32, -115 = -EINPROGRESS, that means URB still pending, no results yet

Code: Select all

ffff8800089495c0 3713432687 S Ci:2:007:0 s a1 01 0302 0000 0005 8 <
ffff8800089495c0 3713436685 C Ci:2:007:0 0 5 = 02000201 01
ffff8800089495c0 3713436692 S Ci:2:007:0 s a1 01 0303 0000 0005 8 <
ffff8800089495c0 3713440574 C Ci:2:007:0 0 5 = 030101ff 01
ffff880008948f00 3713441250 S Io:2:007:1 -115:8 2 = 0c04
ffff880008948f00 3713445537 C Io:2:007:1 0:8 2 >
ffff880008948f00 3713445589 S Io:2:007:1 -115:8 2 = 0c04
ffff880008948f00 3713453546 C Io:2:007:1 0:8 2 >
ffff880008948f00 3713453577 S Io:2:007:1 -115:8 2 = 0c01
ffff880008948f00 3713461603 C Io:2:007:1 0:8 2 >


This is my pipe set up.

Code: Select all

char my_usbDescriptorConfiguration[] = {    /* USB configuration descriptor */
     9,          /* sizeof(usbDescriptorConfiguration): length of descriptor in bytes */
    USBDESCR_CONFIG,    /* descriptor type */
    18 + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT + /*7 * USB_CFG_HAVE_INTRIN_ENDPOINT3*/ + 7 + 9, 0,
                /* total length of data returned (including inlined descriptors) */
    1,          /* number of interfaces in this configuration */
    1,          /* index of this configuration */
    0,          /* configuration name string index */
    USB_CFG_IS_SELF_POWERED,  /* attributes */

    USB_CFG_MAX_BUS_POWER/2,            /* max USB current in 2mA units */
/* interface descriptor follows inline: */
    9,          /* sizeof(usbDescrInterface): length of descriptor in bytes */
    USBDESCR_INTERFACE, /* descriptor type */
    0,          /* index of this interface */
    0,          /* alternate setting for this interface */
    1 + USB_CFG_HAVE_INTRIN_ENDPOINT ,//+ USB_CFG_HAVE_INTRIN_ENDPOINT3,   /* endpoints excl 0: number of endpoint descriptors to follow */
    USB_CFG_INTERFACE_CLASS,
    USB_CFG_INTERFACE_SUBCLASS,
    USB_CFG_INTERFACE_PROTOCOL,
    0,          /* string index for interface */

    9,          /* sizeof(usbDescrHID): length of descriptor in bytes */
    USBDESCR_HID,   /* descriptor type: HID */
    0x10, 0x01, /* BCD representation of HID version */
    0x00,       /* target country code */
    0x01,       /* number of HID Report (or other HID class) Descriptor infos to follow */
    0x22,       /* descriptor type: report */
    USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH, 5,  /* total length of report descriptor *///
//#endif


#if USB_CFG_HAVE_INTRIN_ENDPOINT    /* endpoint descriptor for endpoint 1 */
    7,          /* sizeof(usbDescrEndpoint) */
    USBDESCR_ENDPOINT,  /* descriptor type = endpoint */
   0x81,       // bulk IN endpoint number 1
    0x03,       /* attrib: Interrupt endpoint */
    8, 0,       /* maximum packet size */
    0x08, /* in ms*/

//the output.

    7,          // sizeof(usbDescrEndpoint)
    5,  // descriptor type = endpoint
    0x01,      // out endpoint number 2
    0x03,       // attrib: Interrupt endpoint
    8, 0,       // maximum packet size
    0x08, // in ms
#endif   

};


My descriptor set up

Code: Select all

unsigned   usbFunctionDescriptor(struct usbRequest *rq)
{
   if ((rq->bmRequestType & USBRQ_TYPE_MASK) != USBRQ_TYPE_STANDARD)
      return 0;

   if (rq->bRequest == USBRQ_GET_DESCRIPTOR)
   {
      // USB spec 9.4.3, high byte is descriptor type
      switch (rq->wValue.bytes[1])
      {
         case USBDESCR_DEVICE:
            usbMsgPtr = (void*)usbDescrDevice;      
            return getUsbDescrDevice_size();
         case USBDESCR_HID_REPORT:
            usbMsgPtr = (void*)analog_usbHidReportDescriptor;
            return  getAnalogUsbHidReportDescriptor_size();
         case USBDESCR_CONFIG:
            usbMsgPtr = my_usbDescriptorConfiguration;
            return sizeof(my_usbDescriptorConfiguration);
      }
   }

   return 0;
}


Linux reports that is see's both pipes.

Code: Select all

 Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval               8
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval               8

but uchar usbFunctionWrite(uchar *data, uchar len) is never called.

I do have a if(rq->bRequest == USBRQ_HID_SET_REPORT) return USB_NO_MSG; in my usbFunctionSetup but as mentioned windows is working so I know its done mostly correct. Seems its only linux based OS's.

Post Reply