|
Open Model Railroad Network (OpenMRN)
|
Static values and helper functions for CAN-bus interfaces. More...
#include <CanDefs.hxx>
Public Types | |
| enum | AliasStatus { UNDER_TEST , RESERVED , CONFLICT , FREE } |
| Status value for an alias pool item. More... | |
| enum | ID { SRC_MASK = 0x00000fff , MTI_MASK = 0x00fff000 , DST_MASK = 0x00fff000 , CAN_FRAME_TYPE_MASK = 0x07000000 , FRAME_TYPE_MASK = 0x08000000 , PRIORITY_MASK = 0x10000000 , PADDING_MASK = 0xe0000000 , STREAM_DG_RECV_MASK = 0x0fffffff , SRC_SHIFT = 0 , MTI_SHIFT = 12 , DST_SHIFT = 12 , CAN_FRAME_TYPE_SHIFT = 24 , FRAME_TYPE_SHIFT = 27 , PRIORITY_SHIFT = 28 , PADDING_SHIFT = 29 , CONTROL_SRC_MASK = 0x00000fff , CONTROL_FIELD_MASK = 0x07fff000 , CONTROL_SEQUENCE_MASK = 0x07000000 , CONTROL_TYPE_MASK = 0x08000000 , CONTROL_PRIORITY_MASK = 0x10000000 , CONTROL_PADDING_MASK = 0xe0000000 , CONTROL_SRC_SHIFT = 0 , CONTROL_FIELD_SHIFT = 12 , CONTROL_SEQUENCE_SHIFT = 24 , CONTROL_TYPE_SHIFT = 27 , CONTROL_PRIORITY_SHIFT = 28 , CONTROL_PADDING_SHIFT = 29 } |
| CAN ID bit fields for most CAN frames. More... | |
| enum | CanFrameType { GLOBAL_ADDRESSED = 1 , DATAGRAM_ONE_FRAME = 2 , DATAGRAM_FIRST_FRAME = 3 , DATAGRAM_MIDDLE_FRAME = 4 , DATAGRAM_FINAL_FRAME = 5 , STREAM_DATA = 7 } |
| CAN Frame Types. More... | |
| enum | FrameType { CONTROL_MSG = 0 , NMRANET_MSG = 1 } |
| Frame Types, Control or normal NMRAnet message. More... | |
| enum | Priority { HIGH_PRIORITY = 0 , NORMAL_PRIORITY = 1 } |
| Highest order priority of a CAN message. More... | |
| enum | ControlField { RID_FRAME = 0x0700 , AMD_FRAME = 0x0701 , AME_FRAME = 0x0702 , AMR_FRAME = 0x0703 } |
| enum | AddressedPayloadFlags { NOT_FIRST_FRAME = 0x20 , NOT_LAST_FRAME = 0x10 } |
| enum | ReservedAliasNodeId { RESERVED_ALIAS_NODE_BITS = 0xF000 , RESERVED_ALIAS_NODE_MASK = 0xFFFFFFFFF000 } |
| Constants used in the LocalAliasCache for reserved but not used aliases. More... | |
| typedef uint16_t | CanMTI |
Static Public Member Functions | |
| static NodeAlias | get_src (uint32_t can_id) |
| Get the source field value of the CAN ID. | |
| static CanMTI | get_mti (uint32_t can_id) |
| Get the MTI field value of the CAN ID. | |
| static NodeAlias | get_dst (uint32_t can_id) |
| Get the destination field value of the CAN ID. | |
| static CanFrameType | get_can_frame_type (uint32_t can_id) |
| Get the CAN frame type field value of the CAN ID. | |
| static FrameType | get_frame_type (uint32_t can_id) |
| Get the frame type field value of the CAN ID. | |
| static Priority | get_priority (uint32_t can_id) |
| Get the priority field value of the CAN ID. | |
| static bool | is_cid_frame (uint32_t can_id) |
| Tests if the incoming frame is a CID frame. | |
| static bool | is_stream_frame (uint32_t can_id) |
| Tests if the incoming frame is a stream data send frame. | |
| static void | set_mti (uint32_t *can_id, CanMTI mti) |
| Set the MTI field value of the CAN ID. | |
| static void | set_src (uint32_t *can_id, NodeAlias src) |
| Set the source field value of the CAN ID. | |
| static void | set_dst (uint32_t *can_id, NodeAlias dst) |
| Set the destination field value of the CAN ID. | |
| static void | set_can_frame_type (uint32_t *can_id, CanFrameType type) |
| Set the CAN frame type field value of the CAN ID. | |
| static void | set_frame_type (uint32_t *can_id, FrameType type) |
| Set the frame type field value of the CAN ID. | |
| static void | set_priority (uint32_t *can_id, Priority priority) |
| Set the priority field value of the CAN ID. | |
| static void | set_fields (uint32_t *can_id, NodeAlias src, Defs::MTI mti, CanFrameType can_type, FrameType type, Priority priority) |
| Set all the CAN ID fields. | |
| static void | set_datagram_fields (uint32_t *can_id, NodeAlias src, NodeAlias dst, CanFrameType can_type) |
| Set all the CAN ID fields for datagram or stream message. | |
| static Defs::MTI | nmranet_mti (uint32_t can_id) |
| Get the NMRAnet MTI from a can identifier. | |
| static uint32_t | can_identifier (Defs::MTI mti, NodeAlias src) |
| Get the CAN identifier from an NMRAnet mti and source alias. | |
| static ControlField | get_control_field (uint32_t can_id) |
| Get the control field of a can control frame. | |
| static uint32_t | set_control_fields (NodeAlias src, uint16_t field, int sequence) |
| Initialize a control frame CAN ID and set DLC to 0. | |
| static void | control_init (struct can_frame &frame, NodeAlias src, uint16_t field, int sequence) |
| Initialize a control frame CAN ID and set DLC to 0. | |
| static NodeID | get_reserved_alias_node_id (NodeAlias alias) |
| Computes a reserved alias node ID for the local alias cache map. | |
| static bool | is_reserved_alias_node_id (NodeID id) |
| Tests if a node ID is a reserved alias Node ID. | |
Private Member Functions | |
| CanDefs () | |
| This class should not be instantiated. | |
Static values and helper functions for CAN-bus interfaces.
Definition at line 47 of file CanDefs.hxx.
| typedef uint16_t openlcb::CanDefs::CanMTI |
Definition at line 95 of file CanDefs.hxx.
| enum openlcb::CanDefs::AddressedPayloadFlags |
Definition at line 132 of file CanDefs.hxx.
Status value for an alias pool item.
Definition at line 50 of file CanDefs.hxx.
CAN Frame Types.
Definition at line 98 of file CanDefs.hxx.
| Enumerator | |
|---|---|
| RID_FRAME | Reserve ID Frame. |
| AMD_FRAME | Alias Map Definition frame. |
| AME_FRAME | Alias Mapping Enquiry. |
| AMR_FRAME | Alias Map Reset. |
Definition at line 124 of file CanDefs.hxx.
Frame Types, Control or normal NMRAnet message.
| Enumerator | |
|---|---|
| CONTROL_MSG | CAN control frame message. |
| NMRANET_MSG | normal NMRAnet message |
Definition at line 109 of file CanDefs.hxx.
| enum openlcb::CanDefs::ID |
CAN ID bit fields for most CAN frames.
Definition at line 60 of file CanDefs.hxx.
Highest order priority of a CAN message.
Most messages fall into the NORMAL_PRIORITY category.
| Enumerator | |
|---|---|
| HIGH_PRIORITY | high priority CAN message |
| NORMAL_PRIORITY | normal priority CAN message |
Definition at line 118 of file CanDefs.hxx.
Constants used in the LocalAliasCache for reserved but not used aliases.
Definition at line 140 of file CanDefs.hxx.
Get the CAN identifier from an NMRAnet mti and source alias.
| mti | NMRAnet MTI |
| src | Source node alias |
Definition at line 69 of file CanDefs.cxx.
|
inlinestatic |
Initialize a control frame CAN ID and set DLC to 0.
| _frame | control frame to initialize |
| _source | source data |
| _field | field data |
| _sequence | sequence data |
Definition at line 379 of file CanDefs.hxx.
|
inlinestatic |
Get the CAN frame type field value of the CAN ID.
| can_id | identifier to act upon |
Definition at line 181 of file CanDefs.hxx.
|
inlinestatic |
Get the control field of a can control frame.
This includes the sequence number and the variable field.
| can_id | CAN ID of the control frame |
Definition at line 334 of file CanDefs.hxx.
|
inlinestatic |
Get the destination field value of the CAN ID.
| can_id | identifier to act upon |
Definition at line 172 of file CanDefs.hxx.
|
inlinestatic |
Get the frame type field value of the CAN ID.
| can_id | identifier to act upon |
Definition at line 190 of file CanDefs.hxx.
|
inlinestatic |
Get the MTI field value of the CAN ID.
| can_id | identifier to act upon |
Definition at line 163 of file CanDefs.hxx.
|
inlinestatic |
Get the priority field value of the CAN ID.
| can_id | identifier to act upon |
Definition at line 199 of file CanDefs.hxx.
Computes a reserved alias node ID for the local alias cache map.
| alias | the alias to reserve |
Definition at line 389 of file CanDefs.hxx.
|
inlinestatic |
Get the source field value of the CAN ID.
| can_id | identifier to act upon |
Definition at line 154 of file CanDefs.hxx.
|
inlinestatic |
Tests if the incoming frame is a CID frame.
| can_id | identifier to act upon |
Definition at line 208 of file CanDefs.hxx.
Tests if a node ID is a reserved alias Node ID.
| id | node id to test |
Definition at line 397 of file CanDefs.hxx.
|
inlinestatic |
Tests if the incoming frame is a stream data send frame.
| can_id | identifier to act upon |
Definition at line 217 of file CanDefs.hxx.
|
static |
Get the NMRAnet MTI from a can identifier.
| can_id | CAN identifider |
Definition at line 43 of file CanDefs.cxx.
|
inlinestatic |
Set the CAN frame type field value of the CAN ID.
| can_id | identifier to act upon, passed by reference |
| type | CAN frame type field value |
Definition at line 256 of file CanDefs.hxx.
|
inlinestatic |
Initialize a control frame CAN ID and set DLC to 0.
| src | source node alias |
| field | control field data (e.g. AME_FRAME) |
| sequence | sequence number or zero if not CID frame |
Definition at line 365 of file CanDefs.hxx.
|
inlinestatic |
Set all the CAN ID fields for datagram or stream message.
| can_id | identifier to act upon |
| source | source alias |
| dst | desitnation alias |
| can_type | CAN frame type field value |
Definition at line 305 of file CanDefs.hxx.
|
inlinestatic |
Set the destination field value of the CAN ID.
| can_id | identifier to act upon, passed by reference |
| dst | destination field value |
Definition at line 246 of file CanDefs.hxx.
|
inlinestatic |
Set all the CAN ID fields.
| can_id | identifier to act upon |
| source | source field value |
| mti | MTI field value |
| can_type | CAN frame type field value |
| type | frame type field value |
| priority | priority field value |
Definition at line 290 of file CanDefs.hxx.
|
inlinestatic |
Set the frame type field value of the CAN ID.
| can_id | identifier to act upon, passed by reference |
| type | frame type field value |
Definition at line 266 of file CanDefs.hxx.
|
inlinestatic |
Set the MTI field value of the CAN ID.
| can_id | identifier to act upon, passed by reference |
| mti | MTI field value |
Definition at line 226 of file CanDefs.hxx.
|
inlinestatic |
Set the priority field value of the CAN ID.
| can_id | identifier to act upon, passed by reference |
| priority | pryority field value |
Definition at line 276 of file CanDefs.hxx.
|
inlinestatic |
Set the source field value of the CAN ID.
| can_id | identifier to act upon, passed by pointer |
| src | source field value |
Definition at line 236 of file CanDefs.hxx.