1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-29 14:52:12 +01:00

Ground/rawhid: A small change to OSX serial number handling to be more

"maclike" and correct

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1988 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
peabody124 2010-10-18 00:50:51 +00:00 committed by peabody124
parent 28c3dcf771
commit 33c5877031

View File

@ -42,6 +42,7 @@
#include <unistd.h>
#include <IOKit/IOKitLib.h>
#include <IOKit/hid/IOHIDLib.h>
#include <CoreFoundation/CFString.h>
#include <QString>
#define BUFFER_SIZE 64
@ -283,8 +284,11 @@ QString pjrc_rawhid::getserial(int num) {
CFTypeRef serialnum = IOHIDDeviceGetProperty(hid->ref, CFSTR(kIOHIDSerialNumberKey));
if(serialnum && CFGetTypeID(serialnum) == CFStringGetTypeID())
{
/* For some reason the first 9 bytes of 'serialnum' are useless (a struct?) */
return QString().fromAscii((char *)serialnum+9);
//Note: I'm not sure it will always succeed if encoded as MacRoman but that
//is a superset of UTF8 so I think this is fine
CFStringRef str = (CFStringRef)serialnum;
const char * buf = CFStringGetCStringPtr(str, kCFStringEncodingMacRoman);
return QString(buf);
}
return QString("Error");