|
CANOPEN_CLIENT Driver 0.1.0
API reference
|
The CANopen frame codecs: pure functions that build and decode NMT, SYNC, SDO, heartbeat, EMCY and PDO frames and the drive statusword. No I/O, no state. More...
#include <array>#include <cstddef>#include <cstdint>#include <span>#include "canopen_client_detail.hpp"#include "canopen_client_types.hpp"Go to the source code of this file.
Namespaces | |
| namespace | canopen_client |
The CANopen client driver: everything it declares lives here; internals in detail. | |
Functions | |
| constexpr bool | canopen_client::IsNodeId (uint8_t node) noexcept |
| Whether a node identifier is in 1 to 127. | |
| constexpr uint16_t | canopen_client::SdoRequestId (uint8_t node) noexcept |
The identifier of the SDO request frames to node. | |
| constexpr uint16_t | canopen_client::SdoResponseId (uint8_t node) noexcept |
The identifier of the SDO reply frames from node. | |
| constexpr uint16_t | canopen_client::HeartbeatId (uint8_t node) noexcept |
The identifier of the heartbeat and node-guarding frames of node. | |
| constexpr uint16_t | canopen_client::EmcyId (uint8_t node) noexcept |
The identifier of the emergency frames of node. | |
| constexpr bool | canopen_client::IsNmtCommand (uint8_t command) noexcept |
| Whether a command byte is one of the five NMT commands. | |
| constexpr bool | canopen_client::DecodeNmtState (uint8_t raw, NmtState &state) noexcept |
| Decode the state byte of a heartbeat (bit 7 already cleared). | |
| constexpr Result< CanFrame > | canopen_client::MakeNmtFrame (NmtCommand command, uint8_t node) noexcept |
| The NMT command frame: identifier 0x000, two data bytes. | |
| constexpr Result< CanFrame > | canopen_client::MakeSyncFrame (uint8_t counter) noexcept |
| The SYNC frame: identifier 0x080, no data, or one counter byte. | |
| constexpr Result< CanFrame > | canopen_client::MakeGuardRequest (uint8_t node) noexcept |
| The node-guarding request: a remote frame on 0x700 + node. | |
| constexpr Result< CanFrame > | canopen_client::MakePdoFrame (uint16_t cob_id, std::span< const uint8_t > data) noexcept |
| A PDO frame: a valid identifier and 0 to 8 data bytes. | |
| constexpr Result< CanFrame > | canopen_client::MakeSdoUploadRequest (uint8_t node, uint16_t index, uint8_t sub) noexcept |
| The initiate-upload request (read an object): command byte 0x40. | |
| constexpr Result< CanFrame > | canopen_client::MakeSdoExpeditedDownload (uint8_t node, uint16_t index, uint8_t sub, std::span< const uint8_t > data) noexcept |
| The expedited initiate-download request (write 1 to 4 bytes): command byte 0x23 | (4 - size) << 2. | |
| constexpr Result< CanFrame > | canopen_client::MakeSdoSegmentedDownload (uint8_t node, uint16_t index, uint8_t sub, uint32_t size) noexcept |
The segmented initiate-download request announcing size bytes: command byte 0x21. | |
| constexpr Result< CanFrame > | canopen_client::MakeSdoDownloadSegment (uint8_t node, bool toggle, std::span< const uint8_t > data, bool last) noexcept |
| One download segment: command byte toggle << 4 | (7 - length) << 1 | last. | |
| constexpr Result< CanFrame > | canopen_client::MakeSdoUploadSegmentRequest (uint8_t node, bool toggle) noexcept |
| The request for the next upload segment: command byte 0x60 | toggle << 4. | |
| constexpr Result< CanFrame > | canopen_client::MakeSdoAbort (uint8_t node, uint16_t index, uint8_t sub, uint32_t code) noexcept |
| The abort frame the client sends to end a transfer: command byte 0x80. | |
| constexpr Result< SdoReply > | canopen_client::ParseSdoReply (const CanFrame &frame, bool strict) noexcept |
| Decode a frame from an SDO server (identifier 0x580 + node). | |
| constexpr Result< HeartbeatInfo > | canopen_client::ParseHeartbeat (const CanFrame &frame) noexcept |
| Decode a heartbeat, boot-up or node-guarding reply: identifier 0x701 to 0x77F, one byte. | |
| constexpr Result< EmcyEvent > | canopen_client::ParseEmcy (const CanFrame &frame) noexcept |
| Decode an emergency message: identifier 0x081 to 0x0FF, eight bytes (error code, error register, five manufacturer bytes). The timestamp is left 0 for the caller. | |
| constexpr Result< uint16_t > | canopen_client::PdoCommunicationIndex (PdoKind kind, uint16_t number) noexcept |
| The index of the communication parameter record of a PDO. | |
| constexpr Result< uint16_t > | canopen_client::PdoMappingIndex (PdoKind kind, uint16_t number) noexcept |
| The index of the mapping parameter record of a PDO. | |
| constexpr uint32_t | canopen_client::EncodePdoMapEntry (const PdoMapEntry &entry) noexcept |
| The 32-bit mapping record: index << 16 | sub-index << 8 | length in bits. | |
| constexpr PdoMapEntry | canopen_client::DecodePdoMapEntry (uint32_t record) noexcept |
| Split a 32-bit mapping record into its object and length. | |
| constexpr Error | canopen_client::ValidatePdoConfig (const PdoConfig &config) noexcept |
Check a PDO configuration: identifier range, a transmission type that is not reserved (241 to 251), 0 to kMaxPdoEntries entries, each of 1 to 64 bits at a non-zero index, and at most 64 bits in all. | |
| constexpr uint32_t | canopen_client::PdoBitLength (const PdoConfig &config) noexcept |
| The bits the entries of a PDO occupy in all. | |
| constexpr Result< uint64_t > | canopen_client::ExtractBits (std::span< const uint8_t > data, uint32_t offset, uint32_t bits) noexcept |
Read bits bits starting at bit offset of a PDO payload (Intel bit order: bit 0 is the least significant bit of byte 0). | |
| constexpr Result< void > | canopen_client::InsertBits (std::span< uint8_t > data, uint32_t offset, uint32_t bits, uint64_t value) noexcept |
Write the low bits bits of value at bit offset of a PDO payload; the other bits are unchanged. | |
| constexpr DriveState | canopen_client::DecodeStatusword (uint16_t statusword) noexcept |
| Decode the drive state from a statusword (object 0x6041): the masks 0x4F and 0x6F of the state machine, matched exactly. | |
| constexpr bool | canopen_client::EnableStepControlword (DriveState state, uint16_t &word) noexcept |
| The controlword that moves a drive one step toward Operation enabled. | |
The CANopen frame codecs: pure functions that build and decode NMT, SYNC, SDO, heartbeat, EMCY and PDO frames and the drive statusword. No I/O, no state.
Every builder validates its arguments and returns Error::InvalidArgument for a bad one, so no frame with a wrong identifier or length is ever built. Every decoder validates the frame it reads (identifier, length, command specifier) and returns Error::InvalidFrame for a frame that does not fit; it never reads past dlc. The fuzz target drives them with arbitrary frames.