-
Notifications
You must be signed in to change notification settings - Fork 1
/
SCSerial.h
48 lines (43 loc) · 1.04 KB
/
SCSerial.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* SCSerial.h
* 飞特串行舵机硬件接口层程序
* 日期: 2022.3.29
* 作者:
*/
#ifndef _SCSERIAL_H
#define _SCSERIAL_H
#include "SCS.h"
#include <stdio.h>
#include <termios.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <sys/select.h>
class SCSerial : public SCS
{
public:
SCSerial();
SCSerial(u8 End);
SCSerial(u8 End, u8 Level);
protected:
int writeSCS(unsigned char *nDat, int nLen);//输出nLen字节
int readSCS(unsigned char *nDat, int nLen);//输入nLen字节
int writeSCS(unsigned char bDat);//输出1字节
void rFlushSCS();//
void wFlushSCS();//
public:
unsigned long int IOTimeOut;//输入输出超时
int Err;
public:
virtual int getErr(){ return Err; }
virtual int setBaudRate(int baudRate);
virtual bool begin(int baudRate, const char* serialPort);
virtual void end();
protected:
int fd;//serial port handle
struct termios orgopt;//fd ort opt
struct termios curopt;//fd cur opt
unsigned char txBuf[255];
int txBufLen;
};
#endif