Skip to content

Commit

Permalink
Add support for querying device fw params
Browse files Browse the repository at this point in the history
  • Loading branch information
sdb4 committed Nov 7, 2024
1 parent 56aaa1a commit 6587b13
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ static void showHelp()
qDebug() << "--eraseLisp : Erase lisp-script.";
qDebug() << "--uploadFirmware [path] : Upload firmware-file from path.";
qDebug() << "--uploadBootloaderBuiltin : Upload bootloader from generic included bootloaders.";
qDebug() << "--queryDeviceFwParams : Connect and print out device fw parameters.";
qDebug() << "--writeFileToSdCard [fileLocal:pathSdcard] : Write file to SD-card.";
qDebug() << "--packFirmware [fileIn:fileOut] : Pack firmware-file for compatibility with the bootloader. ";
qDebug() << "--packLisp [fileIn:fileOut] : Pack lisp-file and the included imports.";
Expand Down Expand Up @@ -310,6 +311,7 @@ int main(int argc, char *argv[])
bool eraseLisp = false;
QString firmwarePath = "";
bool uploadBootloaderBuiltin = false;
bool queryDeviceFwParams = false;
QString fwPackIn = "";
QString fwPackOut = "";
QString fileForSdIn = "";
Expand Down Expand Up @@ -597,6 +599,11 @@ int main(int argc, char *argv[])
found = true;
}

if (str == "--queryDeviceFwParams") {
queryDeviceFwParams = true;
found = true;
}

if (str == "--debugOutFile") {
if ((i + 1) < args.size()) {
i++;
Expand Down Expand Up @@ -1004,7 +1011,7 @@ int main(int argc, char *argv[])

if (isMcConf || isAppConf || isCustomConf || !lispPath.isEmpty() ||
eraseLisp || !firmwarePath.isEmpty() || uploadBootloaderBuiltin ||
!fileForSdIn.isEmpty() || bridgeAppData) {
queryDeviceFwParams || !fileForSdIn.isEmpty() || bridgeAppData) {
if (offscreen) {
qputenv("QT_QPA_PLATFORM", "offscreen");
}
Expand Down Expand Up @@ -1160,7 +1167,7 @@ int main(int argc, char *argv[])
}
}

if (isMcConf || isAppConf || isCustomConf) {
if (isMcConf || isAppConf || isCustomConf || queryDeviceFwParams) {
bool res = vesc->customConfigRxDone();
if (!res) {
res = Utility::waitSignal(vesc, SIGNAL(customConfigLoadDone()), 4000);
Expand Down Expand Up @@ -1341,6 +1348,33 @@ int main(int argc, char *argv[])
}
}

if (queryDeviceFwParams) {
FW_RX_PARAMS params = vesc->getLastFwRxParams();

QString fwStr;
QString strUuid = Utility::uuid2Str(params.uuid, true);

if (params.major >= 0) {
fwStr = QString("FW: V%1.%2").arg(params.major).arg(params.minor, 2, 10, QLatin1Char('0'));
if (!params.fwName.isEmpty()) {
fwStr += " (" + params.fwName + ")";
}

if (!params.hw.isEmpty()) {
fwStr += ", Hw: " + params.hw;
}

if (!strUuid.isEmpty()) {
fwStr += ", UUID: " + strUuid;
}

fwStr += ", isTestFw: " + QString::number(params.isTestFw);
fwStr += ", hwType: " + params.hwTypeStr();
fwStr += ", hwConfCrc: " + QString::number(params.hwConfCrc);
}
qInfo() << fwStr;
}

if (!firmwarePath.isEmpty()) {
QFile f(firmwarePath);
if (f.open(QIODevice::ReadOnly)) {
Expand Down

0 comments on commit 6587b13

Please sign in to comment.