实现串口监控功能,重构 ComKit::Work 方法以支持指定端口
This commit is contained in:
20
src/main.cc
20
src/main.cc
@@ -1,4 +1,5 @@
|
||||
#include "ComKit.h"
|
||||
#include "ComWatch.h"
|
||||
#include "imgui_helper.h"
|
||||
#include "imgui_stdlib.h"
|
||||
#include "spdlog/sinks/basic_file_sink.h"
|
||||
@@ -67,6 +68,25 @@ int main(int argc, char **) {
|
||||
filterComName = config.at("ComPorts").as_string();
|
||||
inputCommands = config.at("Commands").as_string();
|
||||
}
|
||||
SerialWatch watcher;
|
||||
watcher.set_callback([](const std::string &port_name, SIGNAL_TYPE type) {
|
||||
switch (type) {
|
||||
case SIGNAL_TYPE::REMOVE_:
|
||||
spdlog::log(spdlog::level::debug,
|
||||
std::format("port: [{}] removed", port_name));
|
||||
ComKit::FlushLog();
|
||||
ComKit::GetAllComPortNames();
|
||||
break;
|
||||
case SIGNAL_TYPE::ADD_:
|
||||
spdlog::log(spdlog::level::debug,
|
||||
std::format("port: [{}] add", port_name));
|
||||
ComKit::FlushLog();
|
||||
ComKit::GetAllComPortNames();
|
||||
ComKit::Work(port_name);
|
||||
break;
|
||||
}
|
||||
});
|
||||
watcher.work();
|
||||
while (isRunning)
|
||||
helper.Render(
|
||||
[&]() {
|
||||
|
||||
Reference in New Issue
Block a user