Commit c170e356 authored by Lorenz Meier's avatar Lorenz Meier

Some VT100 hacks, fixed MAVLink inclusion path

parent 4281a113
...@@ -34,13 +34,15 @@ border: 1px solid #777777; ...@@ -34,13 +34,15 @@ border: 1px solid #777777;
} }
QTextEdit { QTextEdit {
border: 1px solid #777777; border: 1px solid #777777;
border-radius: 2px; border-radius: 2px;
} }
QPlainTextEdit { QPlainTextEdit {
border: 1px solid #777777; border: 1px solid #777777;
border-radius: 2px; border-radius: 2px;
font-family: "Monospace";
font: large;
} }
QComboBox { QComboBox {
......
...@@ -111,7 +111,7 @@ isEmpty(MAVLINK_CONF) { ...@@ -111,7 +111,7 @@ isEmpty(MAVLINK_CONF) {
INCLUDEPATH += $$MAVLINKPATH/common INCLUDEPATH += $$MAVLINKPATH/common
} else { } else {
INCLUDEPATH += $$MAVLINKPATH/$$MAVLINK_CONF INCLUDEPATH += $$MAVLINKPATH/$$MAVLINK_CONF
DEFINES += 'MAVLINK_CONF="$${MAVLINK_CONF}.h"' #DEFINES += 'MAVLINK_CONF="$${MAVLINK_CONF}.h"'
DEFINES += $$sprintf('QGC_USE_%1_MESSAGES', $$upper($$MAVLINK_CONF)) DEFINES += $$sprintf('QGC_USE_%1_MESSAGES', $$upper($$MAVLINK_CONF))
} }
......
...@@ -30,19 +30,13 @@ This file is part of the QGROUNDCONTROL project ...@@ -30,19 +30,13 @@ This file is part of the QGROUNDCONTROL project
#ifndef QGCMAVLINK_H #ifndef QGCMAVLINK_H
#define QGCMAVLINK_H #define QGCMAVLINK_H
#include <../../mavlink/include/mavlink/v1.0/mavlink_types.h> #include <mavlink.h>
#ifdef QGC_USE_PIXHAWK_MESSAGES //#ifdef MAVLINK_CONF
#include <../../mavlink/include/mavlink/v1.0/pixhawk/pixhawk.h> //please do not delete this. //#define MY_MACRO(x) <x>
#else //#include MY_MACRO(MAVLINK_CONF)
#include <../../mavlink/include/mavlink/v1.0/common/mavlink.h>
#endif
#ifdef MAVLINK_CONF
#define MY_MACRO(x) <x>
#include MY_MACRO(MAVLINK_CONF)
//#include MAVLINK_CONF //#include MAVLINK_CONF
#endif //#endif
#endif // QGCMAVLINK_H #endif // QGCMAVLINK_H
......
...@@ -74,12 +74,13 @@ DebugConsole::DebugConsole(QWidget *parent) : ...@@ -74,12 +74,13 @@ DebugConsole::DebugConsole(QWidget *parent) :
m_ui->receiveText->setMaximumBlockCount(500); m_ui->receiveText->setMaximumBlockCount(500);
// Allow to wrap everywhere // Allow to wrap everywhere
m_ui->receiveText->setWordWrapMode(QTextOption::WrapAnywhere); m_ui->receiveText->setWordWrapMode(QTextOption::WrapAnywhere);
// // Set monospace font
// m_ui->receiveText->setFontFamily("Monospace");
// Enable 10 Hz output // Enable 10 Hz output
//connect(&lineBufferTimer, SIGNAL(timeout()), this, SLOT(showData())); //connect(&lineBufferTimer, SIGNAL(timeout()), this, SLOT(showData()));
//lineBufferTimer.setInterval(100); // 100 Hz //lineBufferTimer.setInterval(100); // 100 Hz
//lineBufferTimer.start(); //lineBufferTimer.start();
loadSettings(); loadSettings();
// Enable traffic measurements // Enable traffic measurements
...@@ -392,20 +393,65 @@ void DebugConsole::receiveBytes(LinkInterface* link, QByteArray bytes) ...@@ -392,20 +393,65 @@ void DebugConsole::receiveBytes(LinkInterface* link, QByteArray bytes)
// Convert to ASCII for readability // Convert to ASCII for readability
if (convertToAscii) if (convertToAscii)
{ {
if ((byte <= 32) || (byte > 126)) if (escReceived)
{
if (escIndex < sizeof(escBytes))
{
escBytes[escIndex] = byte;
//qDebug() << "GOT BYTE ESC:" << byte;
if (/*escIndex == 1 && */escBytes[escIndex] == 0x48)
{
// Handle sequence
// for this one, clear all text
m_ui->receiveText->clear();
escReceived = false;
}
else if (/*escIndex == 1 && */escBytes[escIndex] == 0x4b)
{
// Handle sequence
// for this one, do nothing
escReceived = false;
}
else if (byte == 0x5b)
{
// Do nothing, this is still a valid escape sequence
}
else
{
escReceived = false;
}
}
else
{
// Obviously something went wrong, reset
escReceived = false;
escIndex = 0;
}
}
else if ((byte <= 32) || (byte > 126))
{ {
switch (byte) switch (byte)
{ {
case (unsigned char)'\n': // Accept line feed case (unsigned char)'\n': // Accept line feed
if (lastByte != '\r') // Do not break line again for CR+LF if (lastByte != '\r') // Do not break line again for LF+CR
str.append(byte); // only break line for single LF or CR bytes str.append(byte); // only break line for single LF or CR bytes
break; break;
case (unsigned char)' ': // space of any type means don't add another on hex output case (unsigned char)' ': // space of any type means don't add another on hex output
case (unsigned char)'\t': // Accept tab case (unsigned char)'\t': // Accept tab
case (unsigned char)'\r': // Catch and carriage return case (unsigned char)'\r': // Catch and carriage return
str.append(byte); if (lastByte != '\n') // Do not break line again for CR+LF
str.append(byte); // only break line for single LF or CR bytes
lastSpace = 1; lastSpace = 1;
break; break;
/* VT100 emulation (partially */
case 0x1b: // ESC received
escReceived = true;
escIndex = 0;
//qDebug() << "GOT ESC";
break;
case 0x08: // BS (backspace) received
// Do nothing for now
break;
default: // Append replacement character (box) if char is not ASCII default: // Append replacement character (box) if char is not ASCII
// str.append(QChar(QChar::ReplacementCharacter)); // str.append(QChar(QChar::ReplacementCharacter));
QString str2; QString str2;
...@@ -414,6 +460,7 @@ void DebugConsole::receiveBytes(LinkInterface* link, QByteArray bytes) ...@@ -414,6 +460,7 @@ void DebugConsole::receiveBytes(LinkInterface* link, QByteArray bytes)
else str2.sprintf(" 0x%02x ", byte); else str2.sprintf(" 0x%02x ", byte);
str.append(str2); str.append(str2);
lastSpace = 1; lastSpace = 1;
escReceived = false;
break; break;
} }
} }
......
...@@ -121,6 +121,10 @@ protected: ...@@ -121,6 +121,10 @@ protected:
bool autoHold; ///< Auto-hold mode sets view into hold if the data rate is too high bool autoHold; ///< Auto-hold mode sets view into hold if the data rate is too high
int bytesToIgnore; ///< Number of bytes to ignore int bytesToIgnore; ///< Number of bytes to ignore
char lastByte; ///< The last received byte char lastByte; ///< The last received byte
bool escReceived; ///< True if received ESC char in ASCII mode
int escIndex; ///< Index of bytes since ESC was received
char escBytes[5]; ///< Escape-following bytes
bool terminalReceived; ///< Terminal sequence received
QList<QString> sentBytes; ///< Transmitted bytes, per transmission QList<QString> sentBytes; ///< Transmitted bytes, per transmission
QByteArray holdBuffer; ///< Buffer where bytes are stored during hold-enable QByteArray holdBuffer; ///< Buffer where bytes are stored during hold-enable
QString lineBuffer; ///< Buffere where bytes are stored before writing them out QString lineBuffer; ///< Buffere where bytes are stored before writing them out
......
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