# B15F: drv/usart.h Source File

usart.h
#ifndef USART_H
#define USART_H
#include <cstdint>
#include <chrono>
#include <fcntl.h>
#include <unistd.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <string.h>
#include "usartexception.h"
#include "timeoutexception.h"
class USART
{
public:
/*************************************************
* Methoden für die Verwaltung der Schnittstelle *
*************************************************/
explicit USART() = default;
virtual ~USART(void);
void openDevice(std::string device);
void closeDevice(void);
void clearInputBuffer(void);
void clearOutputBuffer(void);
void flushOutputBuffer(void);
/*************************************************/
/*************************************
* Methoden für die Datenübertragung *
*************************************/
void transmit(uint8_t *buffer, uint16_t offset, uint8_t len);
void receive(uint8_t *buffer, uint16_t offset, uint8_t len);
void drop(uint8_t len);
/*************************************/
/***************************************
* Methoden für einstellbare Parameter *
***************************************/
uint32_t getBaudrate(void);
uint8_t getTimeout(void);
void setBaudrate(uint32_t baudrate);
void setTimeout(uint8_t timeout);
/***************************************/
private:
int file_desc = -1;
uint32_t baudrate = 9600;
uint8_t timeout = 10;
};
#endif // USART_H
USART::getBaudrate
uint32_t getBaudrate(void)
Definition: usart.cpp:121
USART::USART
USART()=default
USART::closeDevice
void closeDevice(void)
Definition: usart.cpp:43
USART::transmit
void transmit(uint8_t *buffer, uint16_t offset, uint8_t len)
Definition: usart.cpp:75
USART::receive
void receive(uint8_t *buffer, uint16_t offset, uint8_t len)
Definition: usart.cpp:84
USART::clearInputBuffer
void clearInputBuffer(void)
Definition: usart.cpp:54
USART::getTimeout
uint8_t getTimeout(void)
Definition: usart.cpp:126
USART
Definition: usart.h:16
USART::clearOutputBuffer
void clearOutputBuffer(void)
Definition: usart.cpp:61
USART::setBaudrate
void setBaudrate(uint32_t baudrate)
Definition: usart.cpp:131
USART::~USART
virtual ~USART(void)
Definition: usart.cpp:4
USART::openDevice
void openDevice(std::string device)
Definition: usart.cpp:9
USART::drop
void drop(uint8_t len)
Definition: usart.cpp:114
USART::setTimeout
void setTimeout(uint8_t timeout)
Definition: usart.cpp:136
USART::flushOutputBuffer
void flushOutputBuffer(void)
Definition: usart.cpp:68