Class RfidProtocol

java.lang.Object
jmri.jmrix.rfid.RfidProtocol
Direct Known Subclasses:
CoreIdRfidProtocol, Em18RfidProtocol, OlimexRfid1356mifareProtocol, OlimexRfidProtocol, ParallaxRfidProtocol, SeeedStudioRfidProtocol

public abstract class RfidProtocol
extends Object
Basic interface to be implemented for each tag protocol.
Since:
3.9.2
  • Field Details

  • Constructor Details

    • RfidProtocol

      public RfidProtocol()
      Constructor for an RFID Protocol. Used when a single reader is connected directly to a port, not via a concentrator.
    • RfidProtocol

      public RfidProtocol​(char concentratorFirst, char concentratorLast, int portPosition)
      Constructor for an RFID Protocol. Supports the use of concentrators where a character range is used to determine the specific reader port.
      Parameters:
      concentratorFirst - character representing first concentrator port
      concentratorLast - character representing last concentrator port
      portPosition - position of port character in reply string; 1 for first character
  • Method Details

    • getTag

      public String getTag​(AbstractMRReply msg)
      Retrieves RFID Tag information from message
      Parameters:
      msg - Message to decode
      Returns:
      String representation of tag
    • providesChecksum

      public boolean providesChecksum()
      Determines if this protocol provides checksum values Default is false. Protocols that do provide them should override this method.
      Returns:
      true if provided
    • getCheckSum

      public abstract String getCheckSum​(AbstractMRReply msg)
      When available, returns the checksum portion of an RFID reply
      Parameters:
      msg - RFID reply to process
      Returns:
      checksum value
    • isValid

      public abstract boolean isValid​(AbstractMRReply msg)
      Determines if this RFID reply is valid
      Parameters:
      msg - RFID reply to process
      Returns:
      true if valid
    • endOfMessage

      public abstract boolean endOfMessage​(AbstractMRReply msg)
      Determines if at the end of this RFID reply
      Parameters:
      msg - RFID reply to process
      Returns:
      true if at end
    • initString

      public abstract String initString()
      Returns the initialisation string to be sent to an adapter implementing the protocol. For those protocols that do not require one, return a blank string
      Returns:
      initialisation string
    • getReaderPort

      public char getReaderPort​(AbstractMRReply msg)
    • toMonitorString

      Provides a textual representation of this message for the monitor
      Parameters:
      msg - RFID reply to process
      Returns:
      textual representation
    • convertHexString

      protected static byte[] convertHexString​(String s)
      Converts a hex string to an unsigned byte array. Both upper and lower case hex codes are permitted.
      Parameters:
      s - String representation of a hex number. Must be a whole number of bytes (i.e. an even number of characters) and be formed only of digits 0..9, a..f or A..F
      Returns:
      corresponding unsigned byte array
      Throws:
      IllegalArgumentException - when s is not a valid hex string