class CommandPacket:
Known subclasses: rp2da2.rp2dcc.dcc_cmd_util.CV_Access, rp2da2.rp2dcc.dcc_cmd_util.FGrp1Command, rp2da2.rp2dcc.dcc_cmd_util.IdlePacket, rp2da2.rp2dcc.dcc_cmd_util.SpeedCommand
Constructor: CommandPacket(byte_list)
DCC Commmand
Base class for a DCC Command packet. This is created for a new command and updated when changed. It holds the raw command as required for serialisation by the PIO. The command can be upto 11 bytes inclusive of address bytes but not counting preamble, error check or packet end.
The device driver for the PIO is a singleton class and it's assumed here that any variables held here specific to the PIO device driver may be held as class variables.
| Method | __init__ |
Contruct the DCC Command |
| Method | is |
Is Locked |
| Method | set |
Set buffer contents |
| Constant | BASE |
DCC long mobile address range base |
| Constant | MAX |
DCC long address upper limit (inclusive) |
| Constant | MIN |
DCC long address lower limit (inclusive) |
| Instance Variable | NOT |
Return value for command not sent (command being updated) |
| Instance Variable | SENT |
Return value for command serialised |
| Instance Variable | SENT |
Return valued for Program on Main second send |
| Property | address |
Get Address |
| Property | packet |
Get the Packet Buffer |
| Property | type |
Get the command type |
| Instance Variable | _packet |
Undocumented |
rp2da2.rp2dcc.dcc_cmd_util.CV_Access, rp2da2.rp2dcc.dcc_cmd_util.FGrp1Command, rp2da2.rp2dcc.dcc_cmd_util.IdlePacket, rp2da2.rp2dcc.dcc_cmd_util.SpeedCommandContruct the DCC Command
This method is not called automatically on object instantiation and is called explicitly by __init__ in the inheriting object.
This builds the DCC Command. The supplied byte list is used to create the raw command as serialised by the PIO state machine. It is saved in a word array of sufficient size (max 8 32 bit words). The reference to the PIO state machine is obtained when the first command object is built.
Mobile traction commands etc. are created from the supplied byte list.
POM commands are built as empty templates without a byte list.
| Parameters | |
| byte | a list of the component bytes. |
Is Locked
Check to see if the command is locked by looking at the first word. This will be pre-amble if unlocked or 0 if locked.
returns: True if command is locked for editing
Set buffer contents
This builds the raw command content as required by the PIO state machine. The preamble is prepended. The checksum is calculated and appended, as is the packet end bit. The function is called by the constructor. It may also be called to update the command.
It's not assumed that writing 0 to a word in the buffer is atomic. So setting the first word (the preamble) to 0 is used as an indicator that the buffer is being updated and shouldn't be sent. Word 0 is reset to the preamble to indicate update over. IRQs are disabled when writing to word 0.
We build the buffer here in 'slow time' rather than in ISR 'critical time'.
| Parameters | |
| byte | a list of the component bytes. |
rp2da2.rp2dcc.dcc_cmd_util.CV_AccessReturn value for command not sent (command being updated)
rp2da2.rp2dcc.dcc_cmd_util.CV_AccessReturn valued for Program on Main second send
Get Address
This returns the decoder address targeted by the command
| Returns | |
| The decoder address as an integer |
Get the Packet Buffer
This returns the packet as prepared for serialisation. It may be written as is to the PIO state machine FIFO.