-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserial.h
45 lines (41 loc) · 1.15 KB
/
serial.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
/*
* serial.h
*
* MSU STARX Exosuit
* Software Version 2.3
* Created on: September 30, 2018
* All rights reserved
*/
#ifndef SERIAL_H_
#define SERIAL_H_
// Standard includes
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
class SerialPort {
public:
speed_t constBaud;
int fileDescriptor = 0;
int bytesWrite = 0;
int bytesRead = 0;
int baudRate = 0;
static const int byteSize = 1; // Default byte array size
static const int bufferSize = 255; // Default buffer array size
char byteArray[byteSize] = {0}; // Initialized with null characters
char bufferRead[bufferSize] = {0}; // Initialized with null characters
const char *portName;
struct termios portSettings;
void openPort(void);
void setPort(void);
void flushPortIn(void);
void flushPortOut(void);
void flushPortAll(void);
void closePort(void);
void writePort(const char* bufferWrite);
char* readPort(void);
char* readPortUntil(char bufferTerminator);
};
#endif // SERIAL_H_