Package jmri.jmrix.nce
Class NceMessage
- java.lang.Object
-
- jmri.jmrix.AbstractMessage
-
- jmri.jmrix.AbstractMRMessage
-
- jmri.jmrix.nce.NceMessage
-
- All Implemented Interfaces:
Message
public class NceMessage extends AbstractMRMessage
Encodes a message to an NCE command station.The
NceReply
class handles the response from the command station.The NCE protocol has "binary" and "ASCII" command sets. Depending on the version of the EPROM it contains, NCE command stations have different support for command sets:
- 1999 - All ASCII works. Binary works except for programming.
- 2004 - ASCII needed for programming, binary for everything else.
- 2006 - binary needed for everything
NceTrafficController.setCommandOptions(int)
method for more information.Apparently the binary "exitProgrammingMode" command can crash the command station if the EPROM was built before 2006. This method uses a state flag (
NceTrafficController.getNceProgMode()
) to detect whether a command to enter program mode has been generated, and presumably sent, when using the later EPROMS.
-
-
Field Summary
-
Fields inherited from class jmri.jmrix.AbstractMRMessage
LONG_TIMEOUT
-
Fields inherited from class jmri.jmrix.AbstractMessage
_dataChars, _nDataChars
-
-
Constructor Summary
Constructors Constructor Description NceMessage()
NceMessage(int i)
NceMessage(java.lang.String m)
NceMessage(NceMessage m)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static NceMessage
createAccDecoderPktOpsMode(NceTrafficController tc, int accyAddr, int cvAddr, int cvData)
static NceMessage
createAccySignalMacroMessage(NceTrafficController tc, int op, int addr, int data)
static NceMessage
createBinaryMessage(NceTrafficController tc, byte[] bytes)
static NceMessage
createBinaryMessage(NceTrafficController tc, byte[] bytes, int replyLen)
static NceMessage
getEnableMain(NceTrafficController tc)
static NceMessage
getEpromVersion(NceTrafficController tc)
static NceMessage
getExitProgMode(NceTrafficController tc)
Apparently the binary "exitProgrammingMode" command can crash the command station if the EPROM was built before 2006.static NceMessage
getKillMain(NceTrafficController tc)
static NceMessage
getProgMode(NceTrafficController tc)
enter programming track modestatic NceMessage
getReadDirectCV(NceTrafficController tc, int cv)
static NceMessage
getReadPagedCV(NceTrafficController tc, int cv)
Read Paged mode CV on programming track.static NceMessage
getReadRegister(NceTrafficController tc, int reg)
int
getReplyLen()
static NceMessage
getWriteDirectCV(NceTrafficController tc, int cv, int val)
static NceMessage
getWritePagedCV(NceTrafficController tc, int cv, int val)
Write paged mode CV to programming track.static NceMessage
getWriteRegister(NceTrafficController tc, int reg, int val)
boolean
isEnableMain()
boolean
isKillMain()
static NceMessage
queuePacketMessage(NceTrafficController tc, byte[] bytes)
static NceMessage
sendLocoCmd(NceTrafficController tc, int locoAddr, byte locoSubCmd, byte locoData)
static NceMessage
sendPacketMessage(NceTrafficController tc, byte[] bytes)
static NceMessage
sendPacketMessage(NceTrafficController tc, byte[] bytes, int retries)
void
setReplyLen(int len)
Set the number of characters expected back from the command station.java.lang.String
toMonitorString()
-
Methods inherited from class jmri.jmrix.AbstractMRMessage
addIntAsFourHex, addIntAsThree, addIntAsThreeHex, addIntAsTwoHex, getNeededMode, getOpCode, getOpCodeHex, getRetries, getTimeout, isBinary, replyExpected, setBinary, setNeededMode, setOpCode, setRetries, setTimeout, toString
-
Methods inherited from class jmri.jmrix.AbstractMessage
equals, getElement, getNumDataElements, hashCode, setElement
-
-
-
-
Field Detail
-
NOP_CMD
public static final int NOP_CMD
- See Also:
- Constant Field Values
-
ASSIGN_CAB_CMD
public static final int ASSIGN_CAB_CMD
- See Also:
- Constant Field Values
-
READ_CLOCK_CMD
public static final int READ_CLOCK_CMD
- See Also:
- Constant Field Values
-
STOP_CLOCK_CMD
public static final int STOP_CLOCK_CMD
- See Also:
- Constant Field Values
-
START_CLOCK_CMD
public static final int START_CLOCK_CMD
- See Also:
- Constant Field Values
-
SET_CLOCK_CMD
public static final int SET_CLOCK_CMD
- See Also:
- Constant Field Values
-
CLOCK_1224_CMD
public static final int CLOCK_1224_CMD
- See Also:
- Constant Field Values
-
CLOCK_RATIO_CMD
public static final int CLOCK_RATIO_CMD
- See Also:
- Constant Field Values
-
DEQUEUE_CMD
public static final int DEQUEUE_CMD
- See Also:
- Constant Field Values
-
READ_AUI4_CMD
public static final int READ_AUI4_CMD
- See Also:
- Constant Field Values
-
DUMMY_CMD
public static final int DUMMY_CMD
- See Also:
- Constant Field Values
-
SPEED_MODE_CMD
public static final int SPEED_MODE_CMD
- See Also:
- Constant Field Values
-
WRITE_N_CMD
public static final int WRITE_N_CMD
- See Also:
- Constant Field Values
-
READ16_CMD
public static final int READ16_CMD
- See Also:
- Constant Field Values
-
DISPLAY3_CMD
public static final int DISPLAY3_CMD
- See Also:
- Constant Field Values
-
DISPLAY4_CMD
public static final int DISPLAY4_CMD
- See Also:
- Constant Field Values
-
DISPLAY2_CMD
public static final int DISPLAY2_CMD
- See Also:
- Constant Field Values
-
QUEUE3_TMP_CMD
public static final int QUEUE3_TMP_CMD
- See Also:
- Constant Field Values
-
QUEUE4_TMP_CMD
public static final int QUEUE4_TMP_CMD
- See Also:
- Constant Field Values
-
QUEUE5_TMP_CMD
public static final int QUEUE5_TMP_CMD
- See Also:
- Constant Field Values
-
QUEUE6_TMP_CMD
public static final int QUEUE6_TMP_CMD
- See Also:
- Constant Field Values
-
WRITE1_CMD
public static final int WRITE1_CMD
- See Also:
- Constant Field Values
-
WRITE2_CMD
public static final int WRITE2_CMD
- See Also:
- Constant Field Values
-
WRITE4_CMD
public static final int WRITE4_CMD
- See Also:
- Constant Field Values
-
WRITE8_CMD
public static final int WRITE8_CMD
- See Also:
- Constant Field Values
-
READ_AUI2_CMD
public static final int READ_AUI2_CMD
- See Also:
- Constant Field Values
-
MACRO_CMD
public static final int MACRO_CMD
- See Also:
- Constant Field Values
-
READ1_CMD
public static final int READ1_CMD
- See Also:
- Constant Field Values
-
ENTER_PROG_CMD
public static final int ENTER_PROG_CMD
- See Also:
- Constant Field Values
-
EXIT_PROG_CMD
public static final int EXIT_PROG_CMD
- See Also:
- Constant Field Values
-
WRITE_PAGED_CV_CMD
public static final int WRITE_PAGED_CV_CMD
- See Also:
- Constant Field Values
-
READ_PAGED_CV_CMD
public static final int READ_PAGED_CV_CMD
- See Also:
- Constant Field Values
-
LOCO_CMD
public static final int LOCO_CMD
- See Also:
- Constant Field Values
-
QUEUE3_TRK_CMD
public static final int QUEUE3_TRK_CMD
- See Also:
- Constant Field Values
-
QUEUE4_TRK_CMD
public static final int QUEUE4_TRK_CMD
- See Also:
- Constant Field Values
-
QUEUE5_TRK_CMD
public static final int QUEUE5_TRK_CMD
- See Also:
- Constant Field Values
-
WRITE_REG_CMD
public static final int WRITE_REG_CMD
- See Also:
- Constant Field Values
-
READ_REG_CMD
public static final int READ_REG_CMD
- See Also:
- Constant Field Values
-
WRITE_DIR_CV_CMD
public static final int WRITE_DIR_CV_CMD
- See Also:
- Constant Field Values
-
READ_DIR_CV_CMD
public static final int READ_DIR_CV_CMD
- See Also:
- Constant Field Values
-
SW_REV_CMD
public static final int SW_REV_CMD
- See Also:
- Constant Field Values
-
RESET_SOFT_CMD
public static final int RESET_SOFT_CMD
- See Also:
- Constant Field Values
-
RESET_HARD_CMD
public static final int RESET_HARD_CMD
- See Also:
- Constant Field Values
-
SEND_ACC_SIG_MACRO_CMD
public static final int SEND_ACC_SIG_MACRO_CMD
- See Also:
- Constant Field Values
-
OPS_PROG_LOCO_CMD
public static final int OPS_PROG_LOCO_CMD
- See Also:
- Constant Field Values
-
OPS_PROG_ACCY_CMD
public static final int OPS_PROG_ACCY_CMD
- See Also:
- Constant Field Values
-
FACTORY_TEST_CMD
public static final int FACTORY_TEST_CMD
- See Also:
- Constant Field Values
-
USB_SET_CAB_CMD
public static final int USB_SET_CAB_CMD
- See Also:
- Constant Field Values
-
USB_MEM_POINTER_CMD
public static final int USB_MEM_POINTER_CMD
- See Also:
- Constant Field Values
-
USB_MEM_WRITE_CMD
public static final int USB_MEM_WRITE_CMD
- See Also:
- Constant Field Values
-
USB_MEM_READ_CMD
public static final int USB_MEM_READ_CMD
- See Also:
- Constant Field Values
-
LOCO_CMD_SELECT_LOCO
public static final byte LOCO_CMD_SELECT_LOCO
- See Also:
- Constant Field Values
-
LOCO_CMD_REV_28SPEED
public static final byte LOCO_CMD_REV_28SPEED
- See Also:
- Constant Field Values
-
LOCO_CMD_FWD_28SPEED
public static final byte LOCO_CMD_FWD_28SPEED
- See Also:
- Constant Field Values
-
LOCO_CMD_REV_128SPEED
public static final byte LOCO_CMD_REV_128SPEED
- See Also:
- Constant Field Values
-
LOCO_CMD_FWD_128SPEED
public static final byte LOCO_CMD_FWD_128SPEED
- See Also:
- Constant Field Values
-
LOCO_CMD_REV_ESTOP
public static final byte LOCO_CMD_REV_ESTOP
- See Also:
- Constant Field Values
-
LOCO_CMD_FWD_ESTOP
public static final byte LOCO_CMD_FWD_ESTOP
- See Also:
- Constant Field Values
-
LOCO_CMD_FG1
public static final byte LOCO_CMD_FG1
- See Also:
- Constant Field Values
-
LOCO_CMD_FG2
public static final byte LOCO_CMD_FG2
- See Also:
- Constant Field Values
-
LOCO_CMD_FG3
public static final byte LOCO_CMD_FG3
- See Also:
- Constant Field Values
-
LOCO_CMD_FG4
public static final byte LOCO_CMD_FG4
- See Also:
- Constant Field Values
-
LOCO_CMD_FG5
public static final byte LOCO_CMD_FG5
- See Also:
- Constant Field Values
-
LOCO_CMD_REV_CONSIST_LEAD
public static final byte LOCO_CMD_REV_CONSIST_LEAD
- See Also:
- Constant Field Values
-
LOCO_CMD_FWD_CONSIST_LEAD
public static final byte LOCO_CMD_FWD_CONSIST_LEAD
- See Also:
- Constant Field Values
-
LOCO_CMD_REV_CONSIST_REAR
public static final byte LOCO_CMD_REV_CONSIST_REAR
- See Also:
- Constant Field Values
-
LOCO_CMD_FWD_CONSIST_REAR
public static final byte LOCO_CMD_FWD_CONSIST_REAR
- See Also:
- Constant Field Values
-
LOCO_CMD_REV_CONSIST_MID
public static final byte LOCO_CMD_REV_CONSIST_MID
- See Also:
- Constant Field Values
-
LOCO_CMD_FWD_CONSIST_MID
public static final byte LOCO_CMD_FWD_CONSIST_MID
- See Also:
- Constant Field Values
-
LOCO_CMD_DELETE_LOCO_CONSIST
public static final byte LOCO_CMD_DELETE_LOCO_CONSIST
- See Also:
- Constant Field Values
-
LOCO_CMD_KILL_CONSIST
public static final byte LOCO_CMD_KILL_CONSIST
- See Also:
- Constant Field Values
-
ENABLE_MAIN_CMD
public static final int ENABLE_MAIN_CMD
- See Also:
- Constant Field Values
-
KILL_MAIN_CMD
public static final int KILL_MAIN_CMD
- See Also:
- Constant Field Values
-
SENDn_BYTES_CMD
public static final int SENDn_BYTES_CMD
- See Also:
- Constant Field Values
-
QUEUEn_BYTES_CMD
public static final int QUEUEn_BYTES_CMD
- See Also:
- Constant Field Values
-
NCE_PAGED_CV_TIMEOUT
protected static final int NCE_PAGED_CV_TIMEOUT
- See Also:
- Constant Field Values
-
NCE_DIRECT_CV_TIMEOUT
protected static final int NCE_DIRECT_CV_TIMEOUT
- See Also:
- Constant Field Values
-
SHORT_TIMEOUT
protected static final int SHORT_TIMEOUT
- See Also:
- Constant Field Values
-
REPLY_1
public static final int REPLY_1
- See Also:
- Constant Field Values
-
REPLY_2
public static final int REPLY_2
- See Also:
- Constant Field Values
-
REPLY_3
public static final int REPLY_3
- See Also:
- Constant Field Values
-
REPLY_4
public static final int REPLY_4
- See Also:
- Constant Field Values
-
REPLY_16
public static final int REPLY_16
- See Also:
- Constant Field Values
-
NCE_OKAY
public static char NCE_OKAY
-
replyLen
int replyLen
-
-
Constructor Detail
-
NceMessage
public NceMessage()
-
NceMessage
public NceMessage(int i)
-
NceMessage
public NceMessage(@Nonnull NceMessage m)
-
NceMessage
public NceMessage(@Nonnull java.lang.String m)
-
-
Method Detail
-
setReplyLen
public void setReplyLen(int len)
Set the number of characters expected back from the command station. Used in binary mode, where there's no end-of-reply string to look for.- Parameters:
len
- length of expected reply
-
getReplyLen
public int getReplyLen()
-
isKillMain
public boolean isKillMain()
-
isEnableMain
public boolean isEnableMain()
-
getEnableMain
public static NceMessage getEnableMain(NceTrafficController tc)
-
getKillMain
public static NceMessage getKillMain(NceTrafficController tc)
-
getProgMode
@Nonnull public static NceMessage getProgMode(@Nonnull NceTrafficController tc)
enter programming track mode- Parameters:
tc
- controller for the associated connection- Returns:
- a new message to enter programming track mode
-
getExitProgMode
@CheckForNull public static NceMessage getExitProgMode(@Nonnull NceTrafficController tc)
Apparently the binary "exitProgrammingMode" command can crash the command station if the EPROM was built before 2006. This method uses a state flag (NceTrafficController.getNceProgMode()
) to detect whether a command to enter program mode has been generated, and presumably sent, when using the later EPROMS.- Parameters:
tc
- controller for the associated connection- Returns:
- a new message to exit programming track mode
-
getReadPagedCV
@Nonnull public static NceMessage getReadPagedCV(@Nonnull NceTrafficController tc, int cv)
Read Paged mode CV on programming track.- Parameters:
tc
- controller for the associated connectioncv
- the CV to read- Returns:
- a new message to read a CV
-
getWritePagedCV
@Nonnull public static NceMessage getWritePagedCV(@Nonnull NceTrafficController tc, int cv, int val)
Write paged mode CV to programming track.- Parameters:
tc
- controller for the associated connectioncv
- CV to writeval
- value to write to cv- Returns:
- a new message to write a CV
-
getReadRegister
@CheckForNull public static NceMessage getReadRegister(@Nonnull NceTrafficController tc, int reg)
-
getWriteRegister
public static NceMessage getWriteRegister(NceTrafficController tc, int reg, int val)
-
getReadDirectCV
public static NceMessage getReadDirectCV(NceTrafficController tc, int cv)
-
getWriteDirectCV
public static NceMessage getWriteDirectCV(NceTrafficController tc, int cv, int val)
-
getEpromVersion
public static NceMessage getEpromVersion(NceTrafficController tc)
-
sendLocoCmd
public static NceMessage sendLocoCmd(NceTrafficController tc, int locoAddr, byte locoSubCmd, byte locoData)
-
sendPacketMessage
public static NceMessage sendPacketMessage(NceTrafficController tc, byte[] bytes)
-
sendPacketMessage
public static NceMessage sendPacketMessage(NceTrafficController tc, byte[] bytes, int retries)
-
createBinaryMessage
public static NceMessage createBinaryMessage(NceTrafficController tc, byte[] bytes)
-
createBinaryMessage
public static NceMessage createBinaryMessage(NceTrafficController tc, byte[] bytes, int replyLen)
-
queuePacketMessage
public static NceMessage queuePacketMessage(NceTrafficController tc, byte[] bytes)
-
createAccySignalMacroMessage
public static NceMessage createAccySignalMacroMessage(NceTrafficController tc, int op, int addr, int data)
-
createAccDecoderPktOpsMode
public static NceMessage createAccDecoderPktOpsMode(NceTrafficController tc, int accyAddr, int cvAddr, int cvData)
-
toMonitorString
public java.lang.String toMonitorString()
- Returns:
- a human-readable representation of the message.
-
-