B15F Board 15 Famulus Edition

usart.h
1 #ifndef USART_H
2 #define USART_H
3
4 #include <cstdint>
5 #include <chrono>
6 #include <fcntl.h>
7 #include <unistd.h>
8 #include <termios.h>
9 #include <sys/ioctl.h>
10 #include <string.h>
11 #include "usartexception.h"
12 #include "timeoutexception.h"
13
16 class USART
17 {
18 public:
19
20 /*************************************************
21 * Methoden für die Verwaltung der Schnittstelle *
22 *************************************************/
23
27 explicit USART() = default;
28
32 virtual ~USART(void);
33
39 void openDevice(std::string device);
40
45 void closeDevice(void);
46
51 void clearInputBuffer(void);
52
57 void clearOutputBuffer(void);
58
63 void flushOutputBuffer(void);
64
65 /*************************************************/
66
67
68
69 /*************************************
70 * Methoden für die Datenübertragung *
71 *************************************/
72
80 void transmit(uint8_t *buffer, uint16_t offset, uint8_t len);
81
89 void receive(uint8_t *buffer, uint16_t offset, uint8_t len);
90
96 void drop(uint8_t len);
97
98 /*************************************/
99
100
101
102 /***************************************
103 * Methoden für einstellbare Parameter *
104 ***************************************/
105
110 uint32_t getBaudrate(void);
111
116 uint8_t getTimeout(void);
117
122 void setBaudrate(uint32_t baudrate);
123
128 void setTimeout(uint8_t timeout);
129
130 /***************************************/
131
132 private:
133
134 int file_desc = -1;
135 uint32_t baudrate = 9600;
136 uint8_t timeout = 10;
137 };
138
139 #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