From eb64c8eded8a0b894fb0738b01977754304b09c4 Mon Sep 17 00:00:00 2001 From: Tim Zeuner Date: Sun, 20 Nov 2022 20:17:30 +0100 Subject: [PATCH] Added the Communication Module to the repo. --- .../CMakeLists.txt | 0 .../ControlModule}/CMakeLists.txt | 0 .../ControlModule}/control_module.cpp | 0 .../ControlModule}/control_module.h | 0 .../Input}/CMakeLists.txt | 0 {Input => AutonomousMode/Input}/input.cpp | 0 {Input => AutonomousMode/Input}/input.h | 0 .../Interpreter}/CMakeLists.txt | 0 .../Interpreter}/interpreter.cpp | 0 .../Interpreter}/interpreter.h | 0 .../IntersectionHandler}/CMakeLists.txt | 0 .../intersection_handler.cpp | 0 .../intersection_handler.h | 0 .../Processing}/CMakeLists.txt | 0 .../Processing}/processing.cpp | 0 .../Processing}/processing.h | 0 .../Spielwiese}/CMakeLists.txt | 0 .../Spielwiese}/spielwiese.cpp | 0 .../Test_data}/image1.jpeg | Bin .../Test_data}/image10.jpeg | Bin .../Test_data}/image11.jpeg | Bin .../Test_data}/image12.jpeg | Bin .../Test_data}/image13.jpeg | Bin .../Test_data}/image14.jpeg | Bin .../Test_data}/image15.jpeg | Bin .../Test_data}/image16.jpeg | Bin .../Test_data}/image17.jpeg | Bin .../Test_data}/image18.jpeg | Bin .../Test_data}/image19.jpeg | Bin .../Test_data}/image2.jpeg | Bin .../Test_data}/image20.jpeg | Bin .../Test_data}/image21.jpeg | Bin .../Test_data}/image22.jpeg | Bin .../Test_data}/image23.jpeg | Bin .../Test_data}/image24.jpeg | Bin .../Test_data}/image25.jpeg | Bin .../Test_data}/image26.jpeg | Bin .../Test_data}/image27.jpeg | Bin .../Test_data}/image28.jpeg | Bin .../Test_data}/image3.jpeg | Bin .../Test_data}/image4.jpeg | Bin .../Test_data}/image5.jpeg | Bin .../Test_data}/image6.jpeg | Bin .../Test_data}/image7.jpeg | Bin .../Test_data}/image8.jpeg | Bin .../Test_data}/image9.jpeg | Bin .../Utils}/CMakeLists.txt | 0 {Utils => AutonomousMode/Utils}/utils.cpp | 0 {Utils => AutonomousMode/Utils}/utils.h | 0 .../autonomous_mode_main.cpp | 0 lfr.cpp => AutonomousMode/lfr.cpp | 0 lfr.h => AutonomousMode/lfr.h | 0 Communication/CMakeLists.txt | 17 ++ Communication/uart_communication.cpp | 152 ++++++++++++++++++ Communication/uart_communication.h | 56 +++++++ 55 files changed, 225 insertions(+) rename CMakeLists.txt => AutonomousMode/CMakeLists.txt (100%) rename {ControlModule => AutonomousMode/ControlModule}/CMakeLists.txt (100%) rename {ControlModule => AutonomousMode/ControlModule}/control_module.cpp (100%) rename {ControlModule => AutonomousMode/ControlModule}/control_module.h (100%) rename {Input => AutonomousMode/Input}/CMakeLists.txt (100%) rename {Input => AutonomousMode/Input}/input.cpp (100%) rename {Input => AutonomousMode/Input}/input.h (100%) rename {Interpreter => AutonomousMode/Interpreter}/CMakeLists.txt (100%) rename {Interpreter => AutonomousMode/Interpreter}/interpreter.cpp (100%) rename {Interpreter => AutonomousMode/Interpreter}/interpreter.h (100%) rename {IntersectionHandler => AutonomousMode/IntersectionHandler}/CMakeLists.txt (100%) rename {IntersectionHandler => AutonomousMode/IntersectionHandler}/intersection_handler.cpp (100%) rename {IntersectionHandler => AutonomousMode/IntersectionHandler}/intersection_handler.h (100%) rename {Processing => AutonomousMode/Processing}/CMakeLists.txt (100%) rename {Processing => AutonomousMode/Processing}/processing.cpp (100%) rename {Processing => AutonomousMode/Processing}/processing.h (100%) rename {Spielwiese => AutonomousMode/Spielwiese}/CMakeLists.txt (100%) rename {Spielwiese => AutonomousMode/Spielwiese}/spielwiese.cpp (100%) rename {Test_data => AutonomousMode/Test_data}/image1.jpeg (100%) rename {Test_data => AutonomousMode/Test_data}/image10.jpeg (100%) rename {Test_data => AutonomousMode/Test_data}/image11.jpeg (100%) rename {Test_data => AutonomousMode/Test_data}/image12.jpeg (100%) rename {Test_data => AutonomousMode/Test_data}/image13.jpeg (100%) rename {Test_data => AutonomousMode/Test_data}/image14.jpeg (100%) rename {Test_data => AutonomousMode/Test_data}/image15.jpeg (100%) rename {Test_data => AutonomousMode/Test_data}/image16.jpeg (100%) rename {Test_data => AutonomousMode/Test_data}/image17.jpeg (100%) rename {Test_data => AutonomousMode/Test_data}/image18.jpeg (100%) rename {Test_data => AutonomousMode/Test_data}/image19.jpeg (100%) rename {Test_data => AutonomousMode/Test_data}/image2.jpeg (100%) rename {Test_data => AutonomousMode/Test_data}/image20.jpeg (100%) rename {Test_data => AutonomousMode/Test_data}/image21.jpeg (100%) rename {Test_data => AutonomousMode/Test_data}/image22.jpeg (100%) rename {Test_data => AutonomousMode/Test_data}/image23.jpeg (100%) rename {Test_data => AutonomousMode/Test_data}/image24.jpeg (100%) rename {Test_data => AutonomousMode/Test_data}/image25.jpeg (100%) rename {Test_data => AutonomousMode/Test_data}/image26.jpeg (100%) rename {Test_data => AutonomousMode/Test_data}/image27.jpeg (100%) rename {Test_data => AutonomousMode/Test_data}/image28.jpeg (100%) rename {Test_data => AutonomousMode/Test_data}/image3.jpeg (100%) rename {Test_data => AutonomousMode/Test_data}/image4.jpeg (100%) rename {Test_data => AutonomousMode/Test_data}/image5.jpeg (100%) rename {Test_data => AutonomousMode/Test_data}/image6.jpeg (100%) rename {Test_data => AutonomousMode/Test_data}/image7.jpeg (100%) rename {Test_data => AutonomousMode/Test_data}/image8.jpeg (100%) rename {Test_data => AutonomousMode/Test_data}/image9.jpeg (100%) rename {Utils => AutonomousMode/Utils}/CMakeLists.txt (100%) rename {Utils => AutonomousMode/Utils}/utils.cpp (100%) rename {Utils => AutonomousMode/Utils}/utils.h (100%) rename autonomous_mode_main.cpp => AutonomousMode/autonomous_mode_main.cpp (100%) rename lfr.cpp => AutonomousMode/lfr.cpp (100%) rename lfr.h => AutonomousMode/lfr.h (100%) create mode 100644 Communication/CMakeLists.txt create mode 100644 Communication/uart_communication.cpp create mode 100644 Communication/uart_communication.h diff --git a/CMakeLists.txt b/AutonomousMode/CMakeLists.txt similarity index 100% rename from CMakeLists.txt rename to AutonomousMode/CMakeLists.txt diff --git a/ControlModule/CMakeLists.txt b/AutonomousMode/ControlModule/CMakeLists.txt similarity index 100% rename from ControlModule/CMakeLists.txt rename to AutonomousMode/ControlModule/CMakeLists.txt diff --git a/ControlModule/control_module.cpp b/AutonomousMode/ControlModule/control_module.cpp similarity index 100% rename from ControlModule/control_module.cpp rename to AutonomousMode/ControlModule/control_module.cpp diff --git a/ControlModule/control_module.h b/AutonomousMode/ControlModule/control_module.h similarity index 100% rename from ControlModule/control_module.h rename to AutonomousMode/ControlModule/control_module.h diff --git a/Input/CMakeLists.txt b/AutonomousMode/Input/CMakeLists.txt similarity index 100% rename from Input/CMakeLists.txt rename to AutonomousMode/Input/CMakeLists.txt diff --git a/Input/input.cpp b/AutonomousMode/Input/input.cpp similarity index 100% rename from Input/input.cpp rename to AutonomousMode/Input/input.cpp diff --git a/Input/input.h b/AutonomousMode/Input/input.h similarity index 100% rename from Input/input.h rename to AutonomousMode/Input/input.h diff --git a/Interpreter/CMakeLists.txt b/AutonomousMode/Interpreter/CMakeLists.txt similarity index 100% rename from Interpreter/CMakeLists.txt rename to AutonomousMode/Interpreter/CMakeLists.txt diff --git a/Interpreter/interpreter.cpp b/AutonomousMode/Interpreter/interpreter.cpp similarity index 100% rename from Interpreter/interpreter.cpp rename to AutonomousMode/Interpreter/interpreter.cpp diff --git a/Interpreter/interpreter.h b/AutonomousMode/Interpreter/interpreter.h similarity index 100% rename from Interpreter/interpreter.h rename to AutonomousMode/Interpreter/interpreter.h diff --git a/IntersectionHandler/CMakeLists.txt b/AutonomousMode/IntersectionHandler/CMakeLists.txt similarity index 100% rename from IntersectionHandler/CMakeLists.txt rename to AutonomousMode/IntersectionHandler/CMakeLists.txt diff --git a/IntersectionHandler/intersection_handler.cpp b/AutonomousMode/IntersectionHandler/intersection_handler.cpp similarity index 100% rename from IntersectionHandler/intersection_handler.cpp rename to AutonomousMode/IntersectionHandler/intersection_handler.cpp diff --git a/IntersectionHandler/intersection_handler.h b/AutonomousMode/IntersectionHandler/intersection_handler.h similarity index 100% rename from IntersectionHandler/intersection_handler.h rename to AutonomousMode/IntersectionHandler/intersection_handler.h diff --git a/Processing/CMakeLists.txt b/AutonomousMode/Processing/CMakeLists.txt similarity index 100% rename from Processing/CMakeLists.txt rename to AutonomousMode/Processing/CMakeLists.txt diff --git a/Processing/processing.cpp b/AutonomousMode/Processing/processing.cpp similarity index 100% rename from Processing/processing.cpp rename to AutonomousMode/Processing/processing.cpp diff --git a/Processing/processing.h b/AutonomousMode/Processing/processing.h similarity index 100% rename from Processing/processing.h rename to AutonomousMode/Processing/processing.h diff --git a/Spielwiese/CMakeLists.txt b/AutonomousMode/Spielwiese/CMakeLists.txt similarity index 100% rename from Spielwiese/CMakeLists.txt rename to AutonomousMode/Spielwiese/CMakeLists.txt diff --git a/Spielwiese/spielwiese.cpp b/AutonomousMode/Spielwiese/spielwiese.cpp similarity index 100% rename from Spielwiese/spielwiese.cpp rename to AutonomousMode/Spielwiese/spielwiese.cpp diff --git a/Test_data/image1.jpeg b/AutonomousMode/Test_data/image1.jpeg similarity index 100% rename from Test_data/image1.jpeg rename to AutonomousMode/Test_data/image1.jpeg diff --git a/Test_data/image10.jpeg b/AutonomousMode/Test_data/image10.jpeg similarity index 100% rename from Test_data/image10.jpeg rename to AutonomousMode/Test_data/image10.jpeg diff --git a/Test_data/image11.jpeg b/AutonomousMode/Test_data/image11.jpeg similarity index 100% rename from Test_data/image11.jpeg rename to AutonomousMode/Test_data/image11.jpeg diff --git a/Test_data/image12.jpeg b/AutonomousMode/Test_data/image12.jpeg similarity index 100% rename from Test_data/image12.jpeg rename to AutonomousMode/Test_data/image12.jpeg diff --git a/Test_data/image13.jpeg b/AutonomousMode/Test_data/image13.jpeg similarity index 100% rename from Test_data/image13.jpeg rename to AutonomousMode/Test_data/image13.jpeg diff --git a/Test_data/image14.jpeg b/AutonomousMode/Test_data/image14.jpeg similarity index 100% rename from Test_data/image14.jpeg rename to AutonomousMode/Test_data/image14.jpeg diff --git a/Test_data/image15.jpeg b/AutonomousMode/Test_data/image15.jpeg similarity index 100% rename from Test_data/image15.jpeg rename to AutonomousMode/Test_data/image15.jpeg diff --git a/Test_data/image16.jpeg b/AutonomousMode/Test_data/image16.jpeg similarity index 100% rename from Test_data/image16.jpeg rename to AutonomousMode/Test_data/image16.jpeg diff --git a/Test_data/image17.jpeg b/AutonomousMode/Test_data/image17.jpeg similarity index 100% rename from Test_data/image17.jpeg rename to AutonomousMode/Test_data/image17.jpeg diff --git a/Test_data/image18.jpeg b/AutonomousMode/Test_data/image18.jpeg similarity index 100% rename from Test_data/image18.jpeg rename to AutonomousMode/Test_data/image18.jpeg diff --git a/Test_data/image19.jpeg b/AutonomousMode/Test_data/image19.jpeg similarity index 100% rename from Test_data/image19.jpeg rename to AutonomousMode/Test_data/image19.jpeg diff --git a/Test_data/image2.jpeg b/AutonomousMode/Test_data/image2.jpeg similarity index 100% rename from Test_data/image2.jpeg rename to AutonomousMode/Test_data/image2.jpeg diff --git a/Test_data/image20.jpeg b/AutonomousMode/Test_data/image20.jpeg similarity index 100% rename from Test_data/image20.jpeg rename to AutonomousMode/Test_data/image20.jpeg diff --git a/Test_data/image21.jpeg b/AutonomousMode/Test_data/image21.jpeg similarity index 100% rename from Test_data/image21.jpeg rename to AutonomousMode/Test_data/image21.jpeg diff --git a/Test_data/image22.jpeg b/AutonomousMode/Test_data/image22.jpeg similarity index 100% rename from Test_data/image22.jpeg rename to AutonomousMode/Test_data/image22.jpeg diff --git a/Test_data/image23.jpeg b/AutonomousMode/Test_data/image23.jpeg similarity index 100% rename from Test_data/image23.jpeg rename to AutonomousMode/Test_data/image23.jpeg diff --git a/Test_data/image24.jpeg b/AutonomousMode/Test_data/image24.jpeg similarity index 100% rename from Test_data/image24.jpeg rename to AutonomousMode/Test_data/image24.jpeg diff --git a/Test_data/image25.jpeg b/AutonomousMode/Test_data/image25.jpeg similarity index 100% rename from Test_data/image25.jpeg rename to AutonomousMode/Test_data/image25.jpeg diff --git a/Test_data/image26.jpeg b/AutonomousMode/Test_data/image26.jpeg similarity index 100% rename from Test_data/image26.jpeg rename to AutonomousMode/Test_data/image26.jpeg diff --git a/Test_data/image27.jpeg b/AutonomousMode/Test_data/image27.jpeg similarity index 100% rename from Test_data/image27.jpeg rename to AutonomousMode/Test_data/image27.jpeg diff --git a/Test_data/image28.jpeg b/AutonomousMode/Test_data/image28.jpeg similarity index 100% rename from Test_data/image28.jpeg rename to AutonomousMode/Test_data/image28.jpeg diff --git a/Test_data/image3.jpeg b/AutonomousMode/Test_data/image3.jpeg similarity index 100% rename from Test_data/image3.jpeg rename to AutonomousMode/Test_data/image3.jpeg diff --git a/Test_data/image4.jpeg b/AutonomousMode/Test_data/image4.jpeg similarity index 100% rename from Test_data/image4.jpeg rename to AutonomousMode/Test_data/image4.jpeg diff --git a/Test_data/image5.jpeg b/AutonomousMode/Test_data/image5.jpeg similarity index 100% rename from Test_data/image5.jpeg rename to AutonomousMode/Test_data/image5.jpeg diff --git a/Test_data/image6.jpeg b/AutonomousMode/Test_data/image6.jpeg similarity index 100% rename from Test_data/image6.jpeg rename to AutonomousMode/Test_data/image6.jpeg diff --git a/Test_data/image7.jpeg b/AutonomousMode/Test_data/image7.jpeg similarity index 100% rename from Test_data/image7.jpeg rename to AutonomousMode/Test_data/image7.jpeg diff --git a/Test_data/image8.jpeg b/AutonomousMode/Test_data/image8.jpeg similarity index 100% rename from Test_data/image8.jpeg rename to AutonomousMode/Test_data/image8.jpeg diff --git a/Test_data/image9.jpeg b/AutonomousMode/Test_data/image9.jpeg similarity index 100% rename from Test_data/image9.jpeg rename to AutonomousMode/Test_data/image9.jpeg diff --git a/Utils/CMakeLists.txt b/AutonomousMode/Utils/CMakeLists.txt similarity index 100% rename from Utils/CMakeLists.txt rename to AutonomousMode/Utils/CMakeLists.txt diff --git a/Utils/utils.cpp b/AutonomousMode/Utils/utils.cpp similarity index 100% rename from Utils/utils.cpp rename to AutonomousMode/Utils/utils.cpp diff --git a/Utils/utils.h b/AutonomousMode/Utils/utils.h similarity index 100% rename from Utils/utils.h rename to AutonomousMode/Utils/utils.h diff --git a/autonomous_mode_main.cpp b/AutonomousMode/autonomous_mode_main.cpp similarity index 100% rename from autonomous_mode_main.cpp rename to AutonomousMode/autonomous_mode_main.cpp diff --git a/lfr.cpp b/AutonomousMode/lfr.cpp similarity index 100% rename from lfr.cpp rename to AutonomousMode/lfr.cpp diff --git a/lfr.h b/AutonomousMode/lfr.h similarity index 100% rename from lfr.h rename to AutonomousMode/lfr.h diff --git a/Communication/CMakeLists.txt b/Communication/CMakeLists.txt new file mode 100644 index 0000000..e33619d --- /dev/null +++ b/Communication/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.1.0) +project(lfr_uart VERSION 0.1.0) + +include(CTest) +enable_testing() + +set(THREADS_PREFER_PTHREAD_FLAG ON) + +find_package(Threads REQUIRED) + +add_executable(lfr_uart uart_communication.cpp) + +target_link_libraries( lfr_uart Threads::Threads) + +set(CPACK_PROJECT_NAME ${PROJECT_NAME}) +set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) +include(CPack) diff --git a/Communication/uart_communication.cpp b/Communication/uart_communication.cpp new file mode 100644 index 0000000..3a1fa65 --- /dev/null +++ b/Communication/uart_communication.cpp @@ -0,0 +1,152 @@ +#include "uart_communication.h" + + +LFR_UART::LFR_UART() : fileDescriptor(-1) { + this->openSerialPort(); + this->configureSerialPort(); +} +LFR_UART::~LFR_UART() { + this->closeSerialPort(); +} + +void LFR_UART::openFile(const char *fileName) { + this->fileDescriptor = open(fileName, O_RDWR | O_NONBLOCK); +} + +int LFR_UART::writeDataToFile(uint8_t *buff, uint32_t bufferLength) { + return write(this->fileDescriptor, buff, bufferLength); +} + +int LFR_UART::readFromFile(uint8_t *buff, uint32_t bufferLength) { + return read(this->fileDescriptor, buff, bufferLength); +} + +int LFR_UART::closeFile() { + return close(this->fileDescriptor); +} + +uint8_t LFR_UART::doubleToByte(double in){ + /* + * Map the range of -1.0 to 1.0 as double to the range of a byte. + * + * -1 -> 0 + * 0.0 -> 127 + * 1.0 -> 254 + * Not using the full range upto 254 to hit the 0.0 + */ + double minDouble = -1.0; + double maxDouble = 1.0; + double rangeDouble = maxDouble - minDouble; + + double minByte = 0.0; + double maxByte = 255.0; + double rangeByte = maxByte - minByte; + + double progress = in - minDouble; + double progressPercent = progress/rangeDouble; + + double inputInByteRange = minByte + progressPercent*rangeByte; + return uint8_t(inputInByteRange); +} + +double LFR_UART::byteToDouble(uint8_t in){ + double minDouble = -1.0; + double maxDouble = 1.0; + double rangeDouble = maxDouble - minDouble; + + double minByte = 0.0; + double maxByte = 255.0; + double rangeByte = maxByte - minByte; + + double progress = double(in) - minByte; + double progressPercent = progress/rangeByte; + + double inputInDoubleRange = minDouble + progressPercent*rangeDouble; + return inputInDoubleRange; +} + +void LFR_UART::sendTelegram(double wheel1, double wheel2, double wheel3, double wheel4){ + if(wheel1 > 1.0 || wheel2 > 1.0 || wheel3 > 1.0 || wheel4 > 1.0){ + throw CommunicatorException("Wheel value must not be greater than 1.0"); + } + if(wheel1 < -1.0 || wheel2 < -1.0 || wheel3 < -1.0 || wheel4 < -1.0){ + throw CommunicatorException("Wheel value must not be smaller than -1.0"); + } + + uint8_t wheel1B = this->doubleToByte(wheel1); + uint8_t wheel2B = this->doubleToByte(wheel2); + uint8_t wheel3B = this->doubleToByte(wheel3); + uint8_t wheel4B = this->doubleToByte(wheel4); + + uint8_t checksum = wheel1B^wheel2B^wheel3B^wheel4B; + + uint8_t telegram_buffer[5] = {wheel1B, wheel2B, wheel3B, wheel4B, checksum}; + uint32_t telegram_length = 5; + this->writeDataToFile(telegram_buffer, telegram_length); +} + +bool LFR_UART::readTelegram(double* buffer){ + uint8_t tmp_buffer[5] = {0, 0, 0, 0, 0}; + uint32_t telegram_length = 5; + this->readFromFile(tmp_buffer, telegram_length); + + //std::cout << "Read from file: " << std::bitset<8>(tmp_buffer[0]) << ", " << std::bitset<8>(tmp_buffer[1]) << ", " << std::bitset<8>(tmp_buffer[2]) << ", " << std::bitset<8>(tmp_buffer[3]) << ", " << std::bitset<8>(tmp_buffer[4]) << std::endl; + + if (std::bitset<8>(tmp_buffer[0]^tmp_buffer[1]^tmp_buffer[2]^tmp_buffer[3]) != std::bitset<8>(tmp_buffer[4])){ + return false; + } + else { + buffer[0] = this->byteToDouble(tmp_buffer[0]); + buffer[1] = this->byteToDouble(tmp_buffer[1]); + buffer[2] = this->byteToDouble(tmp_buffer[2]); + buffer[3] = this->byteToDouble(tmp_buffer[3]); + } + return true; +} + +void LFR_UART::openSerialPort() { + openFile(this->serialPortPath); + if(this->fileDescriptor < 0) { + throw CommunicatorException("LFR_UART couldn't open the serial port."); + exit(EXIT_FAILURE); + } +} + +void LFR_UART::configureSerialPort() { + if(tcgetattr(this->fileDescriptor, &this->tty)) { + throw CommunicatorException("LFR_UART couldn't get the port attributes."); + exit(EXIT_FAILURE); + } + + cfsetispeed(&this->tty,B115200); + cfsetospeed(&this->tty,B115200); + + cfmakeraw(&this->tty); + + if(tcsetattr(this->fileDescriptor,TCSANOW,&this->tty)) { + throw CommunicatorException("LFR_UART couldn't set the port attributes."); + exit(EXIT_FAILURE); + } +} + +void LFR_UART::closeSerialPort() { + this->closeFile(); +} + +int main(void) { + printf("Starting the loopback application...\r\n"); + + LFR_UART uartCommunicator; + uartCommunicator.sendTelegram(-1.0, -0.99, 0.99, 1.0); + double buffer[4] = {0.0, 0.0, 0.0, 0.0}; + sleep(1); + if(uartCommunicator.readTelegram(buffer)){ + for(int i = 0; i < 4; i++) { + std::cout << buffer[i] << " "; + } + } + else { + std::cout<<"ne"; + } + return 0; +} diff --git a/Communication/uart_communication.h b/Communication/uart_communication.h new file mode 100644 index 0000000..64786e5 --- /dev/null +++ b/Communication/uart_communication.h @@ -0,0 +1,56 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +class LFR_UART +{ + int fileDescriptor; + const char* serialPortPath = "/dev/ttyS0"; + + void openFile(const char *fileName); + int closeFile(); + + struct termios tty; + + void openSerialPort(); + void configureSerialPort(); + void closeSerialPort(); + + int writeDataToFile(uint8_t *buff, uint32_t bufferLength); + int readFromFile(uint8_t *buff, uint32_t bufferLength); + +public: + + uint8_t doubleToByte(double in); + double byteToDouble(uint8_t in); + + void sendTelegram(double wheel1, double wheel2, double wheel3, double wheel4); + bool readTelegram(double* buffer); + + LFR_UART(); + ~LFR_UART(); + +}; + +class CommunicatorException: public std::exception +{ + const char* msg; +public: + CommunicatorException(const char* msg): msg(msg) {} + virtual const char* what() const throw() + { + return msg; + } +};