Motion Master 6.0.0-alpha.50
Next-generation motion control software
Loading...
Searching...
No Matches
pdo_mapping.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <nlohmann/json_fwd.hpp>
5#include <vector>
6
7namespace mm::node {
8
27 uint16_t index = 0;
28 uint8_t subindex = 0;
29 uint8_t bitLength = 0;
30 uint32_t bitOffset =
31 0;
32};
33
39inline uint32_t packMappingEntry(const PdoMappingEntry& e) {
40 return (static_cast<uint32_t>(e.index) << 16) | (static_cast<uint32_t>(e.subindex) << 8) |
41 static_cast<uint32_t>(e.bitLength);
42}
43
48inline PdoMappingEntry unpackMappingEntry(uint32_t packed) {
49 return PdoMappingEntry{
50 .index = static_cast<uint16_t>(packed >> 16),
51 .subindex = static_cast<uint8_t>((packed >> 8) & 0xFF),
52 .bitLength = static_cast<uint8_t>(packed & 0xFF),
53 };
54}
55
63 std::vector<PdoMappingEntry> outputs;
64 std::vector<PdoMappingEntry> inputs;
65 uint32_t outputBits = 0;
66 uint32_t inputBits = 0;
67};
68
76 uint16_t pdoIndex = 0;
77 std::vector<PdoMappingEntry> entries;
78};
79
89struct PdoMapping {
90 std::vector<PdoMappingObject> outputs;
91 std::vector<PdoMappingObject> inputs;
92};
93
95void to_json(nlohmann::json& j, const PdoMappingEntry& e);
96
98void to_json(nlohmann::json& j, const PdoMappingObject& o);
99
102void to_json(nlohmann::json& j, const PdoMapping& m);
103
104} // namespace mm::node
Definition http_server.h:16
void to_json(nlohmann::json &j, const Device &d)
Serialises a Device to JSON.
Definition device.cc:915
PdoMappingEntry unpackMappingEntry(uint32_t packed)
Unpacks a 32-bit CoE mapping word into an entry — the inverse of packMappingEntry.
Definition pdo_mapping.h:48
uint32_t packMappingEntry(const PdoMappingEntry &e)
Packs an entry into its 32-bit CoE mapping word (ETG.1000.6 §5.6.7.4.7): index<<16 | subindex<<8 | bi...
Definition pdo_mapping.h:39
A device's complete PDO mapping across both directions.
Definition pdo_mapping.h:62
uint32_t inputBits
Total mapped input bits.
Definition pdo_mapping.h:66
uint32_t outputBits
Total mapped output bits (sum of entry widths).
Definition pdo_mapping.h:65
std::vector< PdoMappingEntry > inputs
TxPDO entries (slave→master), in window order.
Definition pdo_mapping.h:64
std::vector< PdoMappingEntry > outputs
RxPDO entries (master→slave), in window order.
Definition pdo_mapping.h:63
One object mapped into a slave's process data, with its position in the window.
Definition pdo_mapping.h:26
uint32_t bitOffset
Bit offset from the slave's direction window (read-only; 0 on write).
Definition pdo_mapping.h:30
uint8_t bitLength
Width of the entry in bits (the packed 7..0 field; max 255).
Definition pdo_mapping.h:29
uint16_t index
CoE object index; 0x0000 marks a padding gap (no object).
Definition pdo_mapping.h:27
uint8_t subindex
CoE object subindex.
Definition pdo_mapping.h:28
One PDO mapping object (0x16xx RxPDO / 0x1Axx TxPDO) and its ordered entries.
Definition pdo_mapping.h:75
std::vector< PdoMappingEntry > entries
Entries in the order they are mapped.
Definition pdo_mapping.h:77
uint16_t pdoIndex
Mapping-object index (0x16xx or 0x1Axx).
Definition pdo_mapping.h:76
A device's desired PDO configuration to write and assign — the write-side input to Device::writePdoMa...
Definition pdo_mapping.h:89
std::vector< PdoMappingObject > outputs
RxPDO objects, assigned to 0x1C12.
Definition pdo_mapping.h:90
std::vector< PdoMappingObject > inputs
TxPDO objects, assigned to 0x1C13.
Definition pdo_mapping.h:91