34#ifndef _DCC_LOGONFEEDBACK_HXX_
35#define _DCC_LOGONFEEDBACK_HXX_
76 uintptr_t feedback_key,
bool error, uint64_t data) = 0;
84 uintptr_t feedback_key,
bool error, uint64_t data) = 0;
92 uintptr_t feedback_key,
bool error, uint64_t data) = 0;
120 if (type == PacketType::UNKNOWN)
126 auto key = b->
data()->feedbackKey;
129 case PacketType::SELECT_SHORTINFO:
131 any_error |= (((data >> 47) & 1) != 1);
135 case PacketType::LOGON_ASSIGN:
138 (((data >> 44) & 0xf) != RMOB_LOGON_ASSIGN_FEEDBACK);
141 case PacketType::LOGON_ENABLE:
143 (((data >> 44) & 0xf) != RMOB_LOGON_ENABLE_FEEDBACK);
146 case PacketType::GET_DATA_START:
147 case PacketType::GET_DATA_CONT:
148 case PacketType::MISC_254:
149 case PacketType::UNKNOWN:
189 static void append_data(uint64_t &data,
unsigned &shift, uint8_t next_byte)
194 data |= ((uint64_t)code) << shift;
230 unsigned shift = 48 - 6;
231 for (
unsigned i = 0; i < 2; i++)
242 for (
unsigned i = 0; i < 6; i++)
262 for (
int i = 48 - 8; i >= 0; i -= 8)
BufferPtr< T > get_buffer_deleter(Buffer< T > *b)
Helper function to create a BufferPtr of an appropriate type without having to explicitly specify the...
const uint8_t railcom_decode[256]
Table for 8-to-6 decoding of railcom data.
Base class for all QMember types that hold data in an expandable format.
T * data()
get a pointer to the start of the data.
Helper class for computing CRC-8 according to Dallas/Maxim specification for 1-wire protocol.
bool check_ok()
Checks that the message has a correct CRC.
void update16(uint8_t message_byte)
Processes one byte of the incoming message.
Abstract class for message recipients.
Templated implementation of the HubFlow.
void register_port(port_type *port)
Adds a new port.
void unregister_port(port_type *port)
Removes a previously added port.
Abstract class to get callbacks for recognized feedback messages.
virtual void process_decoder_id(uintptr_t feedback_key, bool error, uint64_t data)=0
Handles a Decoder ID feedback message.
virtual PacketType classify_packet(uintptr_t feedback_key)=0
Determines based on feedback key what the given DCC packet was.
virtual void process_logon_assign(uintptr_t feedback_key, bool error, uint64_t data)=0
Handles a Logon Assign feedback message.
virtual void process_select_shortinfo(uintptr_t feedback_key, bool error, uint64_t data)=0
Handles a Select ShortInfo feedback message.
@ GET_DATA_CONT
Get Data Continue packet.
@ LOGON_ENABLE
Logon Enable packet.
@ MISC_254
Misc 254 packet (ID based responses)
@ GET_DATA_START
Get Data Start packet.
@ SELECT_SHORTINFO
Select packet with Get Short Info command.
@ LOGON_ASSIGN
Logon Assign packet.
@ UNKNOWN
Non-254 packet or not known (not relevant) 254 packet type.
Parser for RailCom feedback that recognizes logon messages.
LogonFeedbackCallbacks * cb_
Callbacks object.
static bool has_crc_error(uint64_t data)
Checks the CRC8 on a 6-byte payload in this feedback.
@ ERROR_UNKNOWN
Found unknown codepoint (e.g. NACK or BUSY).
@ LENGTH_OFFSET
Counts the number of valid 6-bit counts.
@ ERROR_OUT_OF_ORDER
Found valid data past an ACK byte or a missing byte.
@ ERROR_MASK
Mask where the error bits are.
@ ERROR_ACK
Found an ACK byte.
@ ERROR_SHIFT
Which bit offset do the error bits start.
@ LENGTH_SHIFT
Which bit offset do the error bits start.
@ PAYLOAD_MASK
Mask where the decoded payload is.
@ LENGTH_MASK
Which bit offset do the error bits start.
@ ERROR_MISSING_DATA
Not enough bytes in the feedback response.
@ ERROR_GARBAGE
Found invalid 6/8 code.
LogonFeedbackParser(LogonFeedbackCallbacks *cb, RailcomHubFlow *hub)
Constructor.
void send(Buffer< RailcomHubData > *b, unsigned priority) override
Receives railcom feedback.
RailcomHubFlow * hub_
The railcom hub we are registered to.
static uint64_t parse_code(const Feedback *fb)
Parses a concatenated ch1+ch2 response into a single uint64_t.
static void append_data(uint64_t &data, unsigned &shift, uint8_t next_byte)
Appends 6 bits of incoming data from railcom.
uint8_t ch2Size
Number of bytes in channel two.
uint8_t ch1Size
Number of bytes in channel one.
uint8_t ch1Data[2]
Payload of channel 1.
uint8_t ch2Data[6]
Payload of channel 2.
Structure used for reading (railcom) feedback data from DCC / Railcom device drivers.
@ ACK
Railcom ACK; the decoder received the message ok.
@ INV
invalid value (not conforming to the 4bit weighting requirement)