class documentation

class RComCmdRsp(RailComRead):

Constructor: RComCmdRsp()

View In Hierarchy

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_instance Get the RailCom ch2 detector instance.
Method __init__ DCC Command object constructor.
Method get_dg_list Get Datagram list
Method get_dyn_chng get changes to dyn info
Method get_error_counts Get Error Counts
Method reset_stats Reset diagnostic information
Method set_last_command Set the last command
Constant DG_CDI current driving info - not specified yet
Constant DG_CV_AUTO Background CV transmission
Constant DG_DYN dynamic info (DG ID 7) datagram identifier.
Constant DG_EXT location information
Constant DG_POM POM response (CV value) datagram identifier.
Constant DG_TS1 track search 1
Constant DG_TS14 track search 14
Constant DG_TS2 track search 2
Constant DG_XPOM10 extended POM response - 3rd CV
Constant DG_XPOM11 extended POM response - 4th CV
Constant DG_XPOM8 extended POM response - 1st CV
Constant DG_XPOM9 extended POM response - 2nd CV
Constant DYN_DIRECTION direction status byte
Constant DYN_REAL_SPEED real speed part 1 datagram identifier.
Constant DYN_REAL_SPEED1 real speed part 2 datagram identifier.
Constant DYN_RECEP_STATS reception stats datagram identifier.
Constant DYN_TEMP decoder temperature
Constant DYN_TRACK_VOLT track voltage
Constant ERR_CODE list of error codes
Method _act_on_datagram Undocumented
Method _log_error Undocumented
Method _parse_cg2_msg Parse Channel 2 Message
Method _rail_com_msg Process RailCom Channel 2 response
Class Variable _rc_ch2 Undocumented
Instance Variable _dgs Undocumented
Instance Variable _dyn_chng Undocumented
Instance Variable _dyn_info Undocumented
Instance Variable _errors Undocumented
Instance Variable _last_command Undocumented
Instance Variable _pom_acc Undocumented
@classmethod
def get_instance(cls):

Get the RailCom ch2 detector instance.

This returns the singleton instance. It is instantiated on the first call.

Returns
The RailCom ch2 detector instance
def __init__(self):

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.

def get_dg_list(self):

Get Datagram list

Diagnostic method to retrieve the list of datagram types that have been decoded.

Returns
the set of datagram ids
def get_dyn_chng(self):

get changes to dyn info

Returns
dyn info for first address in queue
def get_error_counts(self):

Get Error Counts

Diagnostic method to retrieve the error counts for detected errors.

Returns
a dictionary of counts by error code.
def reset_stats(self):

Reset diagnostic information

Clears the error counts and set of datagram ids.

def set_last_command(self, command):

Set the last command

Used to set the command that will be used for interpreting the next channel 2 response message.

Parameters
commandThe last serialised command object.
DG_CDI =

current driving info - not specified yet

Value
const(4)
DG_CV_AUTO =

Background CV transmission

Value
const(12)
DG_DYN =

dynamic info (DG ID 7) datagram identifier.

Value
const(7)
DG_EXT =

location information

Value
const(3)
DG_POM =

POM response (CV value) datagram identifier.

Value
const(0)
DG_TS1 =

track search 1

Value
const(1)
DG_TS14 =

track search 14

Value
const(14)
DG_TS2 =

track search 2

Value
const(2)
DG_XPOM10 =

extended POM response - 3rd CV

Value
const(10)
DG_XPOM11 =

extended POM response - 4th CV

Value
const(11)
DG_XPOM8 =

extended POM response - 1st CV

Value
const(8)
DG_XPOM9 =

extended POM response - 2nd CV

Value
const(9)
DYN_DIRECTION =

direction status byte

Value
const(27)
DYN_REAL_SPEED =

real speed part 1 datagram identifier.

Value
const(0)
DYN_REAL_SPEED1 =

real speed part 2 datagram identifier.

Value
const(1)
DYN_RECEP_STATS =

reception stats datagram identifier.

Value
const(7)
DYN_TEMP =

decoder temperature

Value
const(26)
DYN_TRACK_VOLT =

track voltage

Value
const(46)
ERR_CODE =

list of error codes

Value
(RailComRead.ERR_WH, RailComRead.ERR_WL, RailComRead.ERR_OE)
def _act_on_datagram(self, datagram, addr):

Undocumented

def _log_error(self, error_code):

Undocumented

def _parse_cg2_msg(self):

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.

def _rail_com_msg(self, last_command):

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_commandthe command that initiated this response.
_rc_ch2 =

Undocumented

_dgs: set =

Undocumented

_dyn_chng =

Undocumented

_dyn_info: dict =

Undocumented

_errors: dict =

Undocumented

_last_command =

Undocumented

_pom_acc: dict =

Undocumented