Author Topic: winUSB device has issues with friendly name  (Read 12508 times)

lusher00

  • Member
  • ***
  • Posts: 3
winUSB device has issues with friendly name
« on: July 31, 2018, 09:14:51 am »
I have a winusb device that returns the appropriate MS compatibility descriptors at index 0xEE so it doesn't need a driver on Windows 10. This device works everywhere except a small percentage of windows 10 machines. On these windows 10 machines device manager reports error code 10. If I right click, uninstall the device and then do a refresh the device will work until I unplug it. After pulling my hair out for weeks I've discovered that changing the friendly name will fix it. "Redline EX INTL" will not work but "Redline EX International" will work. In fact any combination of 15 letters will fail. I still have not figured out the pattern. Any ideas?

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: winUSB device has issues with friendly name
« Reply #1 on: August 01, 2018, 10:49:27 am »
Very odd. Can you post the code that defines the string (device descriptor with iProduct)?

lusher00

  • Member
  • ***
  • Posts: 3
Re: winUSB device has issues with friendly name
« Reply #2 on: August 01, 2018, 02:34:27 pm »
uint_8 USB_Desc_Get_Descriptor (
     uint_8 controller_ID,   /* [IN] Controller ID */
     uint_8 type,            /* [IN] type of descriptor requested */
     uint_8 str_num,         /* [IN] string index for string descriptor */
     uint_16 index,          /* [IN] string descriptor language Id */
     uint_8_ptr *descriptor, /* [OUT] output descriptor pointer */
     USB_PACKET_SIZE *size   /* [OUT] size of descriptor returned */
)
{
     UNUSED (controller_ID)

    /* string descriptors are handled saperately */
    if (type == USB_STRING_DESCRIPTOR)
    {
       switch (str_num)
      {
         case 0:
            *descriptor = (uint_8_ptr)USB_STR_0;
            *size = USB_STR_0[0];
            break;
         case 1:
            *descriptor = (uint_8_ptr)USB_STR_1;
            *size = USB_STR_1[0];
            break;
         case 2:
            *descriptor = (uint_8_ptr)USB_STR_2;
            *size = USB_STR_2[0];
            break;
         case 3:
            *descriptor = (uint_8_ptr)USB_STR_3;
            *size = USB_STR_3[0];
            break;
         case 0xEE:
            *descriptor = (uint_8_ptr)USB_STR_EE;
            *size = USB_STR_EE[0];
            break;
         default:
            break;
      }
    }
    else if (type < USB_MAX_STD_DESCRIPTORS+1)
    {
        /* set return val for descriptor and size*/
        *descriptor = (uint_8_ptr)g_std_descriptors [type];

        /* if there is no descriptor then return error */
        if(*descriptor == NULL)
        {
            return USBERR_INVALID_REQ_TYPE;
        }

        *size = g_std_desc_size[type];
    }
    else /* invalid descriptor */
    {
        return USBERR_INVALID_REQ_TYPE;
    }

    return USB_OK;
}

uint_8_ptr const g_string_descriptors[USB_MAX_STRING_DESCRIPTORS+1] =
{
   (uint_8_ptr const)USB_STR_0,
   (uint_8_ptr const)USB_STR_1,
   (uint_8_ptr const)USB_STR_2,
   (uint_8_ptr const)USB_STR_3,
   (uint_8_ptr const)USB_STR_n
};

uint_8 USB_STR_0[] =
{
   USB_STR_SIZE(2),
    USB_STRING_DESCRIPTOR,
    0x09, 0x04   /*equiavlent to 0x0409*/
};

uint_8 USB_STR_1[] =
{     
   USB_STR_SIZE(11),
   USB_STRING_DESCRIPTOR,
   'E',0,
   'S',0,
   'C',0,
   'O',0,
   'R',0,
   'T',0,
   ' ',0,
   'I',0,
   'n',0,
   'c',0,
   '.',0
};

uint_8 USB_STR_2[] =

    USB_STR_SIZE(15),
    USB_STRING_DESCRIPTOR,
    'R',0,
    'e',0,
    'd',0,
    'l',0,
    'i',0,
    'n',0,
    'e',0,
    ' ',0,
    'E',0,
    'x',0,
    ' ',0,
    'I',0,
    'n',0,
    't',0,
    'l',0
};

uint_8 USB_STR_3[] =
{
   USB_STR_SIZE(8),
   USB_STRING_DESCRIPTOR,
   '0',0,
   '0',0,
   '0',0,
   '0',0,
   '0',0,
   '0',0,
   '0',0,
   '0',0
};

uint_8 USB_STR_EE[] =
{
   USB_STR_SIZE(8),
   USB_STRING_DESCRIPTOR,
   'M', 0x00,
   'S', 0x00,
   'F', 0x00,
   'T', 0x00,
   '1', 0x00,
   '0', 0x00,
   '0', 0x00,
   MSFT_VENDOR_CODE, 0x01
};

uint_8 USB_STR_n[] =

   USB_STR_SIZE(16),
   USB_STRING_DESCRIPTOR,
   'B',0,
   'A',0,
   'D',0,
   ' ',0,
   'S',0,
   'T',0,
   'R',0,
   'I',0,
   'N',0,
   'G',0,
   ' ',0,
   'I',0,
   'N',0,
   'D',0,
   'E',0,
   'X',0
};

bpaddock

  • Frequent Contributor
  • ****
  • Posts: 66
Re: winUSB device has issues with friendly name
« Reply #3 on: August 01, 2018, 03:14:07 pm »
Quote
uint_8 USB_STR_1[] =
{     
   USB_STR_SIZE(11),
   USB_STRING_DESCRIPTOR,
   'E',0,
   'S',0,
   'C',0,
   'O',0,
   'R',0,
   'T',0,
   ' ',0,
   'I',0,
   'n',0,
   'c',0,
   '.',0
};

While not an answer to the Fun With Windows-10 question,
doing the strings one of these ways will make your brain hurt less:

uint_8 USB_STR_1[] =
{     
   USB_STR_SIZE(11),
   USB_STRING_DESCRIPTOR,
   L"ESCORT Inc." /* WCHAR [Pick one of these two] */
   u"ESCORT Inc." /* UTF16 [Pick one of these two] */
};

Don't use an upper case U as that is UTF32.
Most compilers today will support 'L' and newer ones will support both.

Do verify there are not Big/Little-Endian issues with your particular architecture.



lusher00

  • Member
  • ***
  • Posts: 3
Re: winUSB device has issues with friendly name
« Reply #4 on: August 01, 2018, 03:34:37 pm »
thank you

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: winUSB device has issues with friendly name
« Reply #5 on: August 02, 2018, 07:24:54 pm »
I see nothing that points to a reason.

You might see something amiss by monitoring the traffic on attachment or viewing the setupapi log file on a machine where it fails.

At least you found a workaround by trial/error.

bpaddock

  • Frequent Contributor
  • ****
  • Posts: 66
Re: winUSB device has issues with friendly name
« Reply #6 on: August 03, 2018, 07:45:01 am »
Quote
  uint_8 str_num,
  switch( str_num )

As your problem is a bit obscure, and this is probably not relevant, something to try is:

switch( (uint_fast16_t) str_num )

While the C Standard says an unsigned char is acceptable to a switch(), in practice I have seen it fail
with both the Digital Mars compiler and early versions of the GCC AVR compiler.
The failure in both cases was strange results rather than outright failure of the switch() taking the wrong case:.

What hardware is your problem happening on?

« Last Edit: August 03, 2018, 07:46:58 am by bpaddock »