Class SerialMessage

    • 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.
        len - number of elements in the message
      • SerialMessage

        public SerialMessage​(SerialMessage m)
        Copy a SerialMessage to a new instance.
        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.
        m - String to use as message content
      • SerialMessage

        public SerialMessage​(byte[] a)
        Interpret the byte array as a sequence of characters to send.
        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).

        replyExpected in class AbstractMRMessage
        true by default in Abstract MR message.
      • 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.
        addr - address to poll.
        serial message to poll data.
      • setBank

        public void setBank​(int b)
      • 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.
        len - reply length.
      • format

        public java.lang.String format()
        Format the reply as human-readable text.
        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

        b1 - 1st message byte
        b2 - 2nd message byte
        b3 - 3rd message byte
        b4 - 4th message byte
        Human-readable form
      • colorAsString

        static java.lang.String colorAsString​(int color)