Channel 2 (Command Response) Decode
This runs on the command station. As there is only one DCC generator there can only be one of these too. It is a singleton class.
The channel 2 window is time from the start of the cutout. This is detected by monitoring the DRV8874 enable pin which is used to insert the cutout.
Datagram identifiers for channel 2 are defined in RCN-217 3.1 Table 6.
| Class Method | get |
Get the RailCom ch2 detector instance. |
| Method | __init__ |
DCC Command object constructor. |
| Method | get |
Get Datagram list |
| Method | get |
get changes to dyn info |
| Method | get |
Get Error Counts |
| Method | reset |
Reset diagnostic information |
| Method | set |
Set the last command |
| Constant | DG |
current driving info - not specified yet |
| Constant | DG |
Background CV transmission |
| Constant | DG |
dynamic info (DG ID 7) datagram identifier. |
| Constant | DG |
location information |
| Constant | DG |
POM response (CV value) datagram identifier. |
| Constant | DG |
track search 1 |
| Constant | DG |
track search 14 |
| Constant | DG |
track search 2 |
| Constant | DG |
extended POM response - 3rd CV |
| Constant | DG |
extended POM response - 4th CV |
| Constant | DG |
extended POM response - 1st CV |
| Constant | DG |
extended POM response - 2nd CV |
| Constant | DYN |
direction status byte |
| Constant | DYN |
real speed part 1 datagram identifier. |
| Constant | DYN |
real speed part 2 datagram identifier. |
| Constant | DYN |
reception stats datagram identifier. |
| Constant | DYN |
decoder temperature |
| Constant | DYN |
track voltage |
| Constant | ERR |
list of error codes |
| Method | _act |
Undocumented |
| Method | _log |
Undocumented |
| Method | _parse |
Parse Channel 2 Message |
| Method | _rail |
Process RailCom Channel 2 response |
| Class Variable | _rc |
Undocumented |
| Instance Variable | _dgs |
Undocumented |
| Instance Variable | _dyn |
Undocumented |
| Instance Variable | _dyn |
Undocumented |
| Instance Variable | _errors |
Undocumented |
| Instance Variable | _last |
Undocumented |
| Instance Variable | _pom |
Undocumented |
Get the RailCom ch2 detector instance.
This returns the singleton instance. It is instantiated on the first call.
| Returns | |
| The RailCom ch2 detector instance |
DCC Command object constructor.
The enable pin is that used to enable the DRV8874. It's set by the DCC generator PIO. It's monitored here by the PIO program as it's low going edge marks the start of the cutout.
The RailCom reader for channel 2 is instantiated and the base class is initiated.
Note
The RailCom reader will use two sequentially numbered state machines - the first is read from the hardware configuration.
The RailCom reader will use two sequentially numbered GPIO pins for receiving - the first is read from the hardware configuration.
The pin and state machine allocations are read from the hardware configuration.
Get Datagram list
Diagnostic method to retrieve the list of datagram types that have been decoded.
| Returns | |
| the set of datagram ids |
Get Error Counts
Diagnostic method to retrieve the error counts for detected errors.
| Returns | |
| a dictionary of counts by error code. |
Set the last command
Used to set the command that will be used for interpreting the next channel 2 response message.
| Parameters | |
| command | The last serialised command object. |
Parse Channel 2 Message
Inspect the message and extract datagrams which are saved in list and returned. The datagrams are tuples of (datagram id, payload). Bytes are either protocol control bytes, error bytes or data bytes. The least significant 6 bits of a data byte contrinbute to the payload of a datagram and the most significant 2 bits are ignored. The payload content of each byte is concatenated to form the datagram. The datagram id is the first 4 bits of the datagram. The datagram id is used to determine the length of the datagram.
Process RailCom Channel 2 response
This is called on termination of the RailCom Channel 2 message receipt window, when a response is detected. The addressed decoder returns a channel 2 message. Other mobile decoders remain silent.
It overrides the method in the base class. It runs in soft ISR context, being scheduled by the hard ISR.
Blank reads should have been intercepted in the hard ISR. They are not checked for here but should not be problematic.
| Parameters | |
| last | the command that initiated this response. |