diff --git a/main.cpp b/main.cpp index d034237f6..7029727a0 100755 --- a/main.cpp +++ b/main.cpp @@ -77,6 +77,8 @@ static void showHelp() { qDebug() << "Arguments"; qDebug() << "-h, --help : Show help text"; + qDebug() << "--about : Show about text"; + qDebug() << "--version : Show VESC Tool version information on one line"; qDebug() << "--tcpServer [port] : Connect to VESC and start TCP server on [port]"; qDebug() << "--loadQml [file] : Load QML UI from file instead of the regular VESC Tool UI"; qDebug() << "--loadQmlVesc : Load QML UI from the connected VESC instead of the regular VESC Tool UI"; @@ -367,6 +369,16 @@ int main(int argc, char *argv[]) return 0; } + if (str == "--about") { + qDebug() << Utility::aboutText(); + return 0; + } + + if (str == "--version") { + qDebug() << Utility::versionText(); + return 0; + } + if (str == "--tcpServer") { if ((i + 1) < args.size()) { i++; @@ -1024,6 +1036,8 @@ int main(int argc, char *argv[]) QmlUi *qmlUi = nullptr; QString qmlStr; + bool serialAutoconnect = vescPort.isEmpty(); + QTimer connTimer; connTimer.setInterval(1000); QObject::connect(&connTimer, &QTimer::timeout, [&]() { @@ -1037,7 +1051,7 @@ int main(int argc, char *argv[]) } bool ok = false; - if (vescPort.isEmpty()) { + if (serialAutoconnect) { ok = vesc->autoconnect(); } else { ok = vesc->connectSerial(vescPort); @@ -1069,6 +1083,8 @@ int main(int argc, char *argv[]) vesc = new VescInterface; vesc->setBlockFwSwap(true); vesc->setIgnoreCustomConfigs(!isCustomConf); + vesc->setShowFwUpdateAvailable(false); + vesc->setIgnoreTestVersion(true); vesc->fwConfig()->loadParamsXml("://res/config/fw.xml"); Utility::configLoadLatest(vesc); @@ -1132,7 +1148,7 @@ int main(int argc, char *argv[]) QTimer::singleShot(10, [&]() { int exitCode = 0; bool ok = false; - if (vescPort.isEmpty()) { + if (serialAutoconnect) { ok = vesc->autoconnect(); } else { ok = vesc->connectSerial(vescPort); @@ -1150,6 +1166,14 @@ int main(int argc, char *argv[]) if (canFwd >= 0) { vesc->commands()->setSendCan(true, canFwd); + } else if (!serialAutoconnect) { + //Ensure we talk to the USB connected Vesc, if no CAN id was specified and we are not autoconnecting + //If autoconnecting then we will use the last CAN id in settings + vesc->commands()->setSendCan(false, 0); + } + + if (vesc->commands()->getSendCan()) { + qDebug() << "Sending to CAN ID" << vesc->commands()->getCanSendId(); } CodeLoader loader; diff --git a/utility.cpp b/utility.cpp index e34593d31..7e0bcc661 100755 --- a/utility.cpp +++ b/utility.cpp @@ -257,6 +257,11 @@ QString Utility::aboutText() ; } +QString Utility::versionText() +{ + return QString::number(VT_VERSION, 'f', 2) + "-" + QString::number(VT_IS_TEST_VERSION) + "+" + STR(VT_GIT_COMMIT); +} + QString Utility::uuid2Str(QByteArray uuid, bool space) { QString strUuid; diff --git a/utility.h b/utility.h index 6a985b785..dc88a31db 100644 --- a/utility.h +++ b/utility.h @@ -52,6 +52,7 @@ class Utility : public QObject Q_INVOKABLE static QString fwChangeLog(); Q_INVOKABLE static QString vescToolChangeLog(); Q_INVOKABLE static QString aboutText(); + Q_INVOKABLE static QString versionText(); Q_INVOKABLE static QString uuid2Str(QByteArray uuid, bool space); Q_INVOKABLE static bool requestFilePermission(); Q_INVOKABLE static bool hasLocationPermission(); diff --git a/vescinterface.cpp b/vescinterface.cpp index 427d2e5ee..29b307587 100755 --- a/vescinterface.cpp +++ b/vescinterface.cpp @@ -106,6 +106,7 @@ VescInterface::VescInterface(QObject *parent) : QObject(parent) mCanTmpFwdIdLast = -1; mIgnoreCustomConfigs = false; + mIgnoreTestVersion = false; mFwSwapDone = false; mBlockFwSwap = false; @@ -587,11 +588,13 @@ VescInterface::VescInterface(QObject *parent) : QObject(parent) #if VT_IS_TEST_VERSION QTimer::singleShot(1000, [this]() { - emitMessageDialog("VESC Tool Test Version", - "Warning: This is a test version of VESC Tool. The included firmwares are NOT compatible with " - "released firmwares and should only be used with this test version. When using a release version " - "of VESC Tool, the firmware must be upgraded even if the version number is the same.", - false); + if (!mIgnoreTestVersion) { + emitMessageDialog("VESC Tool Test Version", + "Warning: This is a test version of VESC Tool. The included firmwares are NOT compatible with " + "released firmwares and should only be used with this test version. When using a release version " + "of VESC Tool, the firmware must be upgraded even if the version number is the same.", + false); + } }); #endif } @@ -2451,8 +2454,12 @@ bool VescInterface::connectSerial(QString port, int baudrate) #ifdef HAS_SERIALPORT bool found = false; for (auto ser: listSerialPorts()) { - if (ser.value().systemPath == port) { + VSerialInfo_t info = ser.value(); + + //Allow for partial matches (otherwise on WIN we must specify a strange port path, eg. '\\.\COM4') + if (info.systemPath.contains(port, Qt::CaseInsensitive)) { found = true; + port = info.systemPath; break; } } @@ -4235,6 +4242,16 @@ void VescInterface::setIgnoreCustomConfigs(bool newIgnoreCustomConfigs) mIgnoreCustomConfigs = newIgnoreCustomConfigs; } +bool VescInterface::ignoreTestVersion() const +{ + return mIgnoreTestVersion; +} + +void VescInterface::setIgnoreTestVersion(bool ignore) +{ + mIgnoreTestVersion = ignore; +} + bool VescInterface::reconnectLastCan() { return mSettings.value("reconnectLastCan", true).toBool(); diff --git a/vescinterface.h b/vescinterface.h index 818f26078..5c32b974f 100755 --- a/vescinterface.h +++ b/vescinterface.h @@ -267,6 +267,9 @@ class VescInterface : public QObject bool ignoreCustomConfigs() const; void setIgnoreCustomConfigs(bool newIgnoreCustomConfigs); + bool ignoreTestVersion() const; + void setIgnoreTestVersion(bool ignore); + Q_INVOKABLE bool reconnectLastCan(); Q_INVOKABLE void setReconnectLastCan(bool set); @@ -482,6 +485,7 @@ private slots: bool mSpeedGaugeUseNegativeValues; bool mAskQmlLoad; bool mIgnoreCustomConfigs; + bool mIgnoreTestVersion; void updateFwRx(bool fwRx); void setLastConnectionType(conn_t type);