-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSCSerial.h
45 lines (41 loc) · 1.03 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
/*
* SCSerial.h
* 飞特串行舵机硬件接口层程序
* 日期: 2019.7.22
* 作者:
*/
#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:
virtual int writeSCS(unsigned char *nDat, int nLen);//输出nLen字节
virtual int readSCS(unsigned char *nDat, int nLen);//输入nLen字节
virtual int writeSCS(unsigned char bDat);//输出1字节
virtual void rFlushSCS();//
virtual 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
};
#endif