|
Open Model Railroad Network (OpenMRN)
|
Simple state machine to decode DCC address from railcom broadcast packets. More...
#include <RailcomBroadcastDecoder.hxx>
Public Member Functions | |
| uint16_t | current_address () |
| bool | process_packet (const dcc::Feedback &packet) |
| Decodes a packet. | |
| void | set_occupancy (bool value) |
| Notifies the state machine about observed occupancy. | |
Public Attributes | |
| uint16_t | lastAddress_ |
| usable by clients for storage. | |
Private Member Functions | |
| bool | process_data (const uint8_t *data, unsigned size) |
| Helper function to process a sequence of bytes (whichever window they are coming from). | |
| void | notify_empty () |
| Notifies the state machine that there is no occupancy detected. | |
Private Attributes | |
| uint8_t | currentH_ |
| last received high address bits | |
| uint8_t | currentL_ |
| last received low address bits | |
| uint8_t | countH_ |
| observed repeat count of high address bits | |
| uint8_t | countL_ |
| observed repeat count of low address bits | |
| uint16_t | currentAddress_ |
| last valid address (0 if no valid address) | |
Static Private Attributes | |
| static const uint8_t | MIN_REPEAT_COUNT = 3 |
| How many times we shall get the same data out of railcom before we believe it and report to the bus. | |
| static const uint8_t | MIN_EMPTY_COUNT = 8 |
| This is how many empty packets we need to forget the current address when we're getting empty packets. | |
Simple state machine to decode DCC address from railcom broadcast packets.
Usage:
For each incoming Railcom packet call the process_packet() function. call the current_address() function to retrieve the currently known address that came with the global broadcast.
Definition at line 51 of file RailcomBroadcastDecoder.hxx.
|
inline |
Definition at line 54 of file RailcomBroadcastDecoder.hxx.
|
inline |
Definition at line 66 of file RailcomBroadcastDecoder.hxx.
|
private |
Notifies the state machine that there is no occupancy detected.
Definition at line 143 of file RailcomBroadcastDecoder.cxx.
|
private |
Helper function to process a sequence of bytes (whichever window they are coming from).
| data | pointer to bytes |
| size | how many bytes arethere to decode. |
TODO(balazs.racz) if we have only one byte in ch1 but we have a second byte in ch2, we should still process those because it might be a misaligned window.
Definition at line 66 of file RailcomBroadcastDecoder.cxx.
| bool dcc::RailcomBroadcastDecoder::process_packet | ( | const dcc::Feedback & | packet | ) |
Decodes a packet.
| packet | is what to decode. |
Definition at line 47 of file RailcomBroadcastDecoder.cxx.
| void dcc::RailcomBroadcastDecoder::set_occupancy | ( | bool | value | ) |
Notifies the state machine about observed occupancy.
| value | is true if the track is sensed as occupied. |
Definition at line 134 of file RailcomBroadcastDecoder.cxx.
|
private |
observed repeat count of high address bits
Definition at line 101 of file RailcomBroadcastDecoder.hxx.
|
private |
observed repeat count of low address bits
Definition at line 102 of file RailcomBroadcastDecoder.hxx.
|
private |
last valid address (0 if no valid address)
Definition at line 104 of file RailcomBroadcastDecoder.hxx.
|
private |
last received high address bits
Definition at line 99 of file RailcomBroadcastDecoder.hxx.
|
private |
last received low address bits
Definition at line 100 of file RailcomBroadcastDecoder.hxx.
| uint16_t dcc::RailcomBroadcastDecoder::lastAddress_ |
usable by clients for storage.
Definition at line 108 of file RailcomBroadcastDecoder.hxx.
|
staticprivate |
This is how many empty packets we need to forget the current address when we're getting empty packets.
Definition at line 97 of file RailcomBroadcastDecoder.hxx.
|
staticprivate |
How many times we shall get the same data out of railcom before we believe it and report to the bus.
Definition at line 94 of file RailcomBroadcastDecoder.hxx.