SerialPort
A light-weight C++ library for cross-platform serial communication.
Loading...
Searching...
No Matches
src
serial_port_linux.h
1
#ifndef SERIAL_PORT_LINUX_H_
2
#define SERIAL_PORT_LINUX_H_
3
4
#if defined(__linux__)
5
6
#include "termios.h"
7
8
#include "serial_port/serial_port.h"
9
#include "interface.h"
10
11
namespace
serial_port
12
{
13
class
SerialPortLinux :
public
Interface
14
{
15
public
:
16
// Inherit the constructors from the interface
17
using
Interface::Interface;
18
19
// Make sure the port gets properly closed on destruction
20
~SerialPortLinux()
override
{ SerialPortLinux::Close(); }
21
22
// Implement the interface
23
void
Open()
override
;
24
void
Close()
override
;
25
bool
IsOpen()
override
;
26
27
unsigned
long
NumBytesAvailable()
override
;
28
void
FlushBuffer()
const override
;
29
30
unsigned
long
ReadData(
char
* data,
unsigned
long
num_bytes)
override
;
31
unsigned
long
WriteData(
const
char
* data,
unsigned
long
num_bytes)
override
;
32
33
private
:
34
int
handle_{ -1 };
35
struct
termios tty_;
36
};
37
}
38
39
#endif
// __linux__
40
41
#endif
// !SERIAL_PORT_LINUX_H_
Generated by
1.12.0