Labrador/Desktop_Interface/uartstyledecoder.h

57 lines
1.4 KiB
C
Raw Normal View History

#ifndef UARTSTYLEDECODER_H
#define UARTSTYLEDECODER_H
#include <QObject>
#include "isobufferbuffer.h"
#include "isobuffer.h"
#include <mutex>
2018-12-11 09:25:14 +00:00
#include <limits.h>
#include <stdint.h>
enum class UartParity : uint8_t
{
None,
Even,
Odd
};
class uartStyleDecoder : public QObject
{
Q_OBJECT
public:
2017-12-23 23:52:01 +00:00
explicit uartStyleDecoder(QObject *parent_in = NULL);
~uartStyleDecoder();
void serialDecode(double baudRate);
int serialDistance();
QTimer *updateTimer;
private:
isoBuffer *parent;
int serialPtr_bit;
bool uartTransmitting = false;
bool newUartSymbol = false;
2018-12-11 09:25:14 +00:00
uint32_t dataBit_current = 0;
uint32_t parityIndex = UINT_MAX;
uint32_t dataBit_max = 7;
unsigned short currentUartSymbol = 0;
bool jitterCompensationNeeded = true;
void updateSerialPtr(double baudRate, unsigned char current_bit);
unsigned char getNextUartBit();
void decodeNextUartBit(unsigned char bitValue);
bool jitterCompensationProcedure(double baudRate, unsigned char current_bit);
QPlainTextEdit *console;
isoBufferBuffer *serialBuffer;
void decodeDatabit(int mode);
char decode_baudot(short symbol);
std::mutex mutex;
2018-12-11 09:25:14 +00:00
UartParity parity = UartParity::None;
void performParityCheck();
bool parityCheckFailed = false;
signals:
void wireDisconnected(int);
public slots:
void updateConsole();
2018-12-11 09:25:14 +00:00
void setParityMode(UartParity newParity);
};
#endif // UARTSTYLEDECODER_H