Interface CanFrame

All Known Subinterfaces:
CanMutableFrame
All Known Implementing Classes:
CanMessage, CanReply

@Immutable
public interface CanFrame
Base interface for immutable messages in a CANbus based message/reply protocol.

It is expected that any CAN based system will be based upon basic CAN concepts such as ID/header (standard or extended), Normal and RTR frames and a data field.

"header" refers to the full 11 or 29 bit header; which mode is separately set via the "extended" parameter

  • Method Summary

    Modifier and Type Method Description
    default void appendHexElements​(StringBuilder sb)
    Append the hex value of the data elements to a StringBuilder.
    default boolean dataFramesEqual​(CanFrame a, CanFrame b)
    Compare 2 CanFrame data elements for equality.
    default boolean extendedOrRtr()
    Check if the CAN Frame is extended OR RtR.
    int getElement​(int n)
    Get a single data byte in the frame.
    int getHeader()
    Get the CAN Frame header.
    int getNumDataElements()
    Get number of data bytes in the frame.
    default String getToString()
    Get formatted toString.
    default boolean isEqual​(Object a, Object b)
    Compare 2 CanFrames for equality.
    boolean isExtended()
    Get if the CAN Frame has an extended header.
    boolean isRtr()
    Get if the CAN Frame is an RTR Frame.
    default String monString()
    Get formatted monitor String.
  • Method Details

    • getHeader

      int getHeader()
      Get the CAN Frame header.
      Returns:
      header value
    • isExtended

      boolean isExtended()
      Get if the CAN Frame has an extended header.
      Returns:
      true if extended, else false
    • isRtr

      boolean isRtr()
      Get if the CAN Frame is an RTR Frame.
      Returns:
      true if RTR, else false
    • getNumDataElements

      Get number of data bytes in the frame.
      Returns:
      0-8
    • getElement

      int getElement​(int n)
      Get a single data byte in the frame.
      Parameters:
      n - the index, 0-7
      Returns:
      the data element value
    • monString

      default String monString()
      Get formatted monitor String. Includes if Frame is Extended. Header value at start. All values hex format. Only valid data elements are included.
      Returns:
      eg. "(1A ext) 81 EA 83 00 12"
    • getToString

      default String getToString()
      Get formatted toString. Does NOT include if Frame is Extended. All values hex format. Only valid data elements are included.
      Returns:
      eg. "[12] 81 EA 83"
    • appendHexElements

      default void appendHexElements​(StringBuilder sb)
      Append the hex value of the data elements to a StringBuilder.
      Parameters:
      sb - to append the hex values to
    • isEqual

      default boolean isEqual​(Object a, Object b)
      Compare 2 CanFrames for equality.
      Parameters:
      a - CanFrame to test
      b - CanFrame to test
      Returns:
      true if RTR, Extended, Header and Data elements match, else false
    • dataFramesEqual

      default boolean dataFramesEqual​(CanFrame a, CanFrame b)
      Compare 2 CanFrame data elements for equality.
      Parameters:
      a - CanFrame to test
      b - CanFrame to test
      Returns:
      true if Data elements match, else false
    • extendedOrRtr

      default boolean extendedOrRtr()
      Check if the CAN Frame is extended OR RtR.
      Returns:
      true if either extended or RtR, else false