diff --git a/README.md b/README.md index 0286f11..f296ed1 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ capturing of canbus frames. Please use the "Discussions" tab here on GitHub to ask questions and interact with the community. -Requires at a resolution of at least 1024x768. Fully multi-monitor capable. Works on 4K monitors as well. +Requires a resolution of at least 1024x768. Fully multi-monitor capable. Works on 4K monitors as well. You are highly recommended to use the [CANDue board from EVTV](http://store.evtv.me/proddetail.php?prod=ArduinoDueCANBUS&cat=23). @@ -16,7 +16,7 @@ You are highly recommended to use the The CANDue board must be running the GVRET firmware which can also be found within the collin80 repos. -It is now possible to use any QT SerialBus driver (socketcan, Vector, PeakCAN, TinyCAN). +It is now possible to use any Qt SerialBus driver (socketcan, Vector, PeakCAN, TinyCAN). There may, however, be some loss of some functionality as some functions of SavvyCAN are designed for use directly with the EVTVDue and CANDue 2.0 boards. @@ -28,7 +28,7 @@ of this program. It can load and save in several formats: 2. Microchip log file 3. CRTD format (OVMS log file format from Mark Webb-Johnson) 4. GVRET native format -5. Generic CSV file (ID,D0 D1 D2 D3 D4 D5 D6 D7) +5. Generic CSV file (ID, D0 D1 D2 D3 D4 D5 D6 D7) 6. Vector Trace files 7. IXXAT Minilog files 8. CAN-DO Logs @@ -48,10 +48,10 @@ http://www.qcustomplot.com/ However, this source code is integrated into the source for SavvyCAN and one isn't required to download it separately. -This project requires 5.13.0 or higher because of a dependency on QtSerialBus and other new additions to QT. +This project requires 5.13.0 or higher because of a dependency on QtSerialBus and other new additions to Qt. -NOTE: QT6 currently lacks support for QtSerialBus and many other QT sub-features. At this time you cannot -use QT6 to compile SavvyCAN. Support for QT6 should be possible around QT6.2. +NOTE: Qt6 currently lacks support for QtSerialBus and many other Qt sub-features. At this time you cannot +use Qt6 to compile SavvyCAN. Support for Qt6 should be possible around Qt6.2. ## Instructions for compiling: diff --git a/framefileio.cpp b/framefileio.cpp index 41f0434..043d19c 100644 --- a/framefileio.cpp +++ b/framefileio.cpp @@ -3966,7 +3966,17 @@ bool FrameFileIO::loadCabanaFile(QString filename, QVector* frames) bytes[6] = ((tempData >> 8) & 0xFF); bytes[7] = (tempData & 0xFF); } - thisFrame.setPayload(bytes); + + // Shift the bytes back correctly so we have a frame that is the proper length + unsigned int framelength = tokens[3].length() / 2; + QByteArray finalbytes(framelength,0); + uint8_t bytes_shifted_by = 8 - framelength; + for (unsigned int j = 0; j < framelength; j++) + { + finalbytes[j] = bytes[j + bytes_shifted_by]; + } + + thisFrame.setPayload(finalbytes); frames->append(thisFrame); } else foundErrors = true; diff --git a/jsedit.cpp b/jsedit.cpp index 4784219..5a994d0 100644 --- a/jsedit.cpp +++ b/jsedit.cpp @@ -54,6 +54,7 @@ protected: private: QSet m_keywords; QSet m_knownIds; + QSet m_customIds; QHash m_colors; QString m_markString; Qt::CaseSensitivity m_markCaseSensitivity; @@ -73,6 +74,7 @@ JSHighlighter::JSHighlighter(QTextDocument *parent) m_colors[JSEdit::Keyword] = QColor("#000080"); m_colors[JSEdit::BuiltIn] = QColor("#008080"); m_colors[JSEdit::Marker] = QColor("#ffff00"); + m_colors[JSEdit::Custom] = QColor("#ff00ff"); // https://developer.mozilla.org/en/JavaScript/Reference/Reserved_Words m_keywords << "break"; @@ -249,6 +251,27 @@ JSHighlighter::JSHighlighter(QTextDocument *parent) m_knownIds << "window"; m_knownIds << "navigator"; m_knownIds << "userAgent"; + + //Custom objects + m_customIds << "host"; + m_customIds << "can"; + m_customIds << "isotp"; + m_customIds << "uds"; + //Custom callback functions + m_customIds << "setup"; + m_customIds << "tick"; + m_customIds << "gotCANFrame"; + m_customIds << "gotISOTPMessage"; + m_customIds << "gotUDSMessage"; + //Custom functions + m_customIds << "setTickInterval"; + m_customIds << "log"; //Duplicate + m_customIds << "addParameter"; + m_customIds << "setFilter"; + m_customIds << "clearFilters"; + m_customIds << "sendFrame"; + m_customIds << "sendISOTP"; + m_customIds << "sendUDS"; } void JSHighlighter::setColor(JSEdit::ColorComponent component, const QColor &color) @@ -271,6 +294,7 @@ void JSHighlighter::highlightBlock(const QString &text) }; QList bracketPositions; + QString previousToken; int blockState = previousBlockState(); int bracketLevel = blockState >> 4; @@ -351,10 +375,17 @@ void JSHighlighter::highlightBlock(const QString &text) case Identifier: if (ch.isSpace() || !(ch.isDigit() || ch.isLetter() || ch == '_')) { QString token = text.mid(start, i - start).trimmed(); - if (m_keywords.contains(token)) + if (m_customIds.contains(token) && m_customIds.contains(previousToken)) { + setFormat(start, i - start, m_colors[JSEdit::Custom]); + } else if (m_keywords.contains(token)) { setFormat(start, i - start, m_colors[JSEdit::Keyword]); - else if (m_knownIds.contains(token)) + } else if (m_knownIds.contains(token)) { setFormat(start, i - start, m_colors[JSEdit::BuiltIn]); + if (ch == '.') previousToken = token; + } else if (m_customIds.contains(token)) { + setFormat(start, i - start, m_colors[JSEdit::Custom]); + if (ch == '.') previousToken = token; + } state = Start; } else { ++i; diff --git a/jsedit.h b/jsedit.h index 104856e..52eefc8 100644 --- a/jsedit.h +++ b/jsedit.h @@ -57,6 +57,7 @@ public: Identifier, Keyword, BuiltIn, + Custom, Sidebar, LineNumber, Cursor, diff --git a/scriptingwindow.cpp b/scriptingwindow.cpp index 2fe7238..1d5f378 100644 --- a/scriptingwindow.cpp +++ b/scriptingwindow.cpp @@ -21,6 +21,12 @@ ScriptingWindow::ScriptingWindow(const QVector *frames, QWidget *paren editor->setEnabled(false); editor->setFont(QFont("Monospace", 12)); editor->show(); + + //Show whitespaces + QTextOption option = editor->document()->defaultTextOption(); + option.setFlags(QTextOption::ShowTabsAndSpaces); + editor->document()->setDefaultTextOption(option); + ui->verticalLayout->insertWidget(2,editor, 10); readSettings(); diff --git a/ui/scriptingwindow.ui b/ui/scriptingwindow.ui index 1cf4ebd..35c0b9e 100644 --- a/ui/scriptingwindow.ui +++ b/ui/scriptingwindow.ui @@ -18,8 +18,14 @@ + + + 75 + true + + - Public Variables: + Public Variables Qt::AlignCenter @@ -31,6 +37,12 @@ + + + 75 + true + + Loaded Scripts @@ -47,21 +59,21 @@ - New + &New - Del + &Del - Load + &Load @@ -73,6 +85,12 @@ + + + 75 + true + + Script Editing Window @@ -86,21 +104,21 @@ - Save + &Save - Revert + &Revert - Recompile + Re&compile @@ -108,8 +126,14 @@ + + + 75 + true + + - Log Window: + Log Window Qt::AlignCenter @@ -122,14 +146,14 @@ - Auto Scroll Log Window + &Auto Scroll Log Window - Clear Log Window + Clear Log &Window