mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-05 21:52:10 +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:
parent
28c3dcf771
commit
33c5877031
@ -42,6 +42,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <IOKit/IOKitLib.h>
|
#include <IOKit/IOKitLib.h>
|
||||||
#include <IOKit/hid/IOHIDLib.h>
|
#include <IOKit/hid/IOHIDLib.h>
|
||||||
|
#include <CoreFoundation/CFString.h>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#define BUFFER_SIZE 64
|
#define BUFFER_SIZE 64
|
||||||
@ -283,8 +284,11 @@ QString pjrc_rawhid::getserial(int num) {
|
|||||||
CFTypeRef serialnum = IOHIDDeviceGetProperty(hid->ref, CFSTR(kIOHIDSerialNumberKey));
|
CFTypeRef serialnum = IOHIDDeviceGetProperty(hid->ref, CFSTR(kIOHIDSerialNumberKey));
|
||||||
if(serialnum && CFGetTypeID(serialnum) == CFStringGetTypeID())
|
if(serialnum && CFGetTypeID(serialnum) == CFStringGetTypeID())
|
||||||
{
|
{
|
||||||
/* For some reason the first 9 bytes of 'serialnum' are useless (a struct?) */
|
//Note: I'm not sure it will always succeed if encoded as MacRoman but that
|
||||||
return QString().fromAscii((char *)serialnum+9);
|
//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");
|
return QString("Error");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user