mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-30 15:52:12 +01:00
fixed reading serial number from USB device on mac platform
This commit is contained in:
parent
5b8b38ad7b
commit
427bbd0a80
@ -277,8 +277,18 @@ QString pjrc_rawhid::getserial(int num) {
|
|||||||
//Note: I'm not sure it will always succeed if encoded as MacRoman but that
|
//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
|
//is a superset of UTF8 so I think this is fine
|
||||||
CFStringRef str = (CFStringRef)serialnum;
|
CFStringRef str = (CFStringRef)serialnum;
|
||||||
const char * buf = CFStringGetCStringPtr(str, kCFStringEncodingMacRoman);
|
// const char * buf = CFStringGetCStringPtr(str, kCFStringEncodingMacRoman);
|
||||||
return QString(buf);
|
//return QString(buf);
|
||||||
|
int length = CFStringGetLength(str);
|
||||||
|
if( length == 0 )
|
||||||
|
return "";
|
||||||
|
char* ptr = (char*)malloc( length+1 );
|
||||||
|
Boolean ret = CFStringGetCString( str, ptr, length+1, kCFStringEncodingMacRoman );
|
||||||
|
QString strResult;
|
||||||
|
if( ret == true )
|
||||||
|
strResult = ptr;
|
||||||
|
free( ptr );
|
||||||
|
return strResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
return QString("Error");
|
return QString("Error");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user