Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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++;
Expand Down Expand Up @@ -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, [&]() {
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
29 changes: 23 additions & 6 deletions vescinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ VescInterface::VescInterface(QObject *parent) : QObject(parent)
mCanTmpFwdIdLast = -1;

mIgnoreCustomConfigs = false;
mIgnoreTestVersion = false;

mFwSwapDone = false;
mBlockFwSwap = false;
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -2451,8 +2454,12 @@ bool VescInterface::connectSerial(QString port, int baudrate)
#ifdef HAS_SERIALPORT
bool found = false;
for (auto ser: listSerialPorts()) {
if (ser.value<VSerialInfo_t>().systemPath == port) {
VSerialInfo_t info = ser.value<VSerialInfo_t>();

//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;
}
}
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 4 additions & 0 deletions vescinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -482,6 +485,7 @@ private slots:
bool mSpeedGaugeUseNegativeValues;
bool mAskQmlLoad;
bool mIgnoreCustomConfigs;
bool mIgnoreTestVersion;

void updateFwRx(bool fwRx);
void setLastConnectionType(conn_t type);
Expand Down