35#ifndef _DCC_RAILCOM_HXX_
36#define _DCC_RAILCOM_HXX_
42#include "dcc/railcom.h"
52 void reset(uint32_t feedback_key)
80std::string railcom_debug(
const Feedback& fb);
86extern const uint8_t railcom_decode[256];
91extern const uint8_t railcom_encode[64];
135 static uint16_t
encode12(uint8_t nibble, uint8_t data)
137 return (
railcom_encode[((nibble << 2) | (data >> 6)) & 0x3F] << 8) |
145 static void append12(uint8_t nibble, uint8_t data, uint8_t* dst)
155 static void append36(uint8_t nibble, uint32_t data, uint8_t* dst)
177 uint8_t max_fn, uint8_t psupp, uint8_t ssupp,
Feedback *fb);
186 uint8_t supp2, uint8_t supp3,
Feedback *fb);
207 RMOB_LOGON_ASSIGN_FEEDBACK = 13,
208 RMOB_LOGON_ENABLE_FEEDBACK = 15,
260void parse_railcom_data(
261 const dcc::Feedback &fb, std::vector<struct RailcomPacket> *output);
const uint8_t railcom_encode[64]
Table for 6-to-8 encoding of railcom data.
RailcomMobilePacketId
Packet identifiers from Mobile Decoders.
uint8_t ch2Size
Number of bytes in channel two.
uint8_t ch1Size
Number of bytes in channel one.
uint8_t channel
Used by multi-channel railcom receiver drivers.
uint8_t ch1Data[2]
Payload of channel 1.
uintptr_t feedbackKey
Opaque identifier that allows linking outgoing dcc::Packet sent to the DCC waveform generator to the ...
uint8_t ch2Data[6]
Payload of channel 2.
Structure used for reading (railcom) feedback data from DCC / Railcom device drivers.
void reset(uint32_t feedback_key)
Clears the structure and sets the feedback key to a specific value.
void add_ch1_data(uint8_t data)
Appends a byte to the channel 1 payload.
void add_ch2_data(uint8_t data)
Appends a byte to the channel 2 payload.
Special constant values returned by the railcom_decode[] array.
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.
@ CODE_NACK
Code point for NACK (according to RCN-217)
@ CODE_ACK
Code point for ACK (according to RCN-217)
@ CODE_ACK2
Another accepted code point for ACK (according to RCN-217)
@ CODE_BUSY
Code point for BUSY (according to NMRA S-9.3.2)
static void add_did_feedback(uint64_t decoder_id, Feedback *fb)
Creates a Logon Enable feedback with the decoder unique ID.
@ ACK
Railcom ACK; the decoder received the message ok.
@ INV
invalid value (not conforming to the 4bit weighting requirement)
@ RESVD2
Reserved for future expansion.
@ RESVD1
Reserved for future expansion.
@ BUSY
The decoder is busy; send the packet again.
@ NACK
The decoder rejected the packet.
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.
RailcomDefs()
This struct cannot be instantiated.
static void add_assign_feedback(uint8_t changeflags, uint16_t changecount, uint8_t supp2, uint8_t supp3, Feedback *fb)
Creates a Logon Assign feedback.
Represents a single Railcom datagram.
uint8_t type
packet type, see enum above
uint8_t hw_channel
which detector supplied this data
uint8_t railcom_channel
which part of the railcom cutout (1 or 2)
uint32_t argument
payload of the railcom packet, justified to LSB.
RailcomPacket(uint8_t _hw_channel, uint8_t _railcom_channel, uint8_t _type, uint32_t _argument)
Constructor.