Hex display on serial decoder

This commit is contained in:
Chris Esposito 2019-06-23 13:26:47 +10:00
parent 398f8252bf
commit 40bed49c25
8 changed files with 68 additions and 17 deletions

View File

@ -336,14 +336,11 @@ int isoBuffer::cap_x2fromLast(double seconds, int x1, double vtop)
return capSample(-x1, kSamplesSeekingCap, seconds, vtop, fX1X2Comp);
}
void isoBuffer::serialManage(double baudRate, UartParity parity)
void isoBuffer::serialManage(double baudRate, UartParity parity, bool hexDisplay)
{
if (m_decoder == NULL)
{
m_decoder = new uartStyleDecoder(baudRate, this);
connect(m_decoder, &uartStyleDecoder::wireDisconnected,
m_virtualParent, &isoDriver::serialNeedsDisabling);
}
if (!m_isDecoding)
{
@ -353,6 +350,7 @@ void isoBuffer::serialManage(double baudRate, UartParity parity)
m_decoder->m_baudRate = baudRate;
m_decoder->setParityMode(parity);
m_decoder->setHexDisplay(hexDisplay);
m_decoder->serialDecode();
}

View File

@ -82,7 +82,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, UartParity parity);
void serialManage(double baudRate, UartParity parity, bool hexDisplay);
void setTriggerType(TriggerType newType);
void setTriggerLevel(double voltageLevel, uint16_t top, bool acCoupled);
double getDelayedTriggerPoint(double delay);

View File

@ -87,7 +87,7 @@ void isoDriver::timerTick(void){
internalBuffer375_CH2->m_channel = 1;
frameActionGeneric(1,2);
if(serialDecodeEnabled_CH1 && serialType == 0){
internalBuffer375_CH2->serialManage(baudRate_CH1, parity_CH1);
internalBuffer375_CH2->serialManage(baudRate_CH1, parity_CH1, hexDisplay_CH1);
}
break;
case 2:
@ -104,7 +104,7 @@ void isoDriver::timerTick(void){
frameActionGeneric(2,0);
if(serialDecodeEnabled_CH1 && serialType == 0){
internalBuffer375_CH1->serialManage(baudRate_CH1, parity_CH1);
internalBuffer375_CH1->serialManage(baudRate_CH1, parity_CH1, hexDisplay_CH1);
}
break;
case 4:
@ -116,10 +116,10 @@ void isoDriver::timerTick(void){
internalBuffer375_CH2->m_channel = 2;
frameActionGeneric(2,2);
if(serialDecodeEnabled_CH1 && serialType == 0){
internalBuffer375_CH1->serialManage(baudRate_CH1, parity_CH1);
internalBuffer375_CH1->serialManage(baudRate_CH1, parity_CH1, hexDisplay_CH1);
}
if(serialDecodeEnabled_CH2 && serialType == 0){
internalBuffer375_CH2->serialManage(baudRate_CH2, parity_CH2);
internalBuffer375_CH2->serialManage(baudRate_CH2, parity_CH2, hexDisplay_CH2);
}
if (serialDecodeEnabled_CH1 && serialType == 1)
{
@ -1493,3 +1493,13 @@ void isoDriver::attenuationChanged_CH2(int attenuationIndex)
throw std::runtime_error("Unknown attenuation index for CH2");
}
}
void isoDriver::setHexDisplay_CH1(bool enabled)
{
hexDisplay_CH1 = enabled;
}
void isoDriver::setHexDisplay_CH2(bool enabled)
{
hexDisplay_CH2 = enabled;
}

View File

@ -121,6 +121,8 @@ private:
bool snapshotEnabled_CH1 = false;
bool snapshotEnabled_CH2 = false;
bool firstFrame = true;
bool hexDisplay_CH1 = false;
bool hexDisplay_CH2 = false;
//Generic Functions
void analogConvert(short *shortPtr, QVector<double> *doublePtr, int TOP, bool AC, int channel);
void digitalConvert(short *shortPtr, QVector<double> *doublePtr);
@ -276,6 +278,8 @@ public slots:
void offsetChanged_CH2(double newOffset);
void attenuationChanged_CH1(int attenuationIndex);
void attenuationChanged_CH2(int attenuationIndex);
void setHexDisplay_CH1(bool enabled);
void setHexDisplay_CH2(bool enabled);
};
#endif // ISODRIVER_H

View File

@ -212,6 +212,9 @@ MainWindow::MainWindow(QWidget *parent) :
connect(ui->hideCH1Box, SIGNAL(toggled(bool)), ui->controller_iso, SLOT(hideCH1(bool)));
connect(ui->hideCH2Box, SIGNAL(toggled(bool)), ui->controller_iso, SLOT(hideCH2(bool)));
connect(ui->actionHexDisplay, &QAction::toggled, ui->controller_iso, &isoDriver::setHexDisplay_CH1);
connect(ui->actionHexDisplay_2, &QAction::toggled, ui->controller_iso, &isoDriver::setHexDisplay_CH2);
ui->hideCH1Box->setVisible(false);
ui->hideCH2Box->setVisible(false);

View File

@ -146,7 +146,15 @@ void uartStyleDecoder::decodeNextUartBit(bool bitValue)
parityCheckFailed = false;
}
m_serialBuffer.insert(decodedDatabit);
if (m_hexDisplay)
{
m_serialBuffer.insert_hex(decodedDatabit);
m_serialBuffer.insert(" ");
}
else
{
m_serialBuffer.insert(decodedDatabit);
}
currentUartSymbol = 0;
dataBit_current = 0;
@ -228,6 +236,11 @@ void uartStyleDecoder::setParityMode(UartParity newParity)
parity = newParity;
}
void uartStyleDecoder::setHexDisplay(bool enabled)
{
m_hexDisplay = enabled;
}
bool uartStyleDecoder::isParityCorrect(uint32_t bitField) const
{
assert(parity != UartParity::None);

View File

@ -42,15 +42,24 @@ private:
void decodeNextUartBit(bool bitValue);
bool jitterCompensationProcedure(bool current_bit);
bool m_hexDisplay = false;
QPlainTextEdit *console;
isoBufferBuffer m_serialBuffer;
public:
double m_baudRate;
QTimer m_updateTimer; // IMPORTANT: must be after m_serialBuffer. construction / destruction order matters
public:
void serialDecode();
int serialDistance() const;
signals:
void wireDisconnected(int);
public slots:
void updateConsole();
void setParityMode(UartParity newParity);
void setHexDisplay(bool enabled);
private:
char decodeDatabit(int mode, short symbol) const;
char decodeBaudot(short symbol) const;
@ -62,11 +71,7 @@ private:
UartParity parityOf(uint32_t bitField) const;
bool parityCheckFailed = false;
signals:
void wireDisconnected(int);
public slots:
void updateConsole();
void setParityMode(UartParity newParity);
};
#endif // UARTSTYLEDECODER_H

View File

@ -1695,6 +1695,7 @@
<addaction name="menuBaud_Rate"/>
<addaction name="menuData_Bits"/>
<addaction name="menuParity_Bit"/>
<addaction name="actionHexDisplay"/>
</widget>
<widget class="QMenu" name="menuUART_2">
<property name="title">
@ -1734,6 +1735,7 @@
<addaction name="menuBaud_Rate_2"/>
<addaction name="menuData_Bits_2"/>
<addaction name="menuParity_Bit_2"/>
<addaction name="actionHexDisplay_2"/>
</widget>
<widget class="QMenu" name="menuProtocol">
<property name="title">
@ -2555,6 +2557,22 @@
<string>&amp;Documentation</string>
</property>
</action>
<action name="actionHexDisplay">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Hex Display</string>
</property>
</action>
<action name="actionHexDisplay_2">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Hex Display</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>