参考上海交通大学代码进行修改

This commit is contained in:
2025-12-05 11:13:37 +08:00
parent 593cb37cf7
commit f6e7d37da9
41 changed files with 2297 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
#ifndef TTLCOMMUNICATOR_H
#define TTLCOMMUNICATOR_H
#include <string>
class TTLCommunicator {
public:
TTLCommunicator(const std::string& port_name = "/dev/ttyUSB0", int baudrate = 115200);
~TTLCommunicator();
bool connect();
void close();
bool send_data(const std::string& data);
bool is_connected() const { return connected; }
private:
std::string port_name;
int baudrate;
bool connected;
int serial_fd;
bool open_serial_port();
void close_serial_port();
};
#endif // TTLCOMMUNICATOR_H