Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .github/workflows/mab_candle_sdk_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ jobs:
with:
python-version: "3.13"

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y python3-dev

- name: Checkout
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -140,7 +145,7 @@ jobs:

- name: Build
run: cmake --build ./build -j$(nproc)

- name: Rename artifact to arch dependant name
run: |
mv build/candlelib/libcandle.so build/candlelib/libcandle-x86_64.so
Expand Down Expand Up @@ -255,10 +260,10 @@ jobs:
- name: CMake configure
run: |
cmake -DCMAKE_BUILD_TYPE=Release -DCANDLE_BUILD_STATIC=OFF --toolchain ./cmake/linux.armhf.toolchain.cmake ./ -B build -G "Unix Makefiles" .

- name: Build
run: cmake --build ./build -j$(nproc)

- name: Rename artifact to arch dependant name
run: |
mv build/candlelib/libcandle.so build/candlelib/libcandle-armhf.so
Expand Down
17 changes: 17 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"cStandard": "c17",
"cppStandard": "gnu++20",
"intelliSenseMode": "linux-gcc-x64",
"configurationProvider": "ms-vscode.cmake-tools",
"compileCommands": "${workspaceFolder}/build/compile_commands.json"
}
],
"version": 4
}
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(CANDLESDK_VERSION_1 1)
set(CANDLESDK_VERSION_2 3)
set(CANDLESDK_VERSION_3 3)
set(CANDLESDK_VERSION_3 4)
set(CANDLESDK_VERSION
${CANDLESDK_VERSION_1}.${CANDLESDK_VERSION_2}.${CANDLESDK_VERSION_3})
add_compile_definitions(CANDLESDK_VERSION="${CANDLESDK_VERSION}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ TEST_F(CandleFrameAdapterTest, readerFailError)
std::vector<std::future<std::pair<std::vector<u8>, CANdleFrameAdapter::Error_t>>> futures;

canId_t canId = 100;
u16 timeout = 10;
u16 timeout = 20;
for (const auto& data : mockDataVector)
{
futures.push_back(std::async(std::launch::async,
Expand All @@ -110,4 +110,4 @@ TEST_F(CandleFrameAdapterTest, readerFailError)
lastResult = result.second;
}
EXPECT_EQ(CANdleFrameAdapter::Error_t::READER_TIMEOUT, lastResult);
}
}
9 changes: 5 additions & 4 deletions candletool/include/md_cli.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "MD.hpp"
#include "utilities.hpp"
#include <algorithm>
#include <filesystem>
#include <memory>
#include <optional>
#include <candle_types.hpp>
Expand Down Expand Up @@ -103,7 +104,7 @@ namespace mab

struct ConfigOptions
{
ConfigOptions(CLI::App* rootCli) : configFile(std::make_shared<std::string>(""))
ConfigOptions(CLI::App* rootCli) : configFile(std::make_shared<std::filesystem::path>(""))
{
optionsMap = std::map<std::string, CLI::Option*>{
{"file",
Expand All @@ -116,7 +117,7 @@ namespace mab
->required()}};
}

const std::shared_ptr<std::string> configFile;
const std::shared_ptr<std::filesystem::path> configFile;
std::map<std::string, CLI::Option*> optionsMap;
};

Expand Down Expand Up @@ -168,7 +169,7 @@ namespace mab
{
UpdateOptions(CLI::App* rootCli)
: fwVersion(std::make_shared<std::string>("")),
pathToMabFile(std::make_shared<std::string>("")),
pathToMabFile(std::make_shared<std::filesystem::path>("")),
recovery(std::make_shared<bool>(false)),
metadataFile(std::make_shared<std::string>(""))
{
Expand All @@ -191,7 +192,7 @@ namespace mab
"File with file metadata for managing downloads.")}};
}
const std::shared_ptr<std::string> fwVersion;
const std::shared_ptr<std::string> pathToMabFile;
const std::shared_ptr<std::filesystem::path> pathToMabFile;
const std::shared_ptr<bool> recovery;
const std::shared_ptr<std::string> metadataFile;
std::map<std::string, CLI::Option*> optionsMap;
Expand Down
42 changes: 29 additions & 13 deletions candletool/src/md_cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,25 @@
#include "flasher.hpp"
#include "web_file.hpp"

/* ERROR COLORING NOTE: may not work on all terminals! */

#ifndef WIN32

#define REDSTART "\033[1;31m"
#define GREENSTART "\033[1;32m"
#define YELLOWSTART "\033[1;33m"
#define BLUESTART "\x1b[38;5;33m"
#define RESETTEXT "\033[0m"

#else

#define REDSTART ""
#define GREENSTART ""
#define YELLOWSTART ""
#define BLUESTART ""
#define RESETTEXT ""

#endif

#define RED__(x) REDSTART x RESETTEXT
#define RED_(x) REDSTART + x + RESETTEXT

Expand Down Expand Up @@ -472,17 +484,19 @@ namespace mab
return;
}

std::string configFilePath = *downloadConfigOptions.configFile;
std::filesystem::path configFilePath = *downloadConfigOptions.configFile;
if (configFilePath.empty())
{
m_logger.error("Configuration file path is empty!");
return;
}
// If the path is not specified, prepend the standard path
if (std::find(configFilePath.begin(), configFilePath.end(), '/') ==
configFilePath.end())
std::string matchString = configFilePath.string();
if (std::find(matchString.begin(), matchString.end(), '/') ==
matchString.end() || std::find(matchString.begin(), matchString.end(), '\\') ==
matchString.end())
{
configFilePath = "/etc/candletool/config/motors/" + configFilePath;
configFilePath = std::filesystem::path(DEFAULT_CANDLETOOL_CONFIG_DIR) / std::filesystem::path("/config/motors/") / configFilePath;
}

MDConfigMap cfgMap;
Expand All @@ -491,7 +505,7 @@ namespace mab
cfgElement.m_value = registerRead(*md, regAddress).value_or("NOT FOUND");
}
// Write the configuration to the file
mINI::INIFile configFile(configFilePath);
mINI::INIFile configFile(configFilePath.string());
mINI::INIStructure ini;
for (const auto& [regAddress, cfgElement] : cfgMap.m_map)
{
Expand Down Expand Up @@ -520,24 +534,26 @@ namespace mab
auto md = getMd(mdCanId, candleBuilder);
if (md == nullptr)
{
m_logger.error("Coudl not connect to MD!");
m_logger.error("Could not connect to MD!");
return;
}

std::string configFilePath = *uploadConfigOptions.configFile;
std::filesystem::path configFilePath = *uploadConfigOptions.configFile;
if (configFilePath.empty())
{
m_logger.error("Configuration file path is empty!");
return;
}
// If the path is not specified, prepend the standard path
if (std::find(configFilePath.begin(), configFilePath.end(), '/') ==
configFilePath.end())
std::string matchString = configFilePath.string();
if (std::find(matchString.begin(), matchString.end(), '/') ==
matchString.end() || std::find(matchString.begin(), matchString.end(), '\\') ==
matchString.end())
{
configFilePath = "/etc/candletool/config/motors/" + configFilePath;
configFilePath = std::filesystem::path(DEFAULT_CANDLETOOL_CONFIG_DIR) / std::filesystem::path("/config/motors/") / configFilePath;
}

mINI::INIFile configFile(configFilePath);
mINI::INIFile configFile(configFilePath.string());
mINI::INIStructure ini;
if (!configFile.read(ini))
{
Expand Down Expand Up @@ -1153,7 +1169,7 @@ namespace mab
else
{
m_logger.info("Overriding download of file. Using local provided path.");
MabFileParser mabFile(*updateOptions.pathToMabFile,
MabFileParser mabFile(updateOptions.pathToMabFile->string(),
MabFileParser::TargetDevice_E::MD);

if (*(updateOptions.recovery) == false)
Expand Down
4 changes: 3 additions & 1 deletion examples/py/md_impedance.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
# Initialize CANdle on the USB bus (SPI bus not supported yet)
candle = pc.attachCandle(pc.CANdleDatarate_E.CAN_DATARATE_1M, pc.busTypes_t.USB)

md_id = pc.discoverMDs(candle)[0] # Discover MDs and take the first one

# Create virual MD representation
md = pc.MD(100, candle)
md = pc.MD(md_id, candle)

# Initialize it to see if it connects
err = md.init()
Expand Down
2 changes: 1 addition & 1 deletion pycandle/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ project(pyCandle)

set(CMAKE_BUILD_TYPE Release)

find_package(Python COMPONENTS Interpreter REQUIRED)
find_package(Python COMPONENTS Interpreter Development.Module)
add_subdirectory(3rd_party/pybind11)
message(${CMAKE_SOURCE_DIR})
pybind11_add_module(pyCandle MODULE src/bindings.cpp)
Expand Down
2 changes: 2 additions & 0 deletions pycandle/src/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,8 @@ PYBIND11_MODULE(pyCandle, m)
py::arg("regName"),
py::arg("value"),
"Write a register to the MD device.");
m.def("discoverMDs", &mab::MD::discoverMDs, "Discover MD devices connected to the system.");


// Logger
py::enum_<Logger::Verbosity_E>(m, "Verbosity_E")
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ build-backend = "scikit_build_core.build"

[project]
name = "candlesdk"
version = "1.3.3"
version = "1.3.4"
dependencies = ["cmake"]
requires-python = ">= 3.10"
authors = [{ name = "MAB Robotics", email = "support@mabrobotics.pl" }]
Expand Down
Loading