mirror of https://github.com/EspoTek/Labrador.git
Supports odd and even parity
This commit is contained in:
parent
eb57b2c327
commit
2b5ce2ecc4
|
@ -1,6 +1,5 @@
|
|||
#include "isobuffer.h"
|
||||
#include "isodriver.h"
|
||||
|
||||
#include "uartstyledecoder.h"
|
||||
|
||||
isoBuffer::isoBuffer(QWidget *parent, int bufferLen, isoDriver *caller, unsigned char channel_value) : QWidget(parent)
|
||||
|
@ -371,7 +370,7 @@ int isoBuffer::cap_x2fromLast(double seconds, int x1, double vtop){
|
|||
return -1;
|
||||
}
|
||||
|
||||
void isoBuffer::serialManage(double baudRate, int type){
|
||||
void isoBuffer::serialManage(double baudRate, int type, UartParity parity){
|
||||
//Types:
|
||||
// 0 - standard UART, no parity
|
||||
// 1 - standard UART, with parity bit
|
||||
|
@ -384,6 +383,7 @@ void isoBuffer::serialManage(double baudRate, int type){
|
|||
decoder->updateTimer->start(CONSOLE_UPDATE_TIMER_PERIOD);
|
||||
stopDecoding = false;
|
||||
}
|
||||
decoder->setParityMode(parity);
|
||||
decoder->serialDecode(baudRate);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
#include "isobufferbuffer.h"
|
||||
#include "genericusbdriver.h"
|
||||
|
||||
|
||||
class isoDriver;
|
||||
class uartStyleDecoder;
|
||||
enum class UartParity : uint8_t;
|
||||
|
||||
//isoBuffer is a generic class that enables O(1) read times (!!!) on all read/write operations, while maintaining a huge buffer size.
|
||||
//Imagine it as a circular buffer, but with access functions specifically designed for isochronous data from an Xmega.
|
||||
|
@ -42,7 +42,7 @@ public:
|
|||
int cap_x0fromLast(double seconds, double vbot);
|
||||
int cap_x1fromLast(double seconds, int x0, double vbot);
|
||||
int cap_x2fromLast(double seconds, int x1, double vtop);
|
||||
void serialManage(double baudRate, int type);
|
||||
void serialManage(double baudRate, int type, UartParity parity);
|
||||
//Generic Vars
|
||||
QPlainTextEdit *console1, *console2;
|
||||
bool serialAutoScroll = true;
|
||||
|
|
|
@ -93,7 +93,7 @@ void isoDriver::timerTick(void){
|
|||
internalBuffer375_CH2->channel = 1;
|
||||
frameActionGeneric(1,2);
|
||||
if(serialDecodeEnabled_CH1 && serialType == 0){
|
||||
internalBuffer375_CH2->serialManage(baudRate_CH1, 0);
|
||||
internalBuffer375_CH2->serialManage(baudRate_CH1, 0, parity_CH1);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
|
@ -110,7 +110,7 @@ void isoDriver::timerTick(void){
|
|||
|
||||
frameActionGeneric(2,0);
|
||||
if(serialDecodeEnabled_CH1 && serialType == 0){
|
||||
internalBuffer375_CH1->serialManage(baudRate_CH1, 0);
|
||||
internalBuffer375_CH1->serialManage(baudRate_CH1, 0, parity_CH1);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
|
@ -122,10 +122,10 @@ void isoDriver::timerTick(void){
|
|||
internalBuffer375_CH2->channel = 2;
|
||||
frameActionGeneric(2,2);
|
||||
if(serialDecodeEnabled_CH1 && serialType == 0){
|
||||
internalBuffer375_CH1->serialManage(baudRate_CH1, 0);
|
||||
internalBuffer375_CH1->serialManage(baudRate_CH1, 0, parity_CH1);
|
||||
}
|
||||
if(serialDecodeEnabled_CH2 && serialType == 0){
|
||||
internalBuffer375_CH2->serialManage(baudRate_CH2, 0);
|
||||
internalBuffer375_CH2->serialManage(baudRate_CH2, 0, parity_CH2);
|
||||
}
|
||||
if (serialDecodeEnabled_CH1 && serialType == 1)
|
||||
{
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "desktop_settings.h"
|
||||
#include "siprint.h"
|
||||
#include "i2cdecoder.h"
|
||||
#include "uartstyledecoder.h"
|
||||
|
||||
class isoBuffer;
|
||||
class isoBuffer_file;
|
||||
|
@ -34,6 +35,8 @@ public:
|
|||
bool doNotTouchGraph = true;
|
||||
double ch1_ref = 1.65, ch2_ref = 1.65;
|
||||
double frontendGain_CH1 = (R4/(R3+R4)), frontendGain_CH2 = (R4/(R3+R4));
|
||||
UartParity parity_CH1 = UartParity::None;
|
||||
UartParity parity_CH2 = UartParity::None;
|
||||
//State Vars
|
||||
bool AC_CH1 = false, AC_CH2 = false;
|
||||
bool cursorStatsEnabled = true;
|
||||
|
|
|
@ -319,7 +319,7 @@ void MainWindow::menuSetup(){
|
|||
gainGroup->addAction(ui->actionGain16);
|
||||
gainGroup->addAction(ui->actionGain32);
|
||||
gainGroup->addAction(ui->actionGain64);
|
||||
ui->actionGainAuto->setChecked(1);
|
||||
ui->actionGainAuto->setChecked(true);
|
||||
|
||||
rangeGroupV = new QActionGroup(this);
|
||||
rangeGroupV->addAction(ui->actionAutoV);
|
||||
|
@ -381,7 +381,7 @@ void MainWindow::menuSetup(){
|
|||
uartBaudGroup_CH1->addAction(ui->action38400);
|
||||
uartBaudGroup_CH1->addAction(ui->action57600);
|
||||
uartBaudGroup_CH1->addAction(ui->action115200);
|
||||
ui->action9600->setChecked(1);
|
||||
ui->action9600->setChecked(true);
|
||||
|
||||
uartBaudGroup_CH2 = new QActionGroup(this);
|
||||
uartBaudGroup_CH2->addAction(ui->action300_2);
|
||||
|
@ -396,13 +396,25 @@ void MainWindow::menuSetup(){
|
|||
uartBaudGroup_CH2->addAction(ui->action38400_2);
|
||||
uartBaudGroup_CH2->addAction(ui->action57600_2);
|
||||
uartBaudGroup_CH2->addAction(ui->action115200_2);
|
||||
ui->action9600_2->setChecked(1);
|
||||
ui->action9600_2->setChecked(true);
|
||||
|
||||
uartParityGroup_CH1 = new QActionGroup(this);
|
||||
uartParityGroup_CH1->addAction(ui->actionNone);
|
||||
uartParityGroup_CH1->addAction(ui->actionEven);
|
||||
uartParityGroup_CH1->addAction(ui->actionOdd);
|
||||
ui->actionNone->setChecked(true);
|
||||
|
||||
uartParityGroup_CH2 = new QActionGroup(this);
|
||||
uartParityGroup_CH2->addAction(ui->actionNone_2);
|
||||
uartParityGroup_CH2->addAction(ui->actionEven_2);
|
||||
uartParityGroup_CH2->addAction(ui->actionOdd_2);
|
||||
ui->actionNone_2->setChecked(true);
|
||||
|
||||
connectionTypeGroup = new QActionGroup(this);
|
||||
connectionTypeGroup->addAction(ui->actionLo_bw);
|
||||
connectionTypeGroup->addAction(ui->actionSingle_ep_msync);
|
||||
connectionTypeGroup->addAction(ui->actionSingle_ep_async);
|
||||
ui->actionLo_bw->setChecked(1);
|
||||
ui->actionLo_bw->setChecked(true);
|
||||
expected_variant = 1; //for default Lo_bw mode;
|
||||
|
||||
ui->actionLo_bw->setVisible(false);
|
||||
|
@ -690,51 +702,51 @@ void MainWindow::cycleBaudRate_CH1(){
|
|||
QAction *currentAction = uartBaudGroup_CH1->checkedAction();
|
||||
qDebug() << currentAction;
|
||||
if(currentAction==ui->action300){
|
||||
ui->action600->setChecked(1);
|
||||
ui->action600->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action600){
|
||||
ui->action1200->setChecked(1);
|
||||
ui->action1200->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action1200){
|
||||
ui->action2400->setChecked(1);
|
||||
ui->action2400->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action2400){
|
||||
ui->action4800->setChecked(1);
|
||||
ui->action4800->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action4800){
|
||||
ui->action9600->setChecked(1);
|
||||
ui->action9600->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action9600){
|
||||
ui->action14400->setChecked(1);
|
||||
ui->action14400->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action14400){
|
||||
ui->action19200->setChecked(1);
|
||||
ui->action19200->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action19200){
|
||||
ui->action28800->setChecked(1);
|
||||
ui->action28800->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action28800){
|
||||
ui->action38400->setChecked(1);
|
||||
ui->action38400->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action38400){
|
||||
ui->action57600->setChecked(1);
|
||||
ui->action57600->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action57600){
|
||||
ui->action115200->setChecked(1);
|
||||
ui->action115200->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action115200){
|
||||
ui->action300->setChecked(1);
|
||||
ui->action300->setChecked(true);
|
||||
return;
|
||||
}
|
||||
qFatal("Invalid state in MainWindow::cycleBaudRate_CH1()");
|
||||
|
@ -744,51 +756,51 @@ void MainWindow::cycleBaudRateBackwards_CH1(){
|
|||
QAction *currentAction = uartBaudGroup_CH1->checkedAction();
|
||||
qDebug() << currentAction;
|
||||
if(currentAction==ui->action1200){
|
||||
ui->action600->setChecked(1);
|
||||
ui->action600->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action2400){
|
||||
ui->action1200->setChecked(1);
|
||||
ui->action1200->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action4800){
|
||||
ui->action2400->setChecked(1);
|
||||
ui->action2400->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action9600){
|
||||
ui->action4800->setChecked(1);
|
||||
ui->action4800->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action14400){
|
||||
ui->action9600->setChecked(1);
|
||||
ui->action9600->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action19200){
|
||||
ui->action14400->setChecked(1);
|
||||
ui->action14400->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action28800){
|
||||
ui->action19200->setChecked(1);
|
||||
ui->action19200->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action38400){
|
||||
ui->action28800->setChecked(1);
|
||||
ui->action28800->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action57600){
|
||||
ui->action38400->setChecked(1);
|
||||
ui->action38400->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action115200){
|
||||
ui->action57600->setChecked(1);
|
||||
ui->action57600->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action300){
|
||||
ui->action115200->setChecked(1);
|
||||
ui->action115200->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action600){
|
||||
ui->action300->setChecked(1);
|
||||
ui->action300->setChecked(true);
|
||||
return;
|
||||
}
|
||||
qFatal("Invalid state in MainWindow::cycleBaudRateBackwards_CH1()");
|
||||
|
@ -798,51 +810,51 @@ void MainWindow::cycleBaudRate_CH2(){
|
|||
QAction *currentAction = uartBaudGroup_CH2->checkedAction();
|
||||
qDebug() << currentAction;
|
||||
if(currentAction==ui->action300_2){
|
||||
ui->action600_2->setChecked(1);
|
||||
ui->action600_2->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action600_2){
|
||||
ui->action1200_2->setChecked(1);
|
||||
ui->action1200_2->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action1200_2){
|
||||
ui->action2400_2->setChecked(1);
|
||||
ui->action2400_2->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action2400_2){
|
||||
ui->action4800_2->setChecked(1);
|
||||
ui->action4800_2->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action4800_2){
|
||||
ui->action9600_2->setChecked(1);
|
||||
ui->action9600_2->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action9600_2){
|
||||
ui->action14400_2->setChecked(1);
|
||||
ui->action14400_2->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action14400_2){
|
||||
ui->action19200_2->setChecked(1);
|
||||
ui->action19200_2->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action19200_2){
|
||||
ui->action28800_2->setChecked(1);
|
||||
ui->action28800_2->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action28800_2){
|
||||
ui->action38400_2->setChecked(1);
|
||||
ui->action38400_2->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action38400_2){
|
||||
ui->action57600_2->setChecked(1);
|
||||
ui->action57600_2->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action57600_2){
|
||||
ui->action115200_2->setChecked(1);
|
||||
ui->action115200_2->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action115200_2){
|
||||
ui->action300_2->setChecked(1);
|
||||
ui->action300_2->setChecked(true);
|
||||
return;
|
||||
}
|
||||
qFatal("Invalid state in MainWindow::cycleBaudRate_CH2()");
|
||||
|
@ -852,51 +864,51 @@ void MainWindow::cycleBaudRateBackwards_CH2(){
|
|||
QAction *currentAction = uartBaudGroup_CH2->checkedAction();
|
||||
qDebug() << currentAction;
|
||||
if(currentAction==ui->action1200_2){
|
||||
ui->action600_2->setChecked(1);
|
||||
ui->action600_2->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action2400_2){
|
||||
ui->action1200_2->setChecked(1);
|
||||
ui->action1200_2->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action4800_2){
|
||||
ui->action2400_2->setChecked(1);
|
||||
ui->action2400_2->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action9600_2){
|
||||
ui->action4800_2->setChecked(1);
|
||||
ui->action4800_2->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action14400_2){
|
||||
ui->action9600_2->setChecked(1);
|
||||
ui->action9600_2->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action19200_2){
|
||||
ui->action14400_2->setChecked(1);
|
||||
ui->action14400_2->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action28800_2){
|
||||
ui->action19200_2->setChecked(1);
|
||||
ui->action19200_2->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action38400_2){
|
||||
ui->action28800_2->setChecked(1);
|
||||
ui->action28800_2->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action57600_2){
|
||||
ui->action38400_2->setChecked(1);
|
||||
ui->action38400_2->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action115200_2){
|
||||
ui->action57600_2->setChecked(1);
|
||||
ui->action57600_2->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action300_2){
|
||||
ui->action115200_2->setChecked(1);
|
||||
ui->action115200_2->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if(currentAction==ui->action600_2){
|
||||
ui->action300_2->setChecked(1);
|
||||
ui->action300_2->setChecked(true);
|
||||
return;
|
||||
}
|
||||
qFatal("Invalid state in MainWindow::cycleBaudRateBackwards_CH2()");
|
||||
|
@ -1174,15 +1186,15 @@ void MainWindow::readSettingsFile(){
|
|||
//Change connection Type
|
||||
switch(connectionType){
|
||||
case 0:
|
||||
ui->actionLo_bw->setChecked(1);
|
||||
ui->actionLo_bw->setChecked(true);
|
||||
on_actionLo_bw_triggered();
|
||||
break;
|
||||
case 1:
|
||||
ui->actionSingle_ep_msync->setChecked(1);
|
||||
ui->actionSingle_ep_msync->setChecked(true);
|
||||
on_actionSingle_ep_msync_triggered();
|
||||
break;
|
||||
case 2:
|
||||
ui->actionSingle_ep_async->setChecked(1);
|
||||
ui->actionSingle_ep_async->setChecked(true);
|
||||
on_actionSingle_ep_async_triggered();
|
||||
break;
|
||||
}
|
||||
|
@ -1930,7 +1942,7 @@ void MainWindow::on_actionRecord_CH1_triggered(bool checked)
|
|||
|
||||
#ifndef PLATFORM_ANDROID
|
||||
if(len==0){
|
||||
ui->actionRecord_CH1->setChecked(0);
|
||||
ui->actionRecord_CH1->setChecked(false);
|
||||
return; //User cancelled
|
||||
}
|
||||
#endif
|
||||
|
@ -1962,7 +1974,7 @@ void MainWindow::on_actionRecord_CH2_triggered(bool checked)
|
|||
|
||||
#ifndef PLATFORM_ANDROID
|
||||
if(len==0){
|
||||
ui->actionRecord_CH2->setChecked(0);
|
||||
ui->actionRecord_CH2->setChecked(false);
|
||||
return; //User cancelled
|
||||
}
|
||||
#endif
|
||||
|
@ -2030,7 +2042,7 @@ void MainWindow::on_actionDAQ_Settings_triggered()
|
|||
}
|
||||
|
||||
void MainWindow::fileLimitReached_CH1(void){
|
||||
ui->actionRecord_CH1->setChecked(0);
|
||||
ui->actionRecord_CH1->setChecked(false);
|
||||
|
||||
QMessageBox recordingStoppedMessageBox;
|
||||
char recordingStoppedMessage[256];
|
||||
|
@ -2040,7 +2052,7 @@ void MainWindow::fileLimitReached_CH1(void){
|
|||
}
|
||||
|
||||
void MainWindow::fileLimitReached_CH2(void){
|
||||
ui->actionRecord_CH2->setChecked(0);
|
||||
ui->actionRecord_CH2->setChecked(false);
|
||||
|
||||
QMessageBox recordingStoppedMessageBox;
|
||||
char recordingStoppedMessage[256];
|
||||
|
@ -2275,3 +2287,33 @@ void MainWindow::paused(bool enabled)
|
|||
ui->hideCH2Box->setChecked(false);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionNone_triggered()
|
||||
{
|
||||
ui->controller_iso->parity_CH1 = UartParity::None;
|
||||
}
|
||||
|
||||
void MainWindow::on_actionEven_triggered()
|
||||
{
|
||||
ui->controller_iso->parity_CH1 = UartParity::Even;
|
||||
}
|
||||
|
||||
void MainWindow::on_actionOdd_triggered()
|
||||
{
|
||||
ui->controller_iso->parity_CH1 = UartParity::Odd;
|
||||
}
|
||||
|
||||
void MainWindow::on_actionNone_2_triggered()
|
||||
{
|
||||
ui->controller_iso->parity_CH2 = UartParity::None;
|
||||
}
|
||||
|
||||
void MainWindow::on_actionEven_2_triggered()
|
||||
{
|
||||
ui->controller_iso->parity_CH2 = UartParity::Even;
|
||||
}
|
||||
|
||||
void MainWindow::on_actionOdd_2_triggered()
|
||||
{
|
||||
ui->controller_iso->parity_CH2 = UartParity::Odd;
|
||||
}
|
||||
|
|
|
@ -197,6 +197,18 @@ private slots:
|
|||
|
||||
void paused(bool enabled);
|
||||
|
||||
void on_actionNone_triggered();
|
||||
|
||||
void on_actionNone_2_triggered();
|
||||
|
||||
void on_actionEven_triggered();
|
||||
|
||||
void on_actionOdd_triggered();
|
||||
|
||||
void on_actionEven_2_triggered();
|
||||
|
||||
void on_actionOdd_2_triggered();
|
||||
|
||||
private:
|
||||
//Generic Vars
|
||||
Ui::MainWindow *ui;
|
||||
|
@ -233,6 +245,8 @@ private:
|
|||
QActionGroup *rangeGroupC;
|
||||
QActionGroup *uartBaudGroup_CH1;
|
||||
QActionGroup *uartBaudGroup_CH2;
|
||||
QActionGroup *uartParityGroup_CH1;
|
||||
QActionGroup *uartParityGroup_CH2;
|
||||
QActionGroup *fpsGroup;
|
||||
QActionGroup *connectionTypeGroup;
|
||||
QActionGroup *serialProtocolGroup;
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
/****************************************************************************
|
||||
** Resource object code
|
||||
**
|
||||
** Created by: The Resource Compiler for Qt version 5.5.1
|
||||
** Created by: The Resource Compiler for Qt version 5.9.4
|
||||
**
|
||||
** WARNING! All changes made in this file will be lost!
|
||||
*****************************************************************************/
|
||||
|
||||
static const unsigned char qt_resource_data[] = {
|
||||
// /home/espobuntux86/git/labrador/Desktop_Interface/buffer_0.bmp
|
||||
// /home/esposch/git/labrador/Desktop_Interface/buffer_0.bmp
|
||||
0x0,0x0,0x0,0x8d,
|
||||
0x0,
|
||||
0x0,0x28,0xb6,0x78,0x9c,0xed,0xd0,0xb1,0xd,0xc2,0x30,0x0,0x45,0xc1,0xb0,0x45,
|
||||
|
@ -19,7 +19,7 @@ static const unsigned char qt_resource_data[] = {
|
|||
0xab,0x8f,0xd5,0xc7,0xea,0x63,0xf5,0xb1,0xfa,0x58,0x7d,0xac,0x3e,0x56,0x1f,0xab,
|
||||
0x8f,0xd5,0xc7,0xea,0x63,0xf5,0xb1,0xfa,0x58,0x7d,0xac,0x3e,0x56,0x1f,0xab,0x8f,
|
||||
0xd5,0xc7,0xea,0x63,0x73,0xf6,0xf9,0x2,0xf4,0x4,0x42,0xe7,
|
||||
// /home/espobuntux86/git/labrador/Desktop_Interface/buffer_2.bmp
|
||||
// /home/esposch/git/labrador/Desktop_Interface/buffer_2.bmp
|
||||
0x0,0x0,0x0,0x7b,
|
||||
0x0,
|
||||
0x0,0x28,0xb6,0x78,0x9c,0xed,0xd0,0x31,0xd,0x80,0x30,0x14,0x45,0xd1,0xe2,0x82,
|
||||
|
@ -30,7 +30,7 @@ static const unsigned char qt_resource_data[] = {
|
|||
0x3e,0x99,0xf1,0xe1,0xc3,0x87,0xf,0x9f,0xcc,0xf8,0xf0,0xe1,0xc3,0x87,0x4f,0x66,
|
||||
0x7c,0xf8,0xf0,0xe1,0xc3,0x27,0x33,0x3e,0x7c,0xf8,0xf0,0xe1,0x93,0x19,0x1f,0x3e,
|
||||
0x7c,0xf8,0xf0,0x19,0x7b,0x1,0x6d,0x5a,0xf,0xce,
|
||||
// /home/espobuntux86/git/labrador/Desktop_Interface/buffer_1.bmp
|
||||
// /home/esposch/git/labrador/Desktop_Interface/buffer_1.bmp
|
||||
0x0,0x0,0x0,0x97,
|
||||
0x0,
|
||||
0x0,0x28,0xb6,0x78,0x9c,0xed,0xd0,0xb1,0xd,0xc2,0x30,0x10,0x40,0xd1,0xb0,0x5,
|
||||
|
@ -73,14 +73,19 @@ static const unsigned char qt_resource_name[] = {
|
|||
static const unsigned char qt_resource_struct[] = {
|
||||
// :
|
||||
0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x1,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
// :/bitmap
|
||||
0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x3,0x0,0x0,0x0,0x2,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
// :/bitmap/buffer_2.bmp
|
||||
0x0,0x0,0x0,0x30,0x0,0x1,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x91,
|
||||
0x0,0x0,0x1,0x66,0xe3,0x22,0x5,0x34,
|
||||
// :/bitmap/buffer_0.bmp
|
||||
0x0,0x0,0x0,0x12,0x0,0x1,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x1,0x66,0xe3,0x22,0x5,0x34,
|
||||
// :/bitmap/buffer_1.bmp
|
||||
0x0,0x0,0x0,0x4e,0x0,0x1,0x0,0x0,0x0,0x1,0x0,0x0,0x1,0x10,
|
||||
0x0,0x0,0x1,0x66,0xe3,0x22,0x5,0x34,
|
||||
|
||||
};
|
||||
|
||||
|
@ -112,7 +117,7 @@ int QT_RCC_MANGLE_NAMESPACE(qInitResources_resources)();
|
|||
int QT_RCC_MANGLE_NAMESPACE(qInitResources_resources)()
|
||||
{
|
||||
QT_RCC_PREPEND_NAMESPACE(qRegisterResourceData)
|
||||
(0x01, qt_resource_struct, qt_resource_name, qt_resource_data);
|
||||
(0x2, qt_resource_struct, qt_resource_name, qt_resource_data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -120,7 +125,7 @@ int QT_RCC_MANGLE_NAMESPACE(qCleanupResources_resources)();
|
|||
int QT_RCC_MANGLE_NAMESPACE(qCleanupResources_resources)()
|
||||
{
|
||||
QT_RCC_PREPEND_NAMESPACE(qUnregisterResourceData)
|
||||
(0x01, qt_resource_struct, qt_resource_name, qt_resource_data);
|
||||
(0x2, qt_resource_struct, qt_resource_name, qt_resource_data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#include "uartstyledecoder.h"
|
||||
#include <QDebug>
|
||||
#include <cassert>
|
||||
|
||||
uartStyleDecoder::uartStyleDecoder(QObject *parent_in) : QObject(parent_in)
|
||||
{
|
||||
|
@ -52,24 +54,29 @@ void uartStyleDecoder::serialDecode(double baudRate)
|
|||
double dist_seconds = (double)serialDistance()/(parent->sampleRate_bit);
|
||||
double bitPeriod_seconds = 1/baudRate;
|
||||
|
||||
//Used to check for wire disconnects. You should get at least one "1" for a stop bit.
|
||||
// Used to check for wire disconnects. You should get at least one "1" for a stop bit.
|
||||
bool allZeroes = true;
|
||||
|
||||
while(dist_seconds > (bitPeriod_seconds + SERIAL_DELAY)){
|
||||
//Read next uart bit
|
||||
// Read next uart bit
|
||||
unsigned char uart_bit = getNextUartBit();
|
||||
if(uart_bit) allZeroes = false;
|
||||
|
||||
//Process it
|
||||
if(uartTransmitting){
|
||||
if (uart_bit == 1)
|
||||
allZeroes = false;
|
||||
|
||||
// Process it
|
||||
if (uartTransmitting)
|
||||
{
|
||||
decodeNextUartBit(uart_bit);
|
||||
} else{
|
||||
uartTransmitting = (uart_bit == 1) ? false : true; //Uart starts transmitting after start bit (logic low).
|
||||
}
|
||||
else
|
||||
{
|
||||
uartTransmitting = (uart_bit == 1) ? false : true; // Uart starts transmitting after start bit (logic low).
|
||||
jitterCompensationNeeded = true;
|
||||
}
|
||||
//Update the pointer, accounting for jitter
|
||||
// Update the pointer, accounting for jitter
|
||||
updateSerialPtr(baudRate, uart_bit);
|
||||
//Calculate stopping condition
|
||||
// Calculate stopping condition
|
||||
dist_seconds = (double)serialDistance()/(parent->sampleRate_bit);
|
||||
}
|
||||
|
||||
|
@ -117,17 +124,25 @@ unsigned char uartStyleDecoder::getNextUartBit(){
|
|||
|
||||
void uartStyleDecoder::decodeNextUartBit(unsigned char bitValue)
|
||||
{
|
||||
if(dataBit_current == dataBit_max){
|
||||
decodeDatabit(dataBit_max+1);
|
||||
if (dataBit_current == parityIndex)
|
||||
{
|
||||
assert(parity != UartParity::None);
|
||||
performParityCheck();
|
||||
dataBit_current++;
|
||||
}
|
||||
else if (dataBit_current < dataBit_max)
|
||||
{
|
||||
currentUartSymbol |= (bitValue << dataBit_current);
|
||||
dataBit_current++;
|
||||
}
|
||||
else
|
||||
{
|
||||
decodeDatabit(dataBit_max + 1);
|
||||
currentUartSymbol = 0;
|
||||
dataBit_current = 0;
|
||||
uartTransmitting = false;
|
||||
newUartSymbol = true;
|
||||
return;
|
||||
}
|
||||
//else
|
||||
currentUartSymbol |= (bitValue << dataBit_current);
|
||||
dataBit_current++;
|
||||
}
|
||||
|
||||
//This function compensates for jitter by, when the current bit is a "1", and the last bit was a zero, setting the pointer
|
||||
|
@ -165,18 +180,24 @@ bool uartStyleDecoder::jitterCompensationProcedure(double baudRate, unsigned cha
|
|||
return true;
|
||||
}
|
||||
|
||||
//Basically scaffoldingto add character maps for other modes (5 bit, for example).
|
||||
//Basically scaffolding to add character maps for other modes (5 bit, for example).
|
||||
void uartStyleDecoder::decodeDatabit(int mode){
|
||||
char tempchar;
|
||||
switch(mode){
|
||||
case 5:
|
||||
tempchar = decode_baudot(currentUartSymbol);
|
||||
break;
|
||||
case 8: //8-bit ASCII;
|
||||
tempchar = currentUartSymbol;
|
||||
break;
|
||||
default:
|
||||
qDebug() << "uartStyleDecoder::decodeDatabit is failing...";
|
||||
}
|
||||
if (parityCheckFailed)
|
||||
{
|
||||
serialBuffer->add("\n<ERROR: Following character contains parity error>\n");
|
||||
parityCheckFailed = false;
|
||||
}
|
||||
serialBuffer->add(tempchar);
|
||||
}
|
||||
|
||||
|
@ -184,5 +205,50 @@ char uartStyleDecoder::decode_baudot(short symbol){
|
|||
return 'a';
|
||||
}
|
||||
|
||||
void uartStyleDecoder::setParityMode(UartParity newParity)
|
||||
{
|
||||
switch(newParity)
|
||||
{
|
||||
case UartParity::None:
|
||||
parityIndex = UINT_MAX;
|
||||
break;
|
||||
case UartParity::Even:
|
||||
case UartParity::Odd:
|
||||
parityIndex = dataBit_max;
|
||||
}
|
||||
|
||||
parity = newParity;
|
||||
}
|
||||
|
||||
void uartStyleDecoder::performParityCheck()
|
||||
{
|
||||
auto isEvenParity = [=] () -> bool
|
||||
{
|
||||
uint32_t mask = 0x00000001;
|
||||
uint8_t parity = 0;
|
||||
for (int i = 0; i < dataBit_max; i++)
|
||||
{
|
||||
const uint8_t currentBit = (dataBit_current & mask) ? 1 : 0;
|
||||
parity = parity ^ currentBit;
|
||||
mask = mask << 1;
|
||||
}
|
||||
|
||||
return parity == 0;
|
||||
};
|
||||
|
||||
switch(parity)
|
||||
{
|
||||
case UartParity::None:
|
||||
assert(false);
|
||||
return;
|
||||
case UartParity::Even:
|
||||
parityCheckFailed = ! isEvenParity();
|
||||
case UartParity::Odd:
|
||||
parityCheckFailed = isEvenParity();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -5,6 +5,15 @@
|
|||
#include "isobufferbuffer.h"
|
||||
#include "isobuffer.h"
|
||||
#include <mutex>
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
|
||||
enum class UartParity : uint8_t
|
||||
{
|
||||
None,
|
||||
Even,
|
||||
Odd
|
||||
};
|
||||
|
||||
class uartStyleDecoder : public QObject
|
||||
{
|
||||
|
@ -20,7 +29,9 @@ private:
|
|||
int serialPtr_bit;
|
||||
bool uartTransmitting = false;
|
||||
bool newUartSymbol = false;
|
||||
int dataBit_current = 0, dataBit_max = 7;
|
||||
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);
|
||||
|
@ -32,10 +43,14 @@ private:
|
|||
void decodeDatabit(int mode);
|
||||
char decode_baudot(short symbol);
|
||||
std::mutex mutex;
|
||||
UartParity parity = UartParity::None;
|
||||
void performParityCheck();
|
||||
bool parityCheckFailed = false;
|
||||
signals:
|
||||
void wireDisconnected(int);
|
||||
public slots:
|
||||
void updateConsole();
|
||||
void setParityMode(UartParity newParity);
|
||||
};
|
||||
|
||||
#endif // UARTSTYLEDECODER_H
|
||||
|
|
|
@ -1334,7 +1334,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1440</width>
|
||||
<height>30</height>
|
||||
<height>36</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
|
@ -1439,8 +1439,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>147</width>
|
||||
<height>130</height>
|
||||
<width>163</width>
|
||||
<height>150</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
|
@ -1510,6 +1510,8 @@
|
|||
<string>&Parity Bit</string>
|
||||
</property>
|
||||
<addaction name="actionNone"/>
|
||||
<addaction name="actionEven"/>
|
||||
<addaction name="actionOdd"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuData_Bits">
|
||||
<property name="title">
|
||||
|
@ -1518,8 +1520,8 @@
|
|||
<addaction name="action8"/>
|
||||
</widget>
|
||||
<addaction name="menuBaud_Rate"/>
|
||||
<addaction name="menuParity_Bit"/>
|
||||
<addaction name="menuData_Bits"/>
|
||||
<addaction name="menuParity_Bit"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuUART_2">
|
||||
<property name="title">
|
||||
|
@ -1553,6 +1555,8 @@
|
|||
<string>&Parity Bit</string>
|
||||
</property>
|
||||
<addaction name="actionNone_2"/>
|
||||
<addaction name="actionEven_2"/>
|
||||
<addaction name="actionOdd_2"/>
|
||||
</widget>
|
||||
<addaction name="menuBaud_Rate_2"/>
|
||||
<addaction name="menuData_Bits_2"/>
|
||||
|
@ -1940,6 +1944,9 @@
|
|||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&None</string>
|
||||
</property>
|
||||
|
@ -2331,6 +2338,38 @@
|
|||
<string>&Show Range Dialog on Main Page</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEven">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Even</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionOdd">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Odd</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEven_2">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Even</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionOdd_2">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Odd</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
|
|
Loading…
Reference in New Issue