Class GridConnectReply

java.lang.Object
jmri.jmrix.AbstractMessage
jmri.jmrix.AbstractMRReply
jmri.jmrix.can.adapters.gridconnect.GridConnectReply
All Implemented Interfaces:
Message
Direct Known Subclasses:
MergReply

public class GridConnectReply extends AbstractMRReply
Class for replies in a GridConnect based message/reply protocol.

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

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

  • Field Details

  • Constructor Details

    • GridConnectReply

      Creates a new instance of GridConnectReply.
    • GridConnectReply

      Creates a new GridConnectReply from String.
      Parameters:
      s - String to use as basis for the GCReply.
  • Method Details

    • createReply

      Create a CanReply from a GridConnectReply.
      Returns:
      new CanReply Outgoing message.
    • basicFormatCheck

      protected boolean basicFormatCheck()
      Check if this GCReply contains an Extended or Standard flag.
      Returns:
      true if contains a flag, else false.
    • skipPrefix

      protected int skipPrefix(int index)
      Specified by:
      skipPrefix in class AbstractMRReply
    • getNumDataElements

      public int getNumDataElements()
      Get the number of data elements in a Message.
      Specified by:
      getNumDataElements in interface Message
      Overrides:
      getNumDataElements in class AbstractMessage
      Returns:
      number elements.
    • setNumDataElements

      public void setNumDataElements(int n)
      Set Number of Data Elements. Max. length set by the MAXLEN constant.
      Parameters:
      n - Number Elements.
    • getElement

      public int getElement(int n)
      Get a particular element in a Message.
      Specified by:
      getElement in interface Message
      Overrides:
      getElement in class AbstractMessage
      Parameters:
      n - Element Index.
      Returns:
      single element of message.
    • setElement

      public void setElement(int n, int v)
      Set a single Data Element at a particular index.
      Specified by:
      setElement in interface Message
      Overrides:
      setElement in class AbstractMRReply
      Parameters:
      n - index of element.
      v - value of element.
    • isExtended

      public boolean isExtended()
      Get if the GridConnectReply is Extended.
      Returns:
      true if extended, else false.
    • isRtr

      public boolean isRtr()
      Get if the GridConnectReply is RtR.
      Returns:
      true if RtR, else false.
    • maxSize

      public int maxSize()
      Overrides:
      maxSize in class AbstractMRReply
    • setData

      public void setData(int[] d)
      Set the GridConnectReply data by Array.
      Parameters:
      d - data array.
    • getHeader

      public int getHeader()
      Get the CAN header by using chars from 2 to up to 9.

      Right justify standard headers that had 4 digits.

      Returns:
      the CAN header as an int
    • getNumBytes

      public int getNumBytes()
      Get the number of data bytes.
      Returns:
      number of bytes in reply.
    • getByte

      public int getByte(int b)
      Get a hex data byte from the message.

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

      Parameters:
      b - The byte offset (0 - 7)
      Returns:
      The value