46 lines
671 B
C++
46 lines
671 B
C++
//
|
|
// Created by h44z on 07.05.19.
|
|
//
|
|
|
|
#ifndef GCLOGGER_SERIALPORT_H
|
|
#define GCLOGGER_SERIALPORT_H
|
|
|
|
#include <iostream>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include <termios.h> // POSIX terminal control definitions
|
|
#include <unistd.h>
|
|
#include <fcntl.h>
|
|
|
|
using namespace std;
|
|
|
|
class SerialPort {
|
|
int fd;
|
|
struct termios tio;
|
|
int tioBaud;
|
|
|
|
static int getTioBaud(int);
|
|
|
|
public:
|
|
// Constructor
|
|
SerialPort();
|
|
|
|
SerialPort(const string &, int);
|
|
|
|
~SerialPort();
|
|
|
|
bool isOpen();
|
|
|
|
bool serialClose();
|
|
|
|
vector<uint8_t> serialRead(int);
|
|
|
|
int serialWrite(const string &);
|
|
|
|
bool clearInput(int);
|
|
};
|
|
|
|
|
|
#endif //GCLOGGER_SERIALPORT_H
|