33 lines
680 B
C
33 lines
680 B
C
|
|
//
|
||
|
|
// Created by tankaitao on 2025/6/27.
|
||
|
|
//
|
||
|
|
|
||
|
|
#ifndef SERIAL_PORT_H
|
||
|
|
#define SERIAL_PORT_H
|
||
|
|
#include <string>
|
||
|
|
#include <vector>
|
||
|
|
#include <cstdint>
|
||
|
|
|
||
|
|
|
||
|
|
namespace cmvr
|
||
|
|
{
|
||
|
|
class SerialPort{
|
||
|
|
public:
|
||
|
|
SerialPort()=default;
|
||
|
|
~SerialPort();
|
||
|
|
|
||
|
|
bool open(const std::string &port_name,unsigned int baud_rate);
|
||
|
|
void close();
|
||
|
|
bool is_open();
|
||
|
|
bool wakeupESP32(const std::string &port_name);
|
||
|
|
bool send(const std::vector<uint8_t>& data);
|
||
|
|
bool sendRawServoData(const std::vector<uint8_t>& raw);
|
||
|
|
static void printPacket(const std::vector<uint8_t>& packet);
|
||
|
|
private:
|
||
|
|
int fd_ = -1;
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
#endif //SERIAL_PORT_H
|