Class GridConnectMessage

  • All Implemented Interfaces:
    Direct Known Subclasses:
    GridConnectDoubledMessage, MergMessage

    public class GridConnectMessage
    extends AbstractMRMessage
    Class for GridConnect messages for a CAN hardware adapter.

    The GridConnect protocol encodes messages as an ASCII string of up to 24 characters of the form: :ShhhhNd0d1d2d3d4d5d6d7;

    The S indicates a standard CAN frame :XhhhhhhhhNd0d1d2d3d4d5d6d7; The X indicates an extended CAN frame hhhh is the two byte header N or R indicates a normal or remote frame, in position 6 or 10 d0 - d7 are the (up to) 8 data bytes

    • Constructor Detail

      • GridConnectMessage

        public GridConnectMessage()
        Create a new instance of GridConnectMessage.
      • GridConnectMessage

        public GridConnectMessage​(CanMessage m)
        Create a new GridConnectMessage from CanMessage.
        m - CanMessage outgoing from JMRI.
    • Method Detail

      • setNumDataElements

        public void setNumDataElements​(int n)
        Set Number of Data Elements.
        n - number Elements. Max 28.
      • setData

        public void setData​(int[] d)
        Set data from array.
        d - array, max length 24.
      • setExtended

        public void setExtended​(boolean extended)
        Set the GC Message as Extended.
        extended - true for extended, else false
      • isExtended

        public boolean isExtended()
        Get if the GC Message is Extended.
        true for extended, else false
      • setHeader

        public void setHeader​(int header)
        Set the header.
        header - A valid CAN header value.
      • setRtr

        public void setRtr​(boolean rtr)
        Set CAN Frame as RtR.
        rtr - true to set rtr, else false.
      • setByte

        public void setByte​(int val,
                            int n)
        Set a byte as two ASCII hex digits.

        Data bytes are encoded as two ASCII hex digits starting at byte 7 of the message.

        val - the value to set.
        n - the index of the byte to be set.
      • setHexDigit

        protected void setHexDigit​(int val,
                                   int n)
        Set a hex digit at offset n in _dataChars.
        val - min 0, max value 15.
        n - _dataChars Array Index.