#pragma once #include #include #include using std::string; using std::vector; /** @brief manage asynchronous serial connection */ class CDSerialConnector { public: CDSerialConnector(); ~CDSerialConnector(); /** @brief get list of available serial ports */ static vector get_ports(); /** @brief open serial port */ virtual void connect(); /** @brief close serial port */ virtual void disconnect(); /** @brief write to serial port */ virtual void write(QByteArray msg); /** @brief get last message */ virtual QByteArray get_data(); private: /** @brief executed when new data is received */ virtual void action(); QSerialPort *_serial = nullptr; QByteArray _msg; }; /** @brief global pointer to serial connector, initialized in CDMainWindow */ extern CDSerialConnector *g_cd_serial;