Package jmri.jmrix.can.cbus
Class CbusMessage
java.lang.Object
jmri.jmrix.can.cbus.CbusMessage
Class to allow use of CBUS concepts to access the underlying can message.
Methods that take a CanMessage or CanReply as argument:
- CanMessage - Can Frame being sent by JMRI
- CanReply - Can Frame being received by JMRI
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CanMessagegetBootCheck(int c, int header) Microchip AN247 format message to send the checksum for comparison.static CanMessagegetBootDevId(int header) CBUS bootloader v1.0 format message to request device ID.static CanMessagegetBootEnables(int enables, int header) CBUS bootloader v1.0 format message to set memory region write enablesstatic CanMessagegetBootEntry(int nn, int header) This is a strict CBUS message to put a node into boot mode.static CanMessagegetBootId(int header) CBUS bootloader v1.0 format message to request bootloader ID.static CanMessagegetBootInitialise(int a, int header) Microchip AN247 format message to initialise the bootloader and set the start address.static CanMessagegetBootNop(int a, int header) Microchip AN247 format NOP message to set address.static CanMessagegetBootReset(int header) Microchip AN247 format message to reset and enter normal mode.static CanMessagegetBootTest(int header) Microchip AN247 format message to check if a module is in boot mode.static CanMessagegetBootWriteData(byte[] d, int header) Microchip AN247 format message to write up to 8 bytes of datastatic CanMessagegetBootWriteData(int[] d, int header) Microchip AN247 format message to write 8 bytes of datastatic intGet the Data Length from the CanMessagestatic intGet the Event Number from a CBUS Eventstatic intGet the Event Type ( on or off ) from a CanFramestatic intGet the CAN ID within a CanReply or CanMessage Headerstatic intGet the Node Number from a CanFrame Eventstatic intGet the Op Code from the CanMessagestatic CanMessagegetOpsModeWriteCV(int mAddress, boolean mLongAddr, int cv, int val, int header) CBUS Ops mode programmer commandsstatic intGet the priority from within the CanReply or CanMessage Headerstatic CanMessagegetReadCV(int cv, ProgrammingMode mode, int header) CBUS programmer commandsstatic CanMessagegetRequestTrackOff(int header) Get a CanMessage to send track power offstatic CanMessagegetRequestTrackOn(int header) Get a CanMessage to send track power onstatic CanMessagegetVerifyCV(int cv, ProgrammingMode mode, int startVal, int header) CBUS programmer commands CBUS VCVS works like a QCVS read but the programmer will first check if the CV contents are equal to the startVal.static CanMessagegetWriteCV(int cv, int val, ProgrammingMode mode, int header) Get a CanMessage to write a CV.static booleanTests if CanReply is a System Resetstatic booleanTests if incoming CanReply is a Boot Confirm.static booleanTests if incoming CanReply is a Boot Data Error.static booleanTests if incoming CanReply is a Boot Data OK.static booleanTests if incoming CanReply is a Boot Out of Rangestatic booleanTests if incoming CanReply is a device ID reply.static booleanTests if incoming CanReply is a Boot Command Error.static booleanTests if incoming CanReply is a bootloader ID reply.static booleanTests if incoming CanReply is a Boot Command OK.static booleanTests if incoming CanReply is a Boot Out of Rangestatic booleanTests if a message is a bootloader data writestatic booleanTests if a CanMessage or CanReply is an Event.static booleanChecks if a CanMessage is requesting Track Power Offstatic booleanChecks if a CanMessage is requesting Track Power Onstatic booleanTests if CanFrame is a short eventstatic booleanTests if CanReply is confirming Track Power Off.static booleanTests if CanReply is confirming Track Power On.static CanReplyopcRangeToStl(CanReply original) Return a CanReply for use in sensors, turnouts + light If a response event, set to normal event In future, this may also translate extended messages down to normal messages.static voidsetId(AbstractMessage am, int id) Set the CAN ID within a CanMessage or CanReply Headerstatic voidsetPri(AbstractMessage am, int pri) Set the priority within a CanMessage or CanReply Header.static StringReturns string form of a CanMessage ( a Can Frame sent by JMRI ) Short / Long events converted to Sensor / Turnout / Light hardware address message priority not indicated
-
Constructor Details
-
CbusMessage
public CbusMessage()
-
-
Method Details
-
opcRangeToStl
Return a CanReply for use in sensors, turnouts + light If a response event, set to normal event In future, this may also translate extended messages down to normal messages.- Parameters:
original- CanReply to be coverted to normal opc- Returns:
- new CanReply perhaps converted from response OPC to normal OPC.
-
getOpcode
Get the Op Code from the CanMessage- Parameters:
am- CanMessage or CanReply- Returns:
- OPC of the message
-
getDataLength
Get the Data Length from the CanMessage- Parameters:
am- CanMessage or CanReply- Returns:
- the message data length
-
getNodeNumber
Get the Node Number from a CanFrame Event- Parameters:
am- CanMessage or CanReply- Returns:
- the node number if not a short event
-
getEvent
Get the Event Number from a CBUS Event- Parameters:
m- CanMessage or CanReply- Returns:
- the message event ( device ) number, else -1 if not an event.
-
getEventType
Get the Event Type ( on or off ) from a CanFrame- Parameters:
am- CanFrame or CanReply- Returns:
- CbusConstant EVENT_ON or EVENT_OFF
-
isEvent
Tests if a CanMessage or CanReply is an Event. Performs Extended and RTR check. Adheres to cbus spec, ie on off responses to an AREQ are events.- Parameters:
am- CanMessage or CanReply- Returns:
- True if event, else False.
-
isShort
Tests if CanFrame is a short event- Parameters:
am- CanReply or CanMessage- Returns:
- true if Short Event, else false
-
setId
Set the CAN ID within a CanMessage or CanReply Header- Parameters:
am- CanMessage or CanReplyid- CAN ID- Throws:
IllegalArgumentException- when needed
-
setPri
Set the priority within a CanMessage or CanReply Header.- Parameters:
am- CanMessage or CanReplypri- Priority- Throws:
IllegalArgumentException- when needed
-
toAddress
Returns string form of a CanMessage ( a Can Frame sent by JMRI ) Short / Long events converted to Sensor / Turnout / Light hardware address message priority not indicated- Parameters:
m- CanReply or CanMessage- Returns:
- String of hardware address form
-
isRequestTrackOff
Checks if a CanMessage is requesting Track Power Off- Parameters:
m- Can Frame Message- Returns:
- boolean
-
isRequestTrackOn
Checks if a CanMessage is requesting Track Power On- Parameters:
m- Can Frame Message- Returns:
- True if outgoing track power on request
-
getId
Get the CAN ID within a CanReply or CanMessage Header- Parameters:
f- CanReply or CanMessage- Returns:
- CAN ID of the outgoing message
- Throws:
IllegalArgumentException- when needed
-
getPri
Get the priority from within the CanReply or CanMessage Header- Parameters:
r- CanReply or CanMessage- Returns:
- Priority of the outgoing message
- Throws:
IllegalArgumentException- when needed
-
isTrackOff
Tests if CanReply is confirming Track Power Off.- Parameters:
m- CanReply- Returns:
- True if is a Track Off notification
-
isTrackOn
Tests if CanReply is confirming Track Power On.- Parameters:
m- CanReply- Returns:
- True if is a Track On notification
-
isArst
Tests if CanReply is a System Reset- Parameters:
m- CanReply- Returns:
- True if emergency Stop
-
getReadCV
CBUS programmer commands- Parameters:
cv- CV to readmode- Programming Modeheader- CAN ID- Returns:
- CanMessage ready to send
-
getVerifyCV
CBUS programmer commands CBUS VCVS works like a QCVS read but the programmer will first check if the CV contents are equal to the startVal. This can speed up CV reads by skipping reading of other values.- Parameters:
cv- CV to readmode- Programming ModestartVal- Hint of current CV valueheader- CAN ID- Returns:
- CanMessage ready to send
-
getWriteCV
Get a CanMessage to write a CV.- Parameters:
cv- Which CV, 0-65534val- New CV value, 0-255mode- Programming Modeheader- CAN ID- Returns:
- ready to send CanMessage
-
getOpsModeWriteCV
public static CanMessage getOpsModeWriteCV(int mAddress, boolean mLongAddr, int cv, int val, int header) CBUS Ops mode programmer commands- Parameters:
mAddress- Loco Address, non-DCC formatmLongAddr- If Loco Address is a long addressheader- CAN IDval- New CV valuecv- Which CV, 0-65534- Returns:
- ready to send CanMessage
-
getRequestTrackOn
Get a CanMessage to send track power on- Parameters:
header- for connection CAN ID- Returns:
- the CanMessage to send to request track power on
-
getRequestTrackOff
Get a CanMessage to send track power off- Parameters:
header- for connection CAN ID- Returns:
- the CanMessage to send to request track power off
-
getBootEntry
This is a strict CBUS message to put a node into boot mode.- Parameters:
nn- Node Number 1-65534header- CAN ID- Returns:
- ready to send CanMessage
-
getBootNop
Microchip AN247 format NOP message to set address.The CBUS bootloader uses extended ID frames
- Parameters:
a- addressheader- CAN ID - overridden by call to setHeader- Returns:
- ready to send CanMessage
-
getBootReset
Microchip AN247 format message to reset and enter normal mode.- Parameters:
header- CAN ID - overridden by call to setHeader- Returns:
- ready to send CanMessage
-
getBootInitialise
Microchip AN247 format message to initialise the bootloader and set the start address.- Parameters:
a- start addressheader- CAN ID - overridden by call to setHeader- Returns:
- ready to send CanMessage
-
getBootCheck
Microchip AN247 format message to send the checksum for comparison. At time of writing [6th Feb '20] The MERG bootloader doc is incorrect and shows the checksum as being byte swapped.- Parameters:
c- 0-65535 2's complement of sum of all program bytes sentheader- CAN ID - overridden by call to setHeader- Returns:
- ready to send CanMessage
-
getBootTest
Microchip AN247 format message to check if a module is in boot mode.- Parameters:
header- CAN ID - overridden by call to setHeader- Returns:
- ready to send CanMessage
-
getBootDevId
CBUS bootloader v1.0 format message to request device ID.- Parameters:
header- CAN ID - overridden by call to setHeader- Returns:
- ready to send CanMessage
-
getBootId
CBUS bootloader v1.0 format message to request bootloader ID.- Parameters:
header- CAN ID - overridden by call to setHeader- Returns:
- ready to send CanMessage
-
getBootEnables
CBUS bootloader v1.0 format message to set memory region write enables- Parameters:
enables- enable bits for memory regionsheader- CAN ID - overridden by call to setHeader- Returns:
- ready to send CanMessage
-
getBootWriteData
Microchip AN247 format message to write 8 bytes of data- Parameters:
d- data array, 8 length, values 0-255header- CAN ID - overridden by call to setHeader- Returns:
- ready to send CanMessage
-
getBootWriteData
Microchip AN247 format message to write up to 8 bytes of data- Parameters:
d- data array, values 0-255header- CAN ID - overridden by call to setHeader- Returns:
- ready to send CanMessage
-
isBootWriteData
Tests if a message is a bootloader data write- Parameters:
m- message- Returns:
- true if the message is a bootloader data write
-
isBootError
Tests if incoming CanReply is a Boot Command Error.- Parameters:
r- CanReply- Returns:
- True if is a Boot Command Error
-
isBootDataError
Tests if incoming CanReply is a Boot Data Error.- Parameters:
r- CanReply- Returns:
- True if is a Boot Data Error
-
isBootOK
Tests if incoming CanReply is a Boot Command OK.- Parameters:
r- CanReply- Returns:
- True if is a Boot COmmand OK
-
isBootDataOK
Tests if incoming CanReply is a Boot Data OK.- Parameters:
r- CanReply- Returns:
- True if is a Boot Data OK
-
isBootOutOfRange
Tests if incoming CanReply is a Boot Out of Range- Parameters:
r- CanReply- Returns:
- True if is a Boot Data OK
-
isBootDataOutOfRange
Tests if incoming CanReply is a Boot Out of Range- Parameters:
r- CanReply- Returns:
- True if is a Boot Data OK
-
isBootConfirm
Tests if incoming CanReply is a Boot Confirm.- Parameters:
r- CanReply- Returns:
- True if is a Boot Confirm
-
isBootDevId
Tests if incoming CanReply is a device ID reply.- Parameters:
r- CanReply- Returns:
- True if is a Boot Confirm
-
isBootId
Tests if incoming CanReply is a bootloader ID reply.- Parameters:
r- CanReply- Returns:
- True if is a Boot Confirm
-