实现串口监控功能,重构 ComKit::Work 方法以支持指定端口
This commit is contained in:
@@ -90,34 +90,7 @@ LRESULT ImGuiHelper::WndProc(HWND hWnd, UINT msg, WPARAM wParam,
|
||||
PDEV_BROADCAST_HDR pHdr = reinterpret_cast<PDEV_BROADCAST_HDR>(lParam);
|
||||
switch (wParam) {
|
||||
case DBT_DEVICEARRIVAL:
|
||||
if (pHdr->dbch_devicetype == DBT_DEVTYP_PORT) {
|
||||
PDEV_BROADCAST_PORT pPort =
|
||||
reinterpret_cast<PDEV_BROADCAST_PORT>(pHdr);
|
||||
spdlog::log(spdlog::level::debug,
|
||||
std::format("port: [{}] add", pPort->dbcp_name));
|
||||
ComKit::FlushLog();
|
||||
ComKit::GetAllComPortNames();
|
||||
ComKit::Work();
|
||||
} else {
|
||||
spdlog::log(spdlog::level::debug,
|
||||
std::format("port: other device [{}] add",
|
||||
pHdr->dbch_devicetype));
|
||||
}
|
||||
break;
|
||||
case DBT_DEVICEREMOVECOMPLETE:
|
||||
if (pHdr->dbch_devicetype == DBT_DEVTYP_PORT) {
|
||||
PDEV_BROADCAST_PORT pPort =
|
||||
reinterpret_cast<PDEV_BROADCAST_PORT>(pHdr);
|
||||
spdlog::log(
|
||||
spdlog::level::debug,
|
||||
std::format("port: [{}] removed", pPort->dbcp_name));
|
||||
ComKit::FlushLog();
|
||||
ComKit::GetAllComPortNames();
|
||||
} else {
|
||||
spdlog::log(spdlog::level::debug,
|
||||
std::format("port: other device [{}] add",
|
||||
pHdr->dbch_devicetype));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user