Skip to content

Commit

Permalink
[sitl] add --version, add git commit to version output (iNavFlight#9286)
Browse files Browse the repository at this point in the history
* [sitl] add --version, add git commit to version output

* [sitl] take help path on invalid options
  • Loading branch information
stronnag authored Sep 9, 2023
1 parent cf12672 commit 3a2412e
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/main/target/SITL/target.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#include "drivers/timer.h"
#include "drivers/serial.h"
#include "config/config_streamer.h"
#include "build/version.h"

#include "target/SITL/sim/realFlight.h"
#include "target/SITL/sim/xplane.h"
Expand All @@ -73,9 +74,12 @@ static int simPort = 0;

static char **c_argv;

void systemInit(void) {
static void printVersion(void) {
fprintf(stderr, "INAV %d.%d.%d SITL (%s)\n", FC_VERSION_MAJOR, FC_VERSION_MINOR, FC_VERSION_PATCH_LEVEL, shortGitRevision);
}

fprintf(stderr, "INAV %d.%d.%d SITL\n", FC_VERSION_MAJOR, FC_VERSION_MINOR, FC_VERSION_PATCH_LEVEL);
void systemInit(void) {
printVersion();
clock_gettime(CLOCK_MONOTONIC, &start_time);
fprintf(stderr, "[SYSTEM] Init...\n");

Expand Down Expand Up @@ -168,6 +172,7 @@ bool parseMapping(char* mapStr)

void printCmdLineOptions(void)
{
printVersion();
fprintf(stderr, "Avaiable options:\n");
fprintf(stderr, "--path=[path] Path and filename of eeprom.bin. If not specified 'eeprom.bin' in program directory is used.\n");
fprintf(stderr, "--sim=[rf|xp] Simulator interface: rf = RealFligt, xp = XPlane. Example: --sim=rf\n");
Expand Down Expand Up @@ -197,6 +202,7 @@ void parseArguments(int argc, char *argv[])
{"simport", required_argument, 0, 'p'},
{"help", no_argument, 0, 'h'},
{"path", required_argument, 0, 'e'},
{"version", no_argument, 0, 'v'},
{NULL, 0, NULL, 0}
};

Expand Down Expand Up @@ -236,10 +242,12 @@ void parseArguments(int argc, char *argv[])
fprintf(stderr, "[EEPROM] Invalid path, using eeprom file in program directory\n.");
}
break;
case 'h':
case 'v':
printVersion();
exit(0);
default:
printCmdLineOptions();
exit(0);
break;
}
}

Expand Down

0 comments on commit 3a2412e

Please sign in to comment.