Package jmri.jmrix.grapevine
Class SerialMessage
- java.lang.Object
-
- jmri.jmrix.AbstractMessage
-
- jmri.jmrix.AbstractMRMessage
-
- jmri.jmrix.grapevine.SerialMessage
-
- All Implemented Interfaces:
Message
public class SerialMessage extends AbstractMRMessage
Contains the data payload of a serial packet. Note that it's _only_ the payload.See the Grapevine Binary Message Format Summary
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.lang.String[]
colors
(package private) int
replyLen
-
Fields inherited from class jmri.jmrix.AbstractMRMessage
LONG_TIMEOUT, SHORT_TIMEOUT
-
Fields inherited from class jmri.jmrix.AbstractMessage
_dataChars, _nDataChars
-
-
Constructor Summary
Constructors Constructor Description SerialMessage()
Create a new SerialMessage instance.SerialMessage(byte[] a)
Interpret the byte array as a sequence of characters to send.SerialMessage(int len)
Create a new SerialMessage instance of a given byte size.SerialMessage(java.lang.String m)
Create a new Message instance from a string.SerialMessage(SerialMessage m)
Copy a SerialMessage to a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static java.lang.String
colorAsString(int color)
java.lang.String
format()
Format the reply as human-readable text.int
getAddr()
static SerialMessage
getPoll(int addr)
For Grapevine, which doesn't have a data poll, the poll operation is only used to see that the nodes are present.int
getReplyLen()
boolean
replyExpected()
Is a reply expected to this message?void
setBank(int b)
void
setParity()
void
setParity(int start)
void
setReplyLen(int len)
Set the number of characters expected back from the command station.(package private) static java.lang.String
staticFormat(int b1, int b2, int b3, int b4)
Provide a human-readable form of a message.-
Methods inherited from class jmri.jmrix.AbstractMRMessage
addIntAsFourHex, addIntAsThree, addIntAsThreeHex, addIntAsTwoHex, getNeededMode, getOpCode, getOpCodeHex, getRetries, getTimeout, isBinary, setBinary, setNeededMode, setOpCode, setRetries, setTimeout, toString
-
Methods inherited from class jmri.jmrix.AbstractMessage
equals, getElement, getNumDataElements, hashCode, setElement
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jmri.jmrix.Message
toMonitorString
-
-
-
-
Constructor Detail
-
SerialMessage
public SerialMessage()
Create a new SerialMessage instance.
-
SerialMessage
public SerialMessage(int len)
Create a new SerialMessage instance of a given byte size.- Parameters:
len
- number of elements in the message
-
SerialMessage
public SerialMessage(SerialMessage m)
Copy a SerialMessage to a new instance.- Parameters:
m
- the message to copy
-
SerialMessage
public SerialMessage(java.lang.String m)
Create a new Message instance from a string. Interprets the String as the exact sequence to send, byte-for-byte.- Parameters:
m
- String to use as message content
-
SerialMessage
public SerialMessage(byte[] a)
Interpret the byte array as a sequence of characters to send.- Parameters:
a
- Array of bytes to send
-
-
Method Detail
-
replyExpected
public boolean replyExpected()
Description copied from class:AbstractMRMessage
Is a reply expected to this message?By default, a reply is expected to every message; either a reply or a timeout is needed before the next message can be sent.
If this returns false, the transmit queue will immediately go on to transmit the next message (if any).
- Overrides:
replyExpected
in classAbstractMRMessage
- Returns:
- true by default in Abstract MR message.
-
getAddr
public int getAddr()
-
getPoll
public static SerialMessage getPoll(int addr)
For Grapevine, which doesn't have a data poll, the poll operation is only used to see that the nodes are present. This is done by sending a "get software version" command.- Parameters:
addr
- address to poll.- Returns:
- serial message to poll data.
-
setBank
public void setBank(int b)
-
setParity
public void setParity()
-
setParity
public void setParity(int start)
-
setReplyLen
public void setReplyLen(int len)
Set the number of characters expected back from the command station. Normally four, this is used to set other lengths for special cases, like a reply to a poll (software version) message.- Parameters:
len
- reply length.
-
getReplyLen
public int getReplyLen()
-
format
public java.lang.String format()
Format the reply as human-readable text.- Returns:
- human-readable text of reply.
-
staticFormat
static java.lang.String staticFormat(int b1, int b2, int b3, int b4)
Provide a human-readable form of a message.Used by both SerialMessage and SerialReply, because so much of it is common. That forces the passing of arguments as numbers. Short messages are marked by having missing bytes put to -1 in the arguments. See the Grapevine Binary Message Format Summary
- Parameters:
b1
- 1st message byteb2
- 2nd message byteb3
- 3rd message byteb4
- 4th message byte- Returns:
- Human-readable form
-
colorAsString
static java.lang.String colorAsString(int color)
-
-