Class HexFile
java.lang.Object
jmri.jmrix.can.cbus.swing.bootloader.HexFile
- Direct Known Subclasses:
CbusPicHexFile
Class to encapsulate an intel format hex file for a CBUS PIC.
Assumes hex record addresses are 8-byte aligned and that addresses increase
monotonically.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected BufferedInputStreamprotected intprotected Fileprotected HexRecord[]protected FileInputStreamprotected intprotected static final intprotected Stringprotected booleanprotected int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidDProcess record if requiredvoidclose()Close the currently open file.voiddispose()close the open fileintGet current address.intGet current file line numbergetName()Return the next TYPE_DATA record from the fileGet the file parameters Create an invalid parameter set of necessary.intReturn the highest address read from the hex fileintReturn the lowest address read from the hex filegetRecordForAddress(int addr) Get the hex record for a given address Expected that the address will be the start address of a record but will return the first record that encompasses the address and increment the index to point at the next record.voidopenRd()Open hex file for reading.intRead a hex byte.voidread()Read a hex file.intreadChar()Read a character from the hex fileprotected HexRecordRead one hex record from the file
-
Field Details
-
name
-
file
-
in
-
buffIn
-
MAX_HEX_SIZE
- See Also:
-
address
-
read
-
lineNo
-
hexRecords
-
readIndex
-
endRecord
-
-
Constructor Details
-
HexFile
Create a new HexFile object and initialize data to unprogrammed state.- Parameters:
fileName- file name to use for the hex file
-
-
Method Details
-
getName
- Returns:
- name of the open file
-
openRd
Open hex file for reading.- Throws:
FileNotFoundException- if pre-defined file can't be opened
-
close
Close the currently open file.Safe to call if the file was never opened, or has already been closed. The records already read remain available in memory.
-
checkRecord
DProcess record if required- Parameters:
r- hex record
-
readOneRecord
Read one hex record from the file- Returns:
- the hex record
- Throws:
IOException- on read error.
-
read
Read a hex file.Read hex records and store TYPE_DATA records in the array.
Only data, end of file and extended linear address records are understood. Any other record type causes the file to be rejected.
- Throws:
IOException- on read error, or if the file contains an unsupported record type, or too many records
-
readChar
Read a character from the hex file- Returns:
- the character
- Throws:
IOException- from the underlying read operation
-
rdHexByte
Read a hex byte.- Returns:
- the byte
- Throws:
IOException- from the underlying read operation
-
getAddress
Get current address.- Returns:
- int the current address
-
getLineNo
Get current file line number- Returns:
- the file number
-
getNextRecord
Return the next TYPE_DATA record from the fileOnce the records read from the file are exhausted, an END record is returned so that callers stop cleanly.
- Returns:
- the next hex record
-
getRecordForAddress
Get the hex record for a given address Expected that the address will be the start address of a record but will return the first record that encompasses the address and increment the index to point at the next record.Only the records actually read from the file are searched.
- Parameters:
addr- The address- Returns:
- the hex record, or empty if no data record contains the address
-
getParams
Get the file parameters Create an invalid parameter set of necessary. Override in hardware specific implementations.- Returns:
- CBUS parameters from the file
-
getProgStart
Return the lowest address read from the hex file- Returns:
- the highest address
-
getProgEnd
Return the highest address read from the hex file- Returns:
- the highest address
-
dispose
close the open file
-