diff --git a/src/comm/LinkInterface.h b/src/comm/LinkInterface.h index 4c2e682913595215a90cf4b4a6ebf6f86227f496..0cd15b3124b4b9feac1e6355e61b9fb55e401bcd 100644 --- a/src/comm/LinkInterface.h +++ b/src/comm/LinkInterface.h @@ -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); diff --git a/src/comm/SerialLink.cc b/src/comm/SerialLink.cc index 1d37f91059444e7932dc8daa5b11d7984e75ae12..ae2cde0a79201b2ef0d84308b87ca5881cb61379 100644 --- a/src/comm/SerialLink.cc +++ b/src/comm/SerialLink.cc @@ -20,7 +20,6 @@ #ifdef _WIN32 #include "windows.h" #endif - #ifdef _WIN32 #include #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) { diff --git a/src/ui/DebugConsole.cc b/src/ui/DebugConsole.cc index 8e856aa4f15c0d511e19e4fd266a0cc8da73439a..c89fc3811428bf224c11b8e75b01ea8688717575 100644 --- a/src/ui/DebugConsole.cc +++ b/src/ui/DebugConsole.cc @@ -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()); } diff --git a/src/ui/DebugConsole.h b/src/ui/DebugConsole.h index 4a7cf6b8debcf54ef2e5320510d981be32013228..75365f39c812418c6275e60cc0e1552659170775 100644 --- a/src/ui/DebugConsole.h +++ b/src/ui/DebugConsole.h @@ -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);