B15F Board 15 Famulus Edition

usart.h
1 #ifndef USART_H
2 #define USART_H
3
4 #include <cstdint>
5 #include <fcntl.h>
6 #include <unistd.h>
7 #include <termios.h>
8 #include <iostream>
9 #include <sys/ioctl.h>
10 #include <string.h>
11 #include "usartexception.h"
12
15 class USART
16 {
17 public:
18
19 /*************************************************
20 * Methoden für die Verwaltung der Schnittstelle *
21 *************************************************/
22
26 explicit USART() = default;
27
31 virtual ~USART(void);
32
38 void openDevice(std::string device);
39
44 void closeDevice(void);
45
50 void clearInputBuffer(void);
51
56 void clearOutputBuffer(void);
57
62 void flushOutputBuffer(void);
63
64 /*************************************************/
65
66
67
68 /*************************************
69 * Methoden für die Datenübertragung *
70 *************************************/
71
79 void transmit(uint8_t *buffer, uint16_t offset, uint8_t len);
80
88 void receive(uint8_t *buffer, uint16_t offset, uint8_t len);
89
90 /*************************************/
91
92
93
94 /***************************************
95 * Methoden für einstellbare Parameter *
96 ***************************************/
97
102 uint32_t getBaudrate(void);
103
108 uint8_t getTimeout(void);
109
114 void setBaudrate(uint32_t baudrate);
115
120 void setTimeout(uint8_t timeout);
121
122 /***************************************/
123
124 private:
125
126 int file_desc = -1;
127 uint32_t baudrate = 9600;
128 uint8_t timeout = 100;
129 };
130
131 #endif // USART_H
USART::getBaudrate
uint32_t getBaudrate(void)
Definition: usart.cpp:104
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:95
USART::receive
void receive(uint8_t *buffer, uint16_t offset, uint8_t len)
Definition: usart.cpp:75
USART::clearInputBuffer
void clearInputBuffer(void)
Definition: usart.cpp:54
USART::getTimeout
uint8_t getTimeout(void)
Definition: usart.cpp:109
USART
Definition: usart.h:15
USART::clearOutputBuffer
void clearOutputBuffer(void)
Definition: usart.cpp:61
USART::setBaudrate
void setBaudrate(uint32_t baudrate)
Definition: usart.cpp:114
USART::~USART
virtual ~USART(void)
Definition: usart.cpp:4
USART::openDevice
void openDevice(std::string device)
Definition: usart.cpp:9
USART::setTimeout
void setTimeout(uint8_t timeout)
Definition: usart.cpp:119
USART::flushOutputBuffer
void flushOutputBuffer(void)
Definition: usart.cpp:68