27 lines
541 B
C++
27 lines
541 B
C++
#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
|