Skip to content

Commit

Permalink
add logging dir to config
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler-Lentz committed Apr 17, 2024
1 parent 33ad4dd commit e008eaf
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions configs/config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"logging": {
"dir": "/workspaces/obcpp/logs"
},
"network": {
"mavlink": {
"connect": "serial:///dev/ttyACM0"
Expand Down
3 changes: 3 additions & 0 deletions configs/default-config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"logging": {
"dir": "/workspaces/obcpp/logs"
},
"network": {
"gcs": {
"port": 5010
Expand Down
3 changes: 3 additions & 0 deletions configs/dev-config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"logging": {
"dir": "/workspaces/obcpp/logs"
},
"network": {
"mavlink": {
"connect": "tcp://172.17.0.1:5760"
Expand Down
2 changes: 2 additions & 0 deletions include/utilities/obc_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <string>

struct OBCConfig {
std::string logging_dir;

std::string network_mavlink_connect;
int network_gcs_port;

Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ int main(int argc, char* argv[]) {
OBCConfig config(argc, argv);

// TODO: pull logging folder from config
initLogging("/workspaces/obcpp/logs", true, argc, argv);
initLogging(config.logging_dir, true, argc, argv);

OBC obc(config);
obc.run();
Expand Down
3 changes: 3 additions & 0 deletions src/utilities/obc_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ OBCConfig::OBCConfig(int argc, char* argv[]) {
json configs = json::parse(configStream);

// Set configs
this->logging_dir = configs["logging"]["dir"];
this->network_mavlink_connect = configs["network"]["mavlink"]["connect"];
this->network_gcs_port = configs["network"]["gcs"]["port"];
} else {
Expand All @@ -29,11 +30,13 @@ OBCConfig::OBCConfig(int argc, char* argv[]) {

void OBCConfig::makeDefault() {
// Set configs
this->logging_dir = "/workspaces/obcpp/logs";
this->network_mavlink_connect = "tcp://172.17.0.1:5760";
this->network_gcs_port = 5010;

// Create default configs
json configs;
configs["logging"]["dir"] = this->logging_dir;
configs["network"]["mavlink"]["connect"] = this->network_mavlink_connect;
configs["network"]["gcs"]["port"] = this->network_gcs_port;
std::ofstream configFile(configsPath + "default-config.json");
Expand Down

0 comments on commit e008eaf

Please sign in to comment.