From: Alan O. <al...@si...> - 2013-04-24 14:37:31
|
On 04/24/2013 10:27 AM, Folkert van Heusden wrote: >>> I ported clewarecontrol to hidapi and all runs fine on linux. >>> On macos x, though, it doesn't show the serial number. This is rather >>> essential as it is needed to distinguish what device to control when you >>> have multiple connected. >>> The hidtest program included in hidapi doesn't show the serial either: >>> The serial number ought to be 900705 (decimal) or DBE61 (hex). >> It's worth noting that the serial number is a string descriptor, >> containing a Unicode string, UTF-16 encoded. Sticking random bytes in it >> may be causing the UTF-16 parser in the Apple kernel/libraries to bail >> somewhere. That's my first guess since it seems to work for others. > The code of the (original) cleware c++ library does: > > int strInc = (s[1] == 0) ? 2 : 1 ; > for ( ; *s ; s+=strInc) { > // unicode byte 2 == 0 > if (*s >= '0' && *s <= '9') > SerNum = > SerNum * 16 + *s - '0' ; > else if (*s >= 'A' && *s <= 'F') > SerNum = > SerNum * 16 + *s - 'A' + 10 ; > } > > So I think that some use plain ascii while others may use UTF-16 (with > high byte set to 0x00). You should use the wide character functions. HIDAPI will give you a wchar_t, with which you could use something like wcstol(). I'm less interested in what the PC-side does than what the firmware does. Can you send your string descriptor (as a fragment of your firmware)? Have you tried putting a normal string for the serial number in the firmware (like hard-coding to "ASDF") and seeing if that makes it through? Are you able to see serial numbers from other devices? Alan. |