34#ifndef _OPENLCB_CANDEFS_HXX_
35#define _OPENLCB_CANDEFS_HXX_
95 typedef uint16_t CanMTI;
132 enum AddressedPayloadFlags
134 NOT_FIRST_FRAME = 0x20,
135 NOT_LAST_FRAME = 0x10,
226 static void set_mti(uint32_t *can_id, CanMTI mti)
228 *can_id &= ~MTI_MASK;
238 *can_id &= ~SRC_MASK;
248 *can_id &= ~DST_MASK;
258 *can_id &= ~CAN_FRAME_TYPE_MASK;
268 *can_id &= ~FRAME_TYPE_MASK;
278 *can_id &= ~PRIORITY_MASK;
344 static NodeAlias get_control_src(uint32_t can_id)
353 static unsigned int get_control_sequence(uint32_t can_id)
366 NodeAlias src, uint16_t field,
int sequence)
uint64_t NodeID
48-bit NMRAnet Node ID type
uint16_t NodeAlias
Alias to a 48-bit NMRAnet Node ID type.
Static values and helper functions for CAN-bus interfaces.
static bool is_cid_frame(uint32_t can_id)
Tests if the incoming frame is a CID frame.
static CanFrameType get_can_frame_type(uint32_t can_id)
Get the CAN frame type field value of the CAN ID.
static void set_mti(uint32_t *can_id, CanMTI mti)
Set the MTI field value of the CAN ID.
static uint32_t can_identifier(Defs::MTI mti, NodeAlias src)
Get the CAN identifier from an NMRAnet mti and source alias.
static NodeID get_reserved_alias_node_id(NodeAlias alias)
Computes a reserved alias node ID for the local alias cache map.
FrameType
Frame Types, Control or normal NMRAnet message.
@ NMRANET_MSG
normal NMRAnet message
@ CONTROL_MSG
CAN control frame message.
CanDefs()
This class should not be instantiated.
static void set_dst(uint32_t *can_id, NodeAlias dst)
Set the destination field value of the CAN ID.
static ControlField get_control_field(uint32_t can_id)
Get the control field of a can control frame.
static void set_frame_type(uint32_t *can_id, FrameType type)
Set the frame type field value of the CAN ID.
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 NodeAlias get_dst(uint32_t can_id)
Get the destination 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 uint32_t set_control_fields(NodeAlias src, uint16_t field, int sequence)
Initialize a control frame CAN ID and set DLC to 0.
static CanMTI get_mti(uint32_t can_id)
Get the MTI field value of the CAN ID.
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.
AliasStatus
Status value for an alias pool item.
@ RESERVED
the alias has been reserved for use
@ CONFLICT
we discovered someone else already is using this alias
@ FREE
the alias is free for another request
@ UNDER_TEST
this is an alias we are trying to claim
@ AMD_FRAME
Alias Map Definition frame.
@ AME_FRAME
Alias Mapping Enquiry.
@ RID_FRAME
Reserve ID Frame.
@ AMR_FRAME
Alias Map Reset.
ReservedAliasNodeId
Constants used in the LocalAliasCache for reserved but not used aliases.
@ RESERVED_ALIAS_NODE_MASK
Mask for the reserved aliases.
@ RESERVED_ALIAS_NODE_BITS
To mark a reserved alias in the local alias cache, we use this as a node ID and add the alias to the ...
static void set_src(uint32_t *can_id, NodeAlias src)
Set the source field value of the CAN ID.
static Priority get_priority(uint32_t can_id)
Get the priority 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 bool is_reserved_alias_node_id(NodeID id)
Tests if a node ID is a reserved alias Node ID.
CanFrameType
CAN Frame Types.
@ DATAGRAM_MIDDLE_FRAME
middle frame of multi-frame datagram
@ DATAGRAM_FINAL_FRAME
last frame of multi-frame datagram
@ DATAGRAM_FIRST_FRAME
first frame of multi-frame datagram
@ GLOBAL_ADDRESSED
most CAN frame types fall in this category
@ STREAM_DATA
stream data frame
@ DATAGRAM_ONE_FRAME
a single frame datagram
Priority
Highest order priority of a CAN message.
@ HIGH_PRIORITY
high priority CAN message
@ NORMAL_PRIORITY
normal priority CAN message
static NodeAlias get_src(uint32_t can_id)
Get the source field value of the CAN ID.
static Defs::MTI nmranet_mti(uint32_t can_id)
Get the NMRAnet MTI from a can identifier.
static bool is_stream_frame(uint32_t can_id)
Tests if the incoming frame is a stream data send frame.
static void set_priority(uint32_t *can_id, Priority priority)
Set the priority field value of the CAN ID.
ID
CAN ID bit fields for most CAN frames.
@ FRAME_TYPE_MASK
mask for frame type field of CAN ID
@ SRC_MASK
mask for source field of CAN ID
@ FRAME_TYPE_SHIFT
shift for frame type field of CAN ID
@ PADDING_MASK
mask for padding field of CAN ID
@ CONTROL_PRIORITY_MASK
priority mask
@ CONTROL_FIELD_MASK
control field data mask
@ CONTROL_SRC_MASK
source alias mask
@ CONTROL_SEQUENCE_SHIFT
frame sequence number shift
@ MTI_MASK
mask for MTI field of CAN ID
@ CONTROL_FIELD_SHIFT
control field data shift
@ CONTROL_SEQUENCE_MASK
frame sequence number mask
@ CONTROL_SRC_SHIFT
source alias shift
@ CONTROL_PRIORITY_SHIFT
priority shift
@ STREAM_DG_RECV_MASK
mask for receiving datagram and stream frames.
@ CAN_FRAME_TYPE_SHIFT
shift for can frame type field of CAN ID
@ CAN_FRAME_TYPE_MASK
mask for can frame type field of CAN ID
@ CONTROL_TYPE_SHIFT
value of '0' means control frame shift
@ CONTROL_PADDING_MASK
pad out to a full 32-bit word
@ CONTROL_PADDING_SHIFT
pad out to a full 32-bit word
@ PADDING_SHIFT
shift for padding field of CAN ID
@ PRIORITY_SHIFT
shift for priority field of CAN ID
@ DST_MASK
mask for MTI field of CAN ID
@ PRIORITY_MASK
mask for priority field of CAN ID
@ MTI_SHIFT
shift for MTI field of CAN ID
@ DST_SHIFT
shift for MTI field of CAN ID
@ CONTROL_TYPE_MASK
value of '0' means control frame mask
@ SRC_SHIFT
shift for source field of 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.
MTI
Known Message type indicators.