25 lines
699 B
C
25 lines
699 B
C
|
#include "Arduino.h"
|
||
|
|
||
|
class Serialcommand
|
||
|
{
|
||
|
private:
|
||
|
static const int inbuffersize = 20;
|
||
|
int CmdState; // 指令接收状态
|
||
|
uint8_t ch; // 临时单个字符存储
|
||
|
int datalen;
|
||
|
bool recv_flag; // 指令接收成功标志
|
||
|
uint8_t inBuffer[inbuffersize]; // 接收指令缓冲区
|
||
|
uint8_t bufferIndex;
|
||
|
static const int outbuffersize = 20;
|
||
|
uint8_t outBuffer[outbuffersize];
|
||
|
void Uart_Command_Rev(void);
|
||
|
uint8_t getsum(const uint8_t *buffer, size_t size);
|
||
|
bool checksum();
|
||
|
void sendcmdret(uint8_t cmdret);
|
||
|
|
||
|
public:
|
||
|
Serialcommand(); // 构造函数
|
||
|
~Serialcommand(); // 析构函数
|
||
|
void getcommand();
|
||
|
};
|