实现串口监控功能,重构 ComKit::Work 方法以支持指定端口

This commit is contained in:
JIe
2024-11-07 17:35:02 +08:00
parent cea5209222
commit 7316c326d0
7 changed files with 365 additions and 312 deletions

View File

@@ -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;
}
}