Documentation
¶
Index ¶
Examples ¶
Constants ¶
const ( Data RecordType = 0x00 EndOfFile = 0x01 ExtendedSegmentAddress = 0x02 StartSegmentAddress = 0x03 ExtendedLinearAddress = 0x04 StartLinearAddress = 0x05 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Parses IHEX files.
Example ¶
d := NewDecoder(os.Stdin)
for d.Scan() {
// do something with d.Record()
}
// check if there was an error during parsing
err := d.Err()
if err != nil {
// handle the error
}
func NewDecoder ¶
Create a new Decoder using input from the given io.Reader.
func (*Decoder) Err ¶
Returns the first error that occurred during parsing, or nil if there was no error.
func (*Decoder) Record ¶
Returns the most recently parsed record. An empty record is returned if Scan has not yet been called, or if Scan has never returned true.
func (*Decoder) Scan ¶
Read and decode one record from the source, returning true if the record was decoded successfully. False may be returned if the end of the file is reached or an error has occurred. This method is designed to be called repeatedly to read the entire file, and then have the Err method called to determine if an error occurred. The scanned record can be retrieved with the Record method.
type ExtAddress ¶
type ExtAddress uint32
ExtAddress represents an extended address of width up to 32-bits
type ExtAddressSlice ¶
type ExtAddressSlice []ExtAddress
ExtAddressSlice is defined in order to allow implemention of the Sort interface for client convenience. Invoke as follows:
import "sort"
addressesToSort := []ExtAddress{....}
sort.Sort(ExtAddressSlice(addressesToSort))
func (ExtAddressSlice) Len ¶
func (a ExtAddressSlice) Len() int
func (ExtAddressSlice) Less ¶
func (a ExtAddressSlice) Less(i, j int) bool
func (ExtAddressSlice) Swap ¶
func (a ExtAddressSlice) Swap(i, j int)
type Record ¶
type Record struct {
// The type of record
Type RecordType
// The address associated with the record's data (for Data records).
Address uint16
// The Extended address associated with the record's data
ExtendedAddress ExtAddress
// The payload of the record.
Data []byte
}
Represents a single IHEX record.
func DecodeRecord ¶
Interpreting bytes as the binary form of an IHEX record, decode and return a Record. err may be non-nil if there was a checksum mismatch.
func DecodeRecordHex ¶
Interpreting hexStr as the hexadecimal form of an IHEX record with or without the leading start token (colon), deocde and return a Record. err may be non-nil if there was a checksum mismatch or if the decoding from hexadecimal failed.
type RecordType ¶
type RecordType uint8
RecordType is a value from 0 to 5 as described in the intel hex spec (http://www.piclist.com/techref/fileext/hex/intel.htm)