1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- #pragma once
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <stdint.h>
- #include <errno.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <termios.h>
- #include <iostream>
- #include <exception>
- #include <iostream>
- #include <chrono>
- #include <cmath>
-
- #include <bitset>
-
-
- class LFR_UART
- {
- public:
- std::chrono::milliseconds last;
- 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(int8_t *buff, uint32_t bufferLength);
- int readFromFile(int8_t *buff, uint32_t bufferLength);
-
- public:
-
- int8_t doubleToByte(double in);
- double byteToDouble(int8_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;
- }
- };
|