Class GridConnectMessage

  • All Implemented Interfaces:
    Message
    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.
        Parameters:
        m - CanMessage outgoing from JMRI.
    • Method Detail

      • setNumDataElements

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

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

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

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

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

        public void setRtr​(boolean rtr)
        Set CAN Frame as RtR.
        Parameters:
        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.

        Parameters:
        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.
        Parameters:
        val - min 0, max value 15.
        n - _dataChars Array Index.