实现串口监控功能,重构 ComKit::Work 方法以支持指定端口
This commit is contained in:
28
include/ComWatch.h
Normal file
28
include/ComWatch.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef COMWATCH_H
|
||||
#include "serial.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
|
||||
enum class SIGNAL_TYPE{
|
||||
REMOVE_,
|
||||
ADD_,
|
||||
};
|
||||
|
||||
class SerialWatch {
|
||||
private:
|
||||
std::function<void(const std::string&, SIGNAL_TYPE type)> callback;
|
||||
std::jthread work_thread;
|
||||
std::stop_source s;
|
||||
std::mutex m;
|
||||
public:
|
||||
SerialWatch() = default;
|
||||
~SerialWatch();
|
||||
void set_callback(std::function<void(const std::string&, SIGNAL_TYPE type)> func);
|
||||
void work();
|
||||
|
||||
};
|
||||
|
||||
#endif // !COMWATCH_H
|
||||
Reference in New Issue
Block a user