diff --git a/ground/src/plugins/rawhid/pjrc_rawhid_mac.cpp b/ground/src/plugins/rawhid/pjrc_rawhid_mac.cpp index e62ba1ca8..88811ae5a 100644 --- a/ground/src/plugins/rawhid/pjrc_rawhid_mac.cpp +++ b/ground/src/plugins/rawhid/pjrc_rawhid_mac.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #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");