Model Railroad System 2.2.2
|
Main XPressNet interface class. More...
Public Member Functions | |
XPressNet (name, port="/dev/ttyS0") | |
The constructor opens the serial port and initializes the port. More... | |
~XPressNet () | |
The destructor restores the serial port's state and closes it. More... | |
CheckForResponse (timeout=5) | |
Check for a response from the command station. More... | |
GetNextCommandStationResponse (timeout=5) | |
Return the next response from the command station. More... | |
ResumeOperations () | |
Resume operations request. More... | |
StopOperations () | |
Stop operations request. More... | |
EmergencyStopAllLocomotives () | |
Emergency stop all locomotives. More... | |
EmergencyStopALocomotive (la) | |
Emergency stop a locomotive. More... | |
RegisterModeRead (r) | |
Register mode read. More... | |
DirectModeCVRead (cv) | |
Direct mode CV read. More... | |
PagedModeCVRead (cv) | |
Paged mode CV read. More... | |
RequestForServiceModeResults () | |
Request for service mode results. More... | |
RegisterModeWrite (r, d) | |
Register mode write. More... | |
DirectModeCVWrite (cv, d) | |
Direct mode CV write. More... | |
PagedModeCVWrite (cv, d) | |
Paged mode CV write. More... | |
CommandStationSoftwareVersion () | |
Command station software version request. More... | |
CommandStationStatusRequest () | |
Command station status request. More... | |
SetCommandStationPowerUpMode (mode) | |
Set command station power up mode. More... | |
AccessoryDecoderInformationRequest (address, nibble) | |
Accessory decoder information request. More... | |
AccessoryDecoderOperation (groupaddr, elementaddr, activateOutput, useOutput2) | |
Accessory decoder operation request. More... | |
LocomotiveInformationRequest (address) | |
Locomotive information request. More... | |
FunctionStatusRequest (address) | |
Function status request. More... | |
SetLocomotiveSpeedAndDirection (address, ssm, dir, speed) | |
Set locomotive speed and direction. More... | |
SetLocomotiveFunctionsGroup1 (address, f0, f1, f2, f3, f4) | |
Set locomotive functions, group 1. More... | |
SetLocomotiveFunctionsGroup2 (address, f5, f6, f7, f8) | |
Set locomotive functions, group 2. More... | |
SetLocomotiveFunctionsGroup3 (address, f9, f10, f11, f12) | |
Set locomotive functions, group 3. More... | |
SetFunctionStateGroup1 (address, f0, f1, f2, f3, f4) | |
Set locomotive function state, group 1. More... | |
SetFunctionStateGroup2 (address, f5, f6, f7, f8) | |
Set locomotive function state, group 2. More... | |
SetFunctionStateGroup3 (address, f9, f10, f11, f12) | |
Set locomotive function state, group 3. More... | |
EstablishDoubleHeader (address1, address2) | |
Establish a double header. More... | |
DissolveDoubleHeader (address1) | |
Dissolve a double header. More... | |
OperatingModeProgrammingByteModeWrite (address, cv, data) | |
Operating mode programming byte mode write. More... | |
OperatingModeProgrammingBitModeWrite (address, cv, bitnum, value) | |
Operating mode programming bit mode write. More... | |
AddLocomotiveToMultiUnit (address, mtr, samedirection) | |
Add locomotive to Multi-Unit. More... | |
RemoveLocomotiveFromMultiUnit (address, mtr) | |
Remove locomotive to Multi-Unit. More... | |
AddressInquiryNextMUMember (mtr, address) | |
Address inquire next MU member. More... | |
AddressInquiryPreviousMUMember (mtr, address) | |
Address inquire previous MU member. More... | |
AddressInquiryNextMU (mtr) | |
Address inquire next MU. More... | |
AddressInquiryPreviousMU (mtr) | |
Address inquire previous MU. More... | |
AddressInquiryNextStack (address) | |
Address inquire next stack. More... | |
AddressInquiryPreviousStack (address) | |
Address inquire previous stack. More... | |
DeleteLocomotiveFromStack (address) | |
Delete locomotive from stack. More... | |
GetLI100VersionNumbers () | |
Fetch version numbers from LI100F and LI101. More... | |
SetLI101Address (addr) | |
Set LI101's XPressNet address. More... | |
readevent (script) | |
Establish an external read event handler. More... | |
Private Member Functions | |
_appendXORByte (messageVar) | |
Compute and append the XOR check byte. More... | |
_readevent () | |
Read event handler, toggle timeout flag. More... | |
_timeoutevent () | |
Timeout event handler, toggle timeout flag. More... | |
_transmit (themessage) | |
Transmit a message. More... | |
_readbyte (thebytevar, timeout) | |
Read next available byte or return false. More... | |
Static Private Member Functions | |
static | _CheckForResponse_0x00 (message) |
Helper function for CheckForResponse: handles the 0x00 arm. More... | |
static | _CheckForResponse_0x40 (message) |
Helper function for CheckForResponse: handles the 0x40 arm. More... | |
static | _CheckForResponse_0x60 (message) |
Helper function for CheckForResponse: handles the 0x60 arm. More... | |
static | _CheckForResponse_0x80 (message) |
Helper function for CheckForResponse: handles the 0x80 arm. More... | |
static | _CheckForResponse_0xa0 (message) |
Helper function for CheckForResponse: handles the 0xa0 arm. More... | |
static | _CheckForResponse_0xc0 (message) |
Helper function for CheckForResponse: handles the 0xc0 arm. More... | |
static | _CheckForResponse_0xe0 (message) |
Helper function for CheckForResponse: handles the 0xe0 arm. More... | |
static | _ADDRESS (a) |
Helper function to insure a proper address. More... | |
Private Attributes | |
ttyfd | |
Terminal file descriptor. More... | |
responseList | |
Response list. More... | |
_timeout | |
Timeout or data available flag. More... | |
Main XPressNet interface class.
This class implements the interface logic to connect to the XpressNet.
xpressnet::XPressNet::XPressNet | ( | name | , |
port | = "/dev/ttyS0" |
||
) |
The constructor opens the serial port and initializes the port.
port | The serial port device file. |
xpressnet::XPressNet::~XPressNet | ( | ) |
The destructor restores the serial port's state and closes it.
|
staticprivate |
Helper function to insure a proper address.
If it is a long address (>= 100), 0x0c000 is added.
a | Raw address. |
|
private |
Compute and append the XOR check byte.
messageVar | Name of the list holding the message bytes. |
|
staticprivate |
Helper function for CheckForResponse: handles the 0x00 arm.
|
staticprivate |
Helper function for CheckForResponse: handles the 0x40 arm.
|
staticprivate |
Helper function for CheckForResponse: handles the 0x60 arm.
|
staticprivate |
Helper function for CheckForResponse: handles the 0x80 arm.
|
staticprivate |
Helper function for CheckForResponse: handles the 0xa0 arm.
|
staticprivate |
Helper function for CheckForResponse: handles the 0xc0 arm.
|
staticprivate |
Helper function for CheckForResponse: handles the 0xe0 arm.
|
private |
Read next available byte or return false.
thebytevar | Name of a variable to receive the byte. |
timeout | Timeout in seconds. |
If there is a defined external read event handler, the timeout parameter is ignored and false is returned if there are no bytes available. The presumption is that the read is being called from event handler and that means that there is data available.
|
private |
Read event handler, toggle timeout flag.
|
private |
Timeout event handler, toggle timeout flag.
|
private |
Transmit a message.
xpressnet::XPressNet::AccessoryDecoderInformationRequest | ( | address | , |
nibble | |||
) |
Accessory decoder information request.
address | Address of decoder. |
nibble | Which nibble. |
xpressnet::XPressNet::AccessoryDecoderOperation | ( | groupaddr | , |
elementaddr | , | ||
activateOutput | , | ||
useOutput2 | |||
) |
Accessory decoder operation request.
groupaddr | Address of decoder. |
elementaddr | Address of element. |
activateOutput | Set or clear output. |
useOutput2 | Use output 2? |
xpressnet::XPressNet::AddLocomotiveToMultiUnit | ( | address | , |
mtr | , | ||
samedirection | |||
) |
Add locomotive to Multi-Unit.
address | Locomotive address. |
mtr | Multi-Unit address. |
samedirection | The locomotive direction is the same as the consist direction. |
xpressnet::XPressNet::AddressInquiryNextMU | ( | mtr | ) |
Address inquire next MU.
mtr | Multi-Unit address. |
xpressnet::XPressNet::AddressInquiryNextMUMember | ( | mtr | , |
address | |||
) |
Address inquire next MU member.
mtr | Multi-Unit address. |
address | Locomotive address. |
xpressnet::XPressNet::AddressInquiryNextStack | ( | address | ) |
Address inquire next stack.
address | Locomotive address. |
xpressnet::XPressNet::AddressInquiryPreviousMU | ( | mtr | ) |
Address inquire previous MU.
mtr | Multi-Unit address. |
xpressnet::XPressNet::AddressInquiryPreviousMUMember | ( | mtr | , |
address | |||
) |
Address inquire previous MU member.
mtr | Multi-Unit address. |
address | Locomotive address. |
xpressnet::XPressNet::AddressInquiryPreviousStack | ( | address | ) |
Address inquire previous stack.
address | Locomotive address. |
xpressnet::XPressNet::CheckForResponse | ( | timeout | = 5 | ) |
Check for a response from the command station.
timeout | Timeout in seconds |
xpressnet::XPressNet::CommandStationSoftwareVersion | ( | ) |
Command station software version request.
xpressnet::XPressNet::CommandStationStatusRequest | ( | ) |
Command station status request.
xpressnet::XPressNet::DeleteLocomotiveFromStack | ( | address | ) |
Delete locomotive from stack.
address | Locomotive address. |
xpressnet::XPressNet::DirectModeCVRead | ( | cv | ) |
Direct mode CV read.
cv | CV to read. |
xpressnet::XPressNet::DirectModeCVWrite | ( | cv | , |
d | |||
) |
Direct mode CV write.
cv | CV to write to. |
d | Data to write. |
xpressnet::XPressNet::DissolveDoubleHeader | ( | address1 | ) |
Dissolve a double header.
address1 | Locomotive address1. |
xpressnet::XPressNet::EmergencyStopAllLocomotives | ( | ) |
Emergency stop all locomotives.
xpressnet::XPressNet::EmergencyStopALocomotive | ( | la | ) |
Emergency stop a locomotive.
la | Address of the locomotive to stop. |
xpressnet::XPressNet::EstablishDoubleHeader | ( | address1 | , |
address2 | |||
) |
Establish a double header.
address1 | Locomotive address1. |
address2 | Locomotive address2. |
xpressnet::XPressNet::FunctionStatusRequest | ( | address | ) |
Function status request.
address | Address of locomotive. |
xpressnet::XPressNet::GetLI100VersionNumbers | ( | ) |
Fetch version numbers from LI100F and LI101.
xpressnet::XPressNet::GetNextCommandStationResponse | ( | timeout | = 5 | ) |
Return the next response from the command station.
timeout | Timeout in seconds |
xpressnet::XPressNet::LocomotiveInformationRequest | ( | address | ) |
Locomotive information request.
address | Address of locomotive. |
xpressnet::XPressNet::OperatingModeProgrammingBitModeWrite | ( | address | , |
cv | , | ||
bitnum | , | ||
value | |||
) |
Operating mode programming bit mode write.
address | Locomotive address. |
cv | CV to set. |
bitnum | Bit number. |
value | Value to set. |
xpressnet::XPressNet::OperatingModeProgrammingByteModeWrite | ( | address | , |
cv | , | ||
data | |||
) |
Operating mode programming byte mode write.
address | Locomotive address. |
cv | CV to set. |
data | Data to set. |
xpressnet::XPressNet::PagedModeCVRead | ( | cv | ) |
Paged mode CV read.
cv | CV to read. |
xpressnet::XPressNet::PagedModeCVWrite | ( | cv | , |
d | |||
) |
Paged mode CV write.
cv | CV to write to. |
d | Data to write. |
xpressnet::XPressNet::readevent | ( | script | ) |
Establish an external read event handler.
script | The external event handler script. |
xpressnet::XPressNet::RegisterModeRead | ( | r | ) |
Register mode read.
r | Register to read. |
xpressnet::XPressNet::RegisterModeWrite | ( | r | , |
d | |||
) |
Register mode write.
r | Register to write to. |
d | Data to write. |
xpressnet::XPressNet::RemoveLocomotiveFromMultiUnit | ( | address | , |
mtr | |||
) |
Remove locomotive to Multi-Unit.
address | Locomotive address. |
mtr | Multi-Unit address. |
xpressnet::XPressNet::RequestForServiceModeResults | ( | ) |
Request for service mode results.
xpressnet::XPressNet::ResumeOperations | ( | ) |
Resume operations request.
xpressnet::XPressNet::SetCommandStationPowerUpMode | ( | mode | ) |
Set command station power up mode.
mode | Mode to set. |
xpressnet::XPressNet::SetFunctionStateGroup1 | ( | address | , |
f0 | , | ||
f1 | , | ||
f2 | , | ||
f3 | , | ||
f4 | |||
) |
Set locomotive function state, group 1.
address | Locomotive address. |
f0 | Function 0. |
f1 | Function 1. |
f2 | Function 2. |
f3 | Function 3. |
f4 | Function 4. |
xpressnet::XPressNet::SetFunctionStateGroup2 | ( | address | , |
f5 | , | ||
f6 | , | ||
f7 | , | ||
f8 | |||
) |
Set locomotive function state, group 2.
address | Locomotive address. |
f5 | Function 5. |
f6 | Function 6. |
f7 | Function 7. |
f8 | Function 8. |
xpressnet::XPressNet::SetFunctionStateGroup3 | ( | address | , |
f9 | , | ||
f10 | , | ||
f11 | , | ||
f12 | |||
) |
Set locomotive function state, group 3.
address | Locomotive address. |
f9 | Function 9. |
f10 | Function 10. |
f11 | Function 11. |
f12 | Function 12. |
xpressnet::XPressNet::SetLI101Address | ( | addr | ) |
Set LI101's XPressNet address.
xpressnet::XPressNet::SetLocomotiveFunctionsGroup1 | ( | address | , |
f0 | , | ||
f1 | , | ||
f2 | , | ||
f3 | , | ||
f4 | |||
) |
Set locomotive functions, group 1.
address | Locomotive address. |
f0 | Function 0. |
f1 | Function 1. |
f2 | Function 2. |
f3 | Function 3. |
f4 | Function 4. |
xpressnet::XPressNet::SetLocomotiveFunctionsGroup2 | ( | address | , |
f5 | , | ||
f6 | , | ||
f7 | , | ||
f8 | |||
) |
Set locomotive functions, group 2.
address | Locomotive address. |
f5 | Function 5. |
f6 | Function 6. |
f7 | Function 7. |
f8 | Function 8. |
xpressnet::XPressNet::SetLocomotiveFunctionsGroup3 | ( | address | , |
f9 | , | ||
f10 | , | ||
f11 | , | ||
f12 | |||
) |
Set locomotive functions, group 3.
address | Locomotive address. |
f9 | Function 9. |
f10 | Function 10. |
f11 | Function 11. |
f12 | Function 12. |
xpressnet::XPressNet::SetLocomotiveSpeedAndDirection | ( | address | , |
ssm | , | ||
dir | , | ||
speed | |||
) |
Set locomotive speed and direction.
address | Address of locomotive. |
ssm | Speed step mode to use. |
dir | Desired direction. |
speed | Desired speed. |
xpressnet::XPressNet::StopOperations | ( | ) |
Stop operations request.
|
private |
Timeout or data available flag.
|
private |
Response list.
|
private |
Terminal file descriptor.