Class Z21Message

  • All Implemented Interfaces:
    Message

    public class Z21Message
    extends AbstractMRMessage
    Class for messages in the z21/Z21 protocol. Messages have the following format: 2 bytes data length. 2 bytes op code. n bytes data. All numeric values are stored in little endian format. Carries a sequence of characters, with accessors.
    • Constructor Detail

      • Z21Message

        public Z21Message​(java.lang.String m)
        This ctor interprets the String as the exact sequence to send, byte-for-byte.
        Parameters:
        m - message string.
      • Z21Message

        public Z21Message​(byte[] a,
                          int l)
        This ctor interprets the byte array as a sequence of characters to send.
        Parameters:
        a - Array of bytes to send
        l - unused.
    • 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 class AbstractMRMessage
        Returns:
        true by default in Abstract MR message.
      • setLength

        public void setLength​(int i)
      • getLanSetBroadcastFlagsRequestMessage

        public static Z21Message getLanSetBroadcastFlagsRequestMessage​(int flags)
        Set the broadcast flags as described in section 2.16 of the Roco Z21 Protocol Manual.

        Brief descriptions of the flags are as follows (losely translated from German with the aid of google translate).

        • 0x00000001 send XpressNet related information (track power on/off, programming mode, short circuit, broadcast stop, locomotive information, turnout information).
        • 0x00000002 send data changes that occur on the RMBUS.
        • 0x00000004 (deprecated by Roco) send Railcom Data
        • 0x00000100 send changes in system state (such as track voltage)
        • 0x00010000 send changes to locomotives on XpressNet (must also have 0x00000001 set.
        • 0x01000000 forward LocoNet data to the client. Does not send Locomotive or turnout data.
        • 0x02000000 send Locomotive specific LocoNet data to the client.
        • 0x04000000 send Turnout specific LocoNet data to the client.
        • 0x08000000 send Occupancy information from LocoNet to the client
        • 0x00040000 Automatically send updates for Railcom data to the client
        • 0x00080000 send can detector messages to the client
        Parameters:
        flags - integer representing the flags (32 bits).
        Returns:
        z21 message for LAN_SET_BROADCAST_FLAGS request.
      • toMonitorString

        public java.lang.String toMonitorString()
        Returns:
        a human-readable representation of the message.
      • getLanRMBusProgramModuleMessage

        public static Z21Message getLanRMBusProgramModuleMessage​(int address)
        Parameters:
        address - the RM Bus address to write.
        Returns:
        z21 message for LAN_RMBUS_PROGRAMMODULE
      • getLanCanDetector

        public static Z21Message getLanCanDetector​(int address)
        Parameters:
        address - CAN NetworkID of the module to request data from.
        Returns:
        z21 message for LAN_CAN_DETECTOR request message