-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSerialInterface.h
40 lines (32 loc) · 1.05 KB
/
SerialInterface.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
/**
* @file SerialInterface.h
* @brief Functions to control how the robot communicates via serial.
*/
#ifndef SERIALINTERFACE_H
#define SERIALINTERFACE_H
/*-------------------- INCLUDES --------------------*/
#include "Common.h"
#include <termios.h>
#include <fcntl.h>
/*-------------------- DEFINES --------------------*/
#define INTERFACE_NAME "/dev/ttyUSB0"
#define INTERFACE_SPEED B57600
#define INTERFACE_DATA_BITS 8
#define INTERFACE_PARITY 0
#define INTERFACE_FLOW_CONTROL 0
#define INTERFACE_BLOCKING_READ 1 // Sets whether or not reads block or just return up to the number of bits in the buffer. Can be either 0 or 1.
/*---------------- CLASS DEFINITION ----------------*/
class SerialInterface
{
public:
SerialInterface (void) {}
~SerialInterface (void) {}
void start (void);
void writeByte (const uint8_t b);
void writeBytes (uint8_t* bs, const uint32_t n);
uint8_t readByte (void);
void readBytes (uint8_t* bs, const uint32_t n);
private:
int mSerialPort;
};
#endif