gclogger/src/SerialPort.h

46 lines
671 B
C
Raw Normal View History

2019-05-07 23:14:21 +02:00
//
// Created by h44z on 07.05.19.
//
#ifndef GCLOGGER_SERIALPORT_H
#define GCLOGGER_SERIALPORT_H
#include <iostream>
#include <string>
2019-05-08 18:07:23 +02:00
#include <vector>
2019-05-07 23:14:21 +02:00
#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;
2019-05-08 18:07:23 +02:00
static int getTioBaud(int);
2019-05-07 23:14:21 +02:00
public:
// Constructor
SerialPort();
2019-05-08 18:07:23 +02:00
SerialPort(const string &, int);
2019-05-07 23:14:21 +02:00
~SerialPort();
bool isOpen();
2019-05-08 18:07:23 +02:00
2019-05-07 23:14:21 +02:00
bool serialClose();
2019-05-08 18:07:23 +02:00
vector<uint8_t> serialRead(int);
int serialWrite(const string &);
2019-05-07 23:14:21 +02:00
bool clearInput(int);
};
#endif //GCLOGGER_SERIALPORT_H