Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
dcc::RailcomDefs Struct Reference

Special constant values returned by the railcom_decode[] array. More...

#include <RailCom.hxx>

Public Types

enum  {
  INV = 0xff , ACK = 0xfe , NACK = 0xfd , BUSY = 0xfc ,
  RESVD1 = 0xfb , RESVD2 = 0xfa
}
 
enum  { CODE_ACK = 0xf0 , CODE_ACK2 = 0x0f , CODE_NACK = 0x3c , CODE_BUSY = 0xE1 }
 

Static Public Member Functions

static uint16_t encode12 (uint8_t nibble, uint8_t data)
 Encodes 12 bits of useful payload into 16 bits of UART data to transmit.
 
static void append12 (uint8_t nibble, uint8_t data, uint8_t *dst)
 Encodes 12 bits of useful payload into 16 bits of UART data to transmit.
 
static void append36 (uint8_t nibble, uint32_t data, uint8_t *dst)
 Encodes a 36-bit railcom datagram into UART bytes.
 
static void add_did_feedback (uint64_t decoder_id, Feedback *fb)
 Creates a Logon Enable feedback with the decoder unique ID.
 
static void add_shortinfo_feedback (uint16_t requested_address, uint8_t max_fn, uint8_t psupp, uint8_t ssupp, Feedback *fb)
 Creates a ShortInfo feedback.
 
static void add_assign_feedback (uint8_t changeflags, uint16_t changecount, uint8_t supp2, uint8_t supp3, Feedback *fb)
 Creates a Logon Assign feedback.
 

Private Member Functions

 RailcomDefs ()
 This struct cannot be instantiated.
 

Detailed Description

Special constant values returned by the railcom_decode[] array.

Definition at line 94 of file RailCom.hxx.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
INV 

invalid value (not conforming to the 4bit weighting requirement)

ACK 

Railcom ACK; the decoder received the message ok.

NOTE: There are two codepoints that map to this.

NACK 

The decoder rejected the packet.

BUSY 

The decoder is busy; send the packet again.

This is typically returned when a POM CV write is still pending; the caller must re-try sending the packet later.

RESVD1 

Reserved for future expansion.

RESVD2 

Reserved for future expansion.

Definition at line 97 of file RailCom.hxx.

◆ anonymous enum

anonymous enum
Enumerator
CODE_ACK 

Code point for ACK (according to RCN-217)

CODE_ACK2 

Another accepted code point for ACK (according to RCN-217)

CODE_NACK 

Code point for NACK (according to RCN-217)

CODE_BUSY 

Code point for BUSY (according to NMRA S-9.3.2)

Definition at line 118 of file RailCom.hxx.

Member Function Documentation

◆ add_assign_feedback()

void dcc::RailcomDefs::add_assign_feedback ( uint8_t  changeflags,
uint16_t  changecount,
uint8_t  supp2,
uint8_t  supp3,
Feedback fb 
)
static

Creates a Logon Assign feedback.

Parameters
changeflags8 bits of change flags
changecount12 bits of changecount
supp2protocol support flags (capabilities[2])
supp3protocol support flags (capabilities[3])
fbthe feedback packet to generate.

Definition at line 336 of file RailCom.cxx.

◆ add_did_feedback()

void dcc::RailcomDefs::add_did_feedback ( uint64_t  decoder_id,
Feedback fb 
)
static

Creates a Logon Enable feedback with the decoder unique ID.

Parameters
decoder_idthe 44-bit decoder ID (justified to MSb).
fbthe feedback packet to generate.

Definition at line 305 of file RailCom.cxx.

◆ add_shortinfo_feedback()

void dcc::RailcomDefs::add_shortinfo_feedback ( uint16_t  requested_address,
uint8_t  max_fn,
uint8_t  psupp,
uint8_t  ssupp,
Feedback fb 
)
static

Creates a ShortInfo feedback.

Parameters
requested_address14-bit encoding of the requested address.
max_fnmaximum supported function (0-255)
psuppprotocol support flags (capabilities[0])
ssuppspace support flags (capabilities[1])
fbthe feedback packet to generate.

Definition at line 315 of file RailCom.cxx.

◆ append12()

static void dcc::RailcomDefs::append12 ( uint8_t  nibble,
uint8_t  data,
uint8_t *  dst 
)
inlinestatic

Encodes 12 bits of useful payload into 16 bits of UART data to transmit.

Parameters
nibbletop 4 bits of the payload to send
databottom 8 bits of payload to send.
dstthis is where the payload will be stored.

Definition at line 145 of file RailCom.hxx.

◆ append36()

static void dcc::RailcomDefs::append36 ( uint8_t  nibble,
uint32_t  data,
uint8_t *  dst 
)
inlinestatic

Encodes a 36-bit railcom datagram into UART bytes.

Parameters
nibblethe railcom ID (top 4 bits)
datathe 32 bit payload. Will be transmitted MSbyte-first.
dstthis is where the payload will be stored.

Definition at line 155 of file RailCom.hxx.

◆ encode12()

static uint16_t dcc::RailcomDefs::encode12 ( uint8_t  nibble,
uint8_t  data 
)
inlinestatic

Encodes 12 bits of useful payload into 16 bits of UART data to transmit.

Parameters
nibbletop 4 bits of the payload to send
databottom 8 bits of payload to send.
Returns
the uart bytes, first byte in the high 8 bits, second byte in the low 8 bits.

Definition at line 135 of file RailCom.hxx.


The documentation for this struct was generated from the following files: