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