From 31e689c389e57bd1e573dcae8764f171e35ad7db Mon Sep 17 00:00:00 2001 From: Emran Billah Date: Thu, 1 Aug 2024 12:59:13 -0300 Subject: [PATCH] Adding .env file and better log messages --- .env | 2 ++ docker-compose-flash-device.yml | 4 ++-- xbeemav/src/XBeeSetup.cpp | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 0000000..e60bc79 --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +DEVICE_PATH=/dev/ttyUSB1 +BAUD_RATE=230400 \ No newline at end of file diff --git a/docker-compose-flash-device.yml b/docker-compose-flash-device.yml index edc40e5..b6ca7d0 100644 --- a/docker-compose-flash-device.yml +++ b/docker-compose-flash-device.yml @@ -2,11 +2,11 @@ version: "3.8" services: xbee-mav: - command: rosrun xbee_ros_node xbee_config /dev/ttyUSB0 230400 + command: rosrun xbee_ros_node xbee_config ${DEVICE_PATH} ${BAUD_RATE} build: context: . dockerfile: Dockerfile devices: - - /dev/ttyUSB0:/dev/ttyUSB0 + - ${DEVICE_PATH}:${DEVICE_PATH} diff --git a/xbeemav/src/XBeeSetup.cpp b/xbeemav/src/XBeeSetup.cpp index 417e1cd..f984c9a 100644 --- a/xbeemav/src/XBeeSetup.cpp +++ b/xbeemav/src/XBeeSetup.cpp @@ -13,9 +13,11 @@ bool setupXBee(const std::string &device_port, const unsigned int baud_rate) { XBeeModule xbee_module; XMLConfigParser config_parser; + std::string argsStr = "device_port: " + device_port + ", baud_rate: " + std::to_string(baud_rate); + // Init port at specified baud rate if (!xbee_module.Init_Port(device_port, baud_rate)) { - std::cout << "XBee Configuration Failed. Could not Init_Port." << std::endl; + std::cout << "XBee Configuration Failed. Could not Init_Port. " << argsStr << std::endl; return false; } @@ -34,7 +36,7 @@ bool setupXBee(const std::string &device_port, const unsigned int baud_rate) { } // Flash config params to device - std::cout << "Connected to XBee. Flashing Config File..." << std::endl; + std::cout << "Connected to XBee on port: " << argsStr << ". Flashing Config File..." << std::endl; std::vector *config_parameters = config_parser.Get_Loaded_Parameters(); for (auto& param : *config_parameters) { std::string current_command = "";