Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
dcc::LogonFeedbackParser Class Reference

Parser for RailCom feedback that recognizes logon messages. More...

#include <LogonFeedback.hxx>

Inheritance diagram for dcc::LogonFeedbackParser:
FlowInterface< MessageType >

Public Types

using PacketType = LogonFeedbackCallbacks::PacketType
 
- Public Types inherited from FlowInterface< MessageType >
typedef MessageType message_type
 Stores the message template type for external reference.
 

Public Member Functions

 LogonFeedbackParser (LogonFeedbackCallbacks *cb, RailcomHubFlow *hub)
 Constructor.
 
void send (Buffer< RailcomHubData > *b, unsigned priority) override
 Receives railcom feedback.
 
- Public Member Functions inherited from FlowInterface< MessageType >
virtual Poolpool ()
 
virtual void send (MessageType *message, unsigned priority=UINT_MAX)=0
 Entry point to the flow.
 
virtual MessageType * type_helper ()
 This function is never user in the code, but GDB can use it to infer the correct message types.
 
MessageType * alloc ()
 Synchronously allocates a message buffer from the pool of this flow.
 
void alloc_async (Executable *target)
 Asynchronously allocates a message buffer from the pool of this flow.
 

Private Types

enum  Errors {
  ERROR_SHIFT = 56 , ERROR_MASK = 0xffULL << ERROR_SHIFT , LENGTH_SHIFT = 48 , LENGTH_OFFSET = 1ULL << LENGTH_SHIFT ,
  LENGTH_MASK = 0xffULL << LENGTH_SHIFT , PAYLOAD_MASK = LENGTH_OFFSET - 1 , ERROR_MISSING_DATA = 1ULL << ERROR_SHIFT , ERROR_ACK = 2ULL << ERROR_SHIFT ,
  ERROR_OUT_OF_ORDER = 4ULL << ERROR_SHIFT , ERROR_GARBAGE = 8ULL << ERROR_SHIFT , ERROR_UNKNOWN = 16ULL << ERROR_SHIFT
}
 

Static Private Member Functions

static void append_data (uint64_t &data, unsigned &shift, uint8_t next_byte)
 Appends 6 bits of incoming data from railcom.
 
static uint64_t parse_code (const Feedback *fb)
 Parses a concatenated ch1+ch2 response into a single uint64_t.
 
static bool has_crc_error (uint64_t data)
 Checks the CRC8 on a 6-byte payload in this feedback.
 

Private Attributes

LogonFeedbackCallbackscb_
 Callbacks object.
 
RailcomHubFlowhub_
 The railcom hub we are registered to.
 

Additional Inherited Members

- Static Public Member Functions inherited from FlowInterface< MessageType >
static MessageType * cast_alloc (QMember *entry)
 Down casts and initializes an asynchronous allocation result to the appropriate flow's buffer type.
 

Detailed Description

Parser for RailCom feedback that recognizes logon messages.

Definition at line 96 of file LogonFeedback.hxx.

Member Typedef Documentation

◆ PacketType

Member Enumeration Documentation

◆ Errors

Enumerator
ERROR_SHIFT 

Which bit offset do the error bits start.

ERROR_MASK 

Mask where the error bits are.

LENGTH_SHIFT 

Which bit offset do the error bits start.

LENGTH_OFFSET 

Counts the number of valid 6-bit counts.

LENGTH_MASK 

Which bit offset do the error bits start.

PAYLOAD_MASK 

Mask where the decoded payload is.

ERROR_MISSING_DATA 

Not enough bytes in the feedback response.

ERROR_ACK 

Found an ACK byte.

ERROR_OUT_OF_ORDER 

Found valid data past an ACK byte or a missing byte.

ERROR_GARBAGE 

Found invalid 6/8 code.

ERROR_UNKNOWN 

Found unknown codepoint (e.g. NACK or BUSY).

Definition at line 158 of file LogonFeedback.hxx.

Constructor & Destructor Documentation

◆ LogonFeedbackParser()

dcc::LogonFeedbackParser::LogonFeedbackParser ( LogonFeedbackCallbacks cb,
RailcomHubFlow hub 
)
inline

Constructor.

Parameters
cbrecognized packets get calls on this object.
hubthe railcom hub for gathering feedback.

Definition at line 103 of file LogonFeedback.hxx.

◆ ~LogonFeedbackParser()

dcc::LogonFeedbackParser::~LogonFeedbackParser ( )
inline

Definition at line 110 of file LogonFeedback.hxx.

Member Function Documentation

◆ append_data()

static void dcc::LogonFeedbackParser::append_data ( uint64_t &  data,
unsigned &  shift,
uint8_t  next_byte 
)
inlinestaticprivate

Appends 6 bits of incoming data from railcom.

Parameters
datathe 48-bit aggregated data.
shiftwhere the next 6 bits should be at (0 to 42)
next_bytethe next byte from the uart.

Definition at line 189 of file LogonFeedback.hxx.

◆ has_crc_error()

static bool dcc::LogonFeedbackParser::has_crc_error ( uint64_t  data)
inlinestaticprivate

Checks the CRC8 on a 6-byte payload in this feedback.

Parameters
datathe feedback bytes (right aligned, first is MSB).
Returns
true if there is a CRC error

Definition at line 259 of file LogonFeedback.hxx.

◆ parse_code()

static uint64_t dcc::LogonFeedbackParser::parse_code ( const Feedback fb)
inlinestaticprivate

Parses a concatenated ch1+ch2 response into a single uint64_t.

It contains error flags in the MSB, the number of valid 6-bit codepoints in the second MSB , and 6 bytes data in the LSB, entered with the first wire byte in the third MSB and last wire byte in the LSB.

Any input byte that was missing or contained any other codepoint than a valid 6-bit data codepoint (including garbage or ACK) is translated into zero bits in the parse result.

Parameters
fbfeedback to parse
Returns
parse result.

Definition at line 227 of file LogonFeedback.hxx.

◆ send()

void dcc::LogonFeedbackParser::send ( Buffer< RailcomHubData > *  b,
unsigned  priority 
)
inlineoverride

Receives railcom feedback.

Definition at line 116 of file LogonFeedback.hxx.

Member Data Documentation

◆ cb_

LogonFeedbackCallbacks* dcc::LogonFeedbackParser::cb_
private

Callbacks object.

Definition at line 271 of file LogonFeedback.hxx.

◆ hub_

RailcomHubFlow* dcc::LogonFeedbackParser::hub_
private

The railcom hub we are registered to.

Definition at line 273 of file LogonFeedback.hxx.


The documentation for this class was generated from the following file: