参考上海交通大学代码进行修改
This commit is contained in:
27
Catalyst-MDVS2/inc/TTLCommunicator.h
Normal file
27
Catalyst-MDVS2/inc/TTLCommunicator.h
Normal 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
|
||||
Reference in New Issue
Block a user