Skip to content

Commit

Permalink
Add --cwd <dir> option for setting working directory
Browse files Browse the repository at this point in the history
  • Loading branch information
nhjschulz committed Aug 29, 2024
1 parent 95ec68d commit 27233b9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/APPTurtle/src/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ void App::setup()
/* If the robot name is empty, use the wifi MAC address as robot name. */
if (true == settings.getRobotName().isEmpty())
{
String robotName = WiFi.macAddress();
String robotName("MAC");
robotName += WiFi.macAddress();

/* Remove MAC separators from robot name. */
robotName.replace(":", "");
Expand Down
7 changes: 7 additions & 0 deletions lib/MainNative/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
* Includes
*****************************************************************************/

#include <unistd.h>
#include <Arduino.h>
#include <Terminal.h>
#include <Board.h>
Expand Down Expand Up @@ -111,6 +112,7 @@ static const struct option LONG_OPTIONS[] = {{"help", no_argument, nullptr, 0},
{"xPosition", required_argument, nullptr, 0},
{"yPosition", required_argument, nullptr, 0},
{"heading", required_argument, nullptr, 0},
{"cwd", required_argument, nullptr, 0},
{nullptr, no_argument, nullptr, 0}}; /* Marks the end. */

/** Program argument default value of the robot name. */
Expand Down Expand Up @@ -377,6 +379,10 @@ static int handleCommandLineArguments(PrgArguments& prgArguments, int argc, char
{
prgArguments.heading = optarg;
}
else if (0 == strcmp(LONG_OPTIONS[optionIndex].name, "cwd"))
{
chdir(optarg);
}
else
{
status = -1;
Expand Down Expand Up @@ -433,6 +439,7 @@ static int handleCommandLineArguments(PrgArguments& prgArguments, int argc, char
printf(" Default: %s\n", PRG_ARG_Y_POS); /* Initial Y position default value */
printf("\t--heading <HEADING>\t\tSet initial heading in mrad."); /* Initial heading in mrad */
printf(" Default: %s\n", PRG_ARG_HEADING); /* Initial heading default value */
printf("\t--cwd <dir>\t\tSpecify working directory."); /* Set process working directory */
}

return status;
Expand Down

0 comments on commit 27233b9

Please sign in to comment.