Commit 5f536d0d authored by Michael Carpenter's avatar Michael Carpenter

Addition of extra debug output to comms console during Serial Comms issues

parent 3fba7256
......@@ -232,6 +232,8 @@ signals:
/** @brief Communication error occured */
void communicationError(const QString& linkname, const QString& error);
void communicationUpdate(const QString& linkname, const QString& text);
/** @brief destroying element */
void deleteLink(LinkInterface* const link);
......
......@@ -20,7 +20,6 @@
#ifdef _WIN32
#include "windows.h"
#endif
#ifdef _WIN32
#include <qextserialenumerator.h>
#endif
......@@ -397,6 +396,8 @@ void SerialLink::run()
if (!hardwareConnect())
{
//Need to error out here.
emit communicationError(getName(),"Error connecting: " + port->errorString());
return;
}
......@@ -406,7 +407,7 @@ void SerialLink::run()
quint64 bytes = 0;
bool triedreset = false;
bool triedDTR = false;
int timeout = 2500;
int timeout = 5000;
forever
{
{
......@@ -442,6 +443,7 @@ void SerialLink::run()
if (!triedDTR && triedreset)
{
triedDTR = true;
communicationUpdate(getName(),"No data to receive on COM port. Attempting to reset via DTR signal");
qDebug() << "No data!!! Attempting reset via DTR.";
port->setDtr(true);
this->msleep(250);
......@@ -450,11 +452,13 @@ void SerialLink::run()
else if (!triedreset)
{
qDebug() << "No data!!! Attempting reset via reboot command.";
communicationUpdate(getName(),"No data to receive on COM port. Assuming possible terminal mode, attempting to reset via \"reboot\" command");
port->write("reboot\r\n",8);
triedreset = true;
}
else
{
communicationUpdate(getName(),"No data to receive on COM port....");
qDebug() << "No data!!!";
}
}
......@@ -665,7 +669,14 @@ bool SerialLink::hardwareConnect()
port->setCommTimeouts(QSerialPort::CtScheme_NonBlockingRead);
connectionStartTime = MG::TIME::getGroundTimeNow();
port->open();
if (!port->open())
{
emit communicationUpdate(getName(),"Error opening port: " + port->errorString());
}
else
{
emit communicationUpdate(getName(),"Opened port!");
}
bool connectionUp = isConnected();
if(connectionUp) {
......
......@@ -215,6 +215,12 @@ void DebugConsole::removeLink(LinkInterface* const linkInterface)
}
if (linkInterface == currLink) currLink = NULL;
}
void DebugConsole::linkStatusUpdate(const QString& name,const QString& text)
{
m_ui->receiveText->appendPlainText(text);
// Ensure text area scrolls correctly
m_ui->receiveText->ensureCursorVisible();
}
void DebugConsole::linkSelected(int linkId)
{
......@@ -222,6 +228,7 @@ void DebugConsole::linkSelected(int linkId)
if (currLink) {
disconnect(currLink, SIGNAL(bytesReceived(LinkInterface*,QByteArray)), this, SLOT(receiveBytes(LinkInterface*, QByteArray)));
disconnect(currLink, SIGNAL(connected(bool)), this, SLOT(setConnectionState(bool)));
disconnect(currLink,SIGNAL(communicationUpdate(QString,QString)),this,SLOT(linkStatusUpdate(QString,QString)));
}
// Clear data
m_ui->receiveText->clear();
......@@ -230,6 +237,7 @@ void DebugConsole::linkSelected(int linkId)
currLink = links[linkId];
connect(currLink, SIGNAL(bytesReceived(LinkInterface*,QByteArray)), this, SLOT(receiveBytes(LinkInterface*, QByteArray)));
connect(currLink, SIGNAL(connected(bool)), this, SLOT(setConnectionState(bool)));
connect(currLink,SIGNAL(communicationUpdate(QString,QString)),this,SLOT(linkStatusUpdate(QString,QString)));
setConnectionState(currLink->isConnected());
}
......
......@@ -96,6 +96,8 @@ public slots:
/** @brief A new special symbol is selected */
void specialSymbolSelected(const QString& text);
void linkStatusUpdate(const QString& name,const QString& text);
protected slots:
/** @brief Draw information overlay */
void paintEvent(QPaintEvent *event);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment