Documentation ¶
Index ¶
- Constants
- func CustomError(original FileError, msg string, args ...any) error
- type File
- type FileError
- type Record
- func (r *Record) Address() uint16
- func (r *Record) AddressBytes() []byte
- func (r *Record) AsString() string
- func (r *Record) ByteCount() int
- func (r *Record) Checksum() []byte
- func (r *Record) ReadData() []byte
- func (r *Record) Type() RecordType
- func (r *Record) WriteData(start int, data []byte) error
- type RecordError
- type RecordType
- type Unsigned
Constants ¶
const ( MissingStartCodeErr = RecordError("the passed record does not start with the correct start code") WrongRecordFormatErr = RecordError("the passed record is not a correct hex record") DataOutOfBounds = RecordError("the passed byte slice cannot be held by this record") InvalidHexDigit = RecordError("the passed byte represents a character that is not an hex digit") NoMoreRecordsErr = RecordError("no more records") )
const ( MultipleEofErr = FileError("the passed hex file contains more than one EOF records") NoEofRecordErr = FileError("the passed hex file does not contain an EOF record") AccessOutOfBounds = FileError("cannot access the hex file out of the length of the encoded program") RecordErr = FileError("faulty record") )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
File implements an Intel Hex-encoded file
func ReadAll ¶
func ReadAll(in io.ByteReader) (*File, error)
ReadAll initializes a hex file by reading every byte from its source, parsing the records and validating them
func (*File) ReadAt ¶
ReadAt reads size bytes starting from pos position in the hex-encoded file. This implements a sort of random access to the data mapped in hex-format.
type Record ¶
type Record struct {
// contains filtered or unexported fields
}
Record is an HEX Record that has been validated. Instantiate only via ParseRecord
func ParseRecord ¶
func ParseRecord(input io.ByteReader) (*Record, error)
ParseRecord initializes a new Record reading from a ByteReader. This function returns an error if the byte stream that is read does not represent a valid Record.
func (*Record) AddressBytes ¶
AddressBytes is the hex representation of the record address value
type RecordError ¶
type RecordError string
RecordError identifies an error related to a hex record
func (RecordError) Error ¶
func (r RecordError) Error() string
Error returns a string representation of a RecordError
type RecordType ¶
type RecordType uint
RecordType identifies the type of hex record (Data, EOF, etc.)
const ( DataRecord RecordType = iota // A DataRecord contains data in hex format EOFRecord // An EOFRecord identifies the end of a hex file ExtendedSegmentAddrRecord StartSegmentAddrRecord ExtendedLinearAddrRecord StartLinearAddrRecord InvalidRecord )