Class SprogHexFile

All Implemented Interfaces:
ComponentListener, WindowListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants, BeanInterface, ModifiedFlag, WindowInterface

public class SprogHexFile extends JmriJFrame
Class to encapsulate an intel format hex file and methods to manipulate it. Intended use is as an input format for new program code to be sent to a hardware device via some bootloading process.
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • getName

      public String getName()
      Overrides:
      getName in class Component
      Returns:
      name of the open file
    • openRd

      public boolean openRd()
      Open hex file for reading.
      Returns:
      boolean true if successful
    • openWr

      public boolean openWr()
      Open file for writing.
      Returns:
      boolean true if successful
    • close

      public void close()
      Close the currently open file.
    • read

      public int read()
      Read a record (line) from the hex file.

      If it's an extended address record then update the address and read the next line. Returns the data length.

      Returns:
      int the data length of the record, or 0 if no data
    • readLine

      public int[] readLine()
      Read a line from the hex file and verify the checksum.
      Returns:
      int[] the array of bytes read from the file
    • write

      public void write(int addr, byte type, byte[] data)
      Write a line to the hex file.
      Parameters:
      addr - int the starting address of the data
      type - byte the type of data record being written
      data - byte[] the array of bytes to be written
    • wrExtAddr

      public void wrExtAddr(int addr)
      Write an extended address record.
      Parameters:
      addr - the extended address
    • wrEof

      public void wrEof()
      Write an end of file record.
    • getRecordType

      public int getRecordType()
      Get the type of the last record read from the hex file.
      Returns:
      byte the record type
    • getLen

      public int getLen()
      Get the length of the last record read from the hex file.
      Returns:
      byte the length
    • getAddress

      public int getAddress()
      Get current address.
      Returns:
      int the current address
    • getAddressL

      public byte getAddressL()
      Get lower byte of current address.
      Returns:
      byte the lower byte of the address
    • getAddressH

      public byte getAddressH()
      Get high (middle) byte of current address.
      Returns:
      byte the high (middle) byte of the address
    • getAddressU

      public byte getAddressU()
      Get upper byte of current address.
      Returns:
      byte the upper byte of the address
    • getData

      public int[] getData()
      Get data from last record read.
      Returns:
      byte[] array of data bytes