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 Modifier and Type Field Description static int
ASSIGN_CAB_CMD
static int
CLOCK_1224_CMD
static int
CLOCK_RATIO_CMD
static int
DEQUEUE_CMD
static int
DISPLAY2_CMD
static int
DISPLAY3_CMD
static int
DISPLAY4_CMD
static int
DUMMY_CMD
static int
ENABLE_MAIN_CMD
static int
ENTER_PROG_CMD
static int
EXIT_PROG_CMD
static int
FACTORY_TEST_CMD
static int
KILL_MAIN_CMD
static int
LOCO_CMD
static int
MACRO_CMD
protected static int
NCE_DIRECT_CV_TIMEOUT
protected static int
NCE_PAGED_CV_TIMEOUT
static int
NOP_CMD
static int
OPS_PROG_ACCY_CMD
static int
OPS_PROG_LOCO_CMD
static int
QUEUE3_TMP_CMD
static int
QUEUE3_TRK_CMD
static int
QUEUE4_TMP_CMD
static int
QUEUE4_TRK_CMD
static int
QUEUE5_TMP_CMD
static int
QUEUE5_TRK_CMD
static int
QUEUE6_TMP_CMD
static int
QUEUEn_BYTES_CMD
static int
READ_AUI2_CMD
static int
READ_AUI4_CMD
static int
READ_CLOCK_CMD
static int
READ_DIR_CV_CMD
static int
READ_PAGED_CV_CMD
static int
READ_REG_CMD
static int
READ1_CMD
static int
READ16_CMD
static int
REPLY_1
static int
REPLY_16
static int
REPLY_2
static int
REPLY_4
(package private) int
replyLen
static int
RESET_HARD_CMD
static int
RESET_SOFT_CMD
static int
SEND_ACC_SIG_MACRO_CMD
static int
SENDn_BYTES_CMD
static int
SET_CLOCK_CMD
protected static int
SHORT_TIMEOUT
static int
SPEED_MODE_CMD
static int
START_CLOCK_CMD
static int
STOP_CLOCK_CMD
static int
SW_REV_CMD
static int
USB_MEM_POINTER_CMD
static int
USB_MEM_READ_CMD
static int
USB_MEM_WRITE_CMD
static int
USB_SET_CAB_CMD
static int
WRITE_DIR_CV_CMD
static int
WRITE_N_CMD
static int
WRITE_PAGED_CV_CMD
static int
WRITE_REG_CMD
static int
WRITE1_CMD
static int
WRITE2_CMD
static int
WRITE4_CMD
static int
WRITE8_CMD
-
Constructor Summary
Constructors Constructor Description NceMessage()
NceMessage(int i)
NceMessage(String m)
NceMessage(NceMessage m)
-
Method Summary
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
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
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.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 Details
-
NOP_CMD
- See Also:
- Constant Field Values
-
ASSIGN_CAB_CMD
- See Also:
- Constant Field Values
-
READ_CLOCK_CMD
- See Also:
- Constant Field Values
-
STOP_CLOCK_CMD
- See Also:
- Constant Field Values
-
START_CLOCK_CMD
- See Also:
- Constant Field Values
-
SET_CLOCK_CMD
- See Also:
- Constant Field Values
-
CLOCK_1224_CMD
- See Also:
- Constant Field Values
-
CLOCK_RATIO_CMD
- See Also:
- Constant Field Values
-
DEQUEUE_CMD
- See Also:
- Constant Field Values
-
READ_AUI4_CMD
- See Also:
- Constant Field Values
-
DUMMY_CMD
- See Also:
- Constant Field Values
-
SPEED_MODE_CMD
- See Also:
- Constant Field Values
-
WRITE_N_CMD
- See Also:
- Constant Field Values
-
READ16_CMD
- See Also:
- Constant Field Values
-
DISPLAY3_CMD
- See Also:
- Constant Field Values
-
DISPLAY4_CMD
- See Also:
- Constant Field Values
-
DISPLAY2_CMD
- See Also:
- Constant Field Values
-
QUEUE3_TMP_CMD
- See Also:
- Constant Field Values
-
QUEUE4_TMP_CMD
- See Also:
- Constant Field Values
-
QUEUE5_TMP_CMD
- See Also:
- Constant Field Values
-
QUEUE6_TMP_CMD
- See Also:
- Constant Field Values
-
WRITE1_CMD
- See Also:
- Constant Field Values
-
WRITE2_CMD
- See Also:
- Constant Field Values
-
WRITE4_CMD
- See Also:
- Constant Field Values
-
WRITE8_CMD
- See Also:
- Constant Field Values
-
READ_AUI2_CMD
- See Also:
- Constant Field Values
-
MACRO_CMD
- See Also:
- Constant Field Values
-
READ1_CMD
- See Also:
- Constant Field Values
-
ENTER_PROG_CMD
- See Also:
- Constant Field Values
-
EXIT_PROG_CMD
- See Also:
- Constant Field Values
-
WRITE_PAGED_CV_CMD
- See Also:
- Constant Field Values
-
READ_PAGED_CV_CMD
- See Also:
- Constant Field Values
-
LOCO_CMD
- See Also:
- Constant Field Values
-
QUEUE3_TRK_CMD
- See Also:
- Constant Field Values
-
QUEUE4_TRK_CMD
- See Also:
- Constant Field Values
-
QUEUE5_TRK_CMD
- See Also:
- Constant Field Values
-
WRITE_REG_CMD
- See Also:
- Constant Field Values
-
READ_REG_CMD
- See Also:
- Constant Field Values
-
WRITE_DIR_CV_CMD
- See Also:
- Constant Field Values
-
READ_DIR_CV_CMD
- See Also:
- Constant Field Values
-
SW_REV_CMD
- See Also:
- Constant Field Values
-
RESET_SOFT_CMD
- See Also:
- Constant Field Values
-
RESET_HARD_CMD
- See Also:
- Constant Field Values
-
SEND_ACC_SIG_MACRO_CMD
- See Also:
- Constant Field Values
-
OPS_PROG_LOCO_CMD
- See Also:
- Constant Field Values
-
OPS_PROG_ACCY_CMD
- See Also:
- Constant Field Values
-
FACTORY_TEST_CMD
- See Also:
- Constant Field Values
-
USB_SET_CAB_CMD
- See Also:
- Constant Field Values
-
USB_MEM_POINTER_CMD
- See Also:
- Constant Field Values
-
USB_MEM_WRITE_CMD
- See Also:
- Constant Field Values
-
USB_MEM_READ_CMD
- See Also:
- Constant Field Values
-
ENABLE_MAIN_CMD
- See Also:
- Constant Field Values
-
KILL_MAIN_CMD
- See Also:
- Constant Field Values
-
SENDn_BYTES_CMD
- See Also:
- Constant Field Values
-
QUEUEn_BYTES_CMD
- See Also:
- Constant Field Values
-
NCE_PAGED_CV_TIMEOUT
- See Also:
- Constant Field Values
-
NCE_DIRECT_CV_TIMEOUT
- See Also:
- Constant Field Values
-
SHORT_TIMEOUT
- See Also:
- Constant Field Values
-
REPLY_1
- See Also:
- Constant Field Values
-
REPLY_2
- See Also:
- Constant Field Values
-
REPLY_4
- See Also:
- Constant Field Values
-
REPLY_16
- See Also:
- Constant Field Values
-
replyLen
int replyLen
-
-
Constructor Details
-
NceMessage
public NceMessage() -
NceMessage
-
NceMessage
-
NceMessage
-
-
Method Details
-
setReplyLen
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
-
isKillMain
-
isEnableMain
-
getEnableMain
-
getKillMain
-
getProgMode
enter programming track mode- Parameters:
tc
- controller for the associated connection- Returns:
- a new message to enter programming track mode
-
getExitProgMode
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
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
-
getWriteRegister
-
getReadDirectCV
-
getWriteDirectCV
-
sendPacketMessage
-
sendPacketMessage
-
createBinaryMessage
-
createBinaryMessage
-
queuePacketMessage
-
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
-