迁移入tty持续连接

This commit is contained in:
2026-03-28 04:08:07 +08:00
parent 4a640cf7db
commit d195deaa48
10 changed files with 504 additions and 3 deletions

View File

@@ -0,0 +1,49 @@
#ifndef UNIFIED_MANAGER_HPP
#define UNIFIED_MANAGER_HPP
#include "serialComm.hpp"
#include <memory>
#include <thread>
#include <atomic>
#include <mutex>
// Unified device manager (Serial )
class UnifiedDeviceManager {
private:
// Device instances
std::unique_ptr<SerialComm> m_serial;
std::unique_ptr<CameraManager> m_camera;
// Thread management
std::thread m_serialReconnectThread;
std::atomic<bool> m_serialConnected;
std::atomic<bool> m_shouldStop;
std::mutex m_serialMutex;
int m_retryIntervalMs;
// Serial reconnect thread
void serialReconnectThreadFunc();
public:
UnifiedDeviceManager(int retryIntervalMs = 500);
~UnifiedDeviceManager();
// Control methods
void start();
void stop();
// Status check
bool isSerialConnected() const { return m_serialConnected.load(); }
// Serial operations (thread-safe)
bool sendData(const char* data, size_t length);
int receiveData(uint8_t* buffer, size_t maxLength);
// Camera operations (thread-safe)
bool grabFrame(cv::Mat& frame);
const char* getCameraName() const;
};
#endif // UNIFIED_MANAGER_HPP