From: Folkert v. H. <fo...@va...> - 2013-04-24 14:27:49
|
>> 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). |