You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
#pragma once
#include <termios.h>
#include <unistd.h>
#include <fstream>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <set>
#include <sstream>
#include <string>
#include <vector>
namespace iflytop { using namespace std; // ref:https://www.cnblogs.com/electron/p/3451114.html
// ref:https://baike.baidu.com/item/tcflush/6869357?fr=aladdin
class Uart { private: /* data */ int m_fd = 0; string m_name; string m_rate; struct termios m_tty; string m_error;
public: Uart(); ~Uart();
/**
* @brief 打开串口 * * @param path * @param rate * "0" "50" "75" "110" * "134" "150" "200" "300" * "600" "1200" "1800" "2400" * "4800" "9600" "19200" "38400" * "57600" "115200" "230400" "460800" * "500000" "576000" "921600" "1000000" * "1152000" "1500000" "2000000" "2500000" * "3000000" "3500000" "4000000" * * @return int */ int open(string path, string rate); int send(char *data, int size); int receive(char *data, int size_max); int receive(char *data, int size, int overtimems); int close();
string get_error() { return m_error; }
bool flush_rx(); bool flush_tx(); bool set_rx_overtime(int n100ms); };
} // namespace iflytop
|