A C++20 CANopen host client for HardFOC Vortex devices: NMT commands and expedited SDO writes with named CiA 301 and CiA 402 objects, over a CAN transport you provide.
Documentation: https://hardfoc.github.io/hf-vortex-driver/
Implement VortexCanTransport::send() for your CAN driver
(Porting), then:
#include "vortex/VortexHostSession.hpp"
#include "vortex/VortexProtocol.hpp"
using namespace hf::vortex;
// Put node 5 in Operational and select CiA 402 profile velocity mode (3).
bool start_node_in_velocity_mode(VortexCanTransport& bus) {
VortexHostSession session(bus);
constexpr std::uint8_t kNode = 5;
if (!session.sendNmt(NmtCommand::Start, kNode)) { // 0x000: 01 05
return false; // transport refused the frame
}
return session.sdoDownloadExpedited(kNode, kIdxModesOfOperation, // 0x605: 2F 60 60 00 03
/*sub=*/0, /*value=*/3, /*size=*/1);
}sendNmt(): Start, Stop, Pre-operational, Reset node, Reset communication, to one node or all.sdoDownloadExpedited(): writes 1, 2 or 4 bytes to any object, with the CiA 301 command specifier.- Named objects: controlword, statusword, modes of operation, actual position and velocity, error register, a HardFOC vendor range.
- One virtual method to port; a
BaseCanadapter is ten lines. - No heap, no threads, no RTOS; transmit only (read responses with hf-utils-canopen or CANopenNode).
git submodule add https://github.com/hardfoc/hf-vortex-driver.git external/hf-vortex-driveradd_subdirectory(external/hf-vortex-driver)
target_link_libraries(my_app PRIVATE hf_vortex_driver)| Quickstart | Wire the bus, write the transport, start a node |
| Hardware | Bus settings, COB-IDs, frame bytes, objects |
| API guide | NMT, SDO, the CiA 402 state machine |
| Porting | The transport contract and a BaseCan adapter |
| API reference | Doxygen |
cmake -B build -S . -DHF_VORTEX_BUILD_DOC_SNIPPETS=ON && cmake --build build && ctest --test-dir buildGPL-3.0; see LICENSE.