Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
RailcomDebug.cxx
Go to the documentation of this file.
1
35#include "dcc/RailCom.hxx"
37
38namespace dcc
39{
40
41string railcom_debug(const Feedback &fb)
42{
43 string ret;
44 ret += StringPrintf("ch1(%d) ", fb.ch1Size);
45 for (int i = 0; i < fb.ch1Size; ++i)
46 {
47 ret += StringPrintf(
48 " %02x=%02x", fb.ch1Data[i], railcom_decode[fb.ch1Data[i]]);
49 }
50 ret += StringPrintf(" ch2(%d) ", fb.ch2Size);
51 for (int i = 0; i < fb.ch2Size; ++i)
52 {
53 ret += StringPrintf(
54 " %02x=%02x", fb.ch2Data[i], railcom_decode[fb.ch2Data[i]]);
55 }
56 return ret;
57}
58
59} // namespace dcc
const uint8_t railcom_decode[256]
Table for 8-to-6 decoding of railcom data.
Definition RailCom.cxx:47
std::string railcom_debug(const Feedback &fb)
Formats a dcc::Feedback message into a debug string.
uint8_t ch2Size
Number of bytes in channel two.
Definition railcom.h:49
uint8_t ch1Size
Number of bytes in channel one.
Definition railcom.h:45
uint8_t ch1Data[2]
Payload of channel 1.
Definition railcom.h:47
uint8_t ch2Data[6]
Payload of channel 2.
Definition railcom.h:51
Structure used for reading (railcom) feedback data from DCC / Railcom device drivers.
Definition RailCom.hxx:50