itas109 / CSerialPort

CSerialPort - lightweight cross-platform serial port library for C++/C/C#/Java/Python/Node.js/Electron
https://blog.csdn.net/itas109/article/details/84282860
Other
740 stars 338 forks source link

Mac枚举串口列表失败,getSerialPath有Bug #75

Closed xxCabin closed 1 year ago

xxCabin commented 1 year ago

/描述bug Mac枚举串口失败 `char getSerialPath(char dest, io_object_t &serialPort) { CFTypeRef calloutCFString;

calloutCFString = IORegistryEntryCreateCFProperty(serialPort, CFSTR(kIOCalloutDeviceKey), kCFAllocatorDefault, 0);

if (calloutCFString)
{
    // sizeof(dest) = 8bytes, can not copy all bytes
    // CFStringGetCString(static_cast<CFStringRef>(calloutCFString), dest, sizeof(dest), kCFStringEncodingUTF8);

    CFStringGetCString(static_cast<CFStringRef>(calloutCFString), dest, MAXPATHLEN, kCFStringEncodingUTF8);

    CFRelease(calloutCFString);
}

return dest;

}`

重现步骤 mac下,调用getPortInfoList 预期行为截图 image

运行环境信息:

其他内容

itas109 commented 1 year ago

感谢反馈,可以加群交流