ihex

package module
v0.0.0-...-e24378d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2015 License: MIT Imports: 4 Imported by: 1

README

ihex

Parser for Intel HEX files

Documentation: http://godoc.org/github.com/edmccard/ihex

Intel HEX specification: http://microsym.com/editor/assets/intelhex.pdf

Documentation

Overview

Package ihex implements a parser for Intel HEX files.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ParseError

type ParseError struct {
	Line int
	Msg  string
}

A ParseError represents an error encountered during parsing.

func (ParseError) Error

func (e ParseError) Error() string

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

A Parser reads records from an io.Reader, with an interface similar to bufio.Scanner.

Example
lines := `
:1000000000E10EBFEFE531E001E011E0010F40E05B
:1000100052E00E94710432E000E111EF010F41E073
:00000001FF
`
parser := NewParser(strings.NewReader(lines))
for parser.Parse() {
	data := parser.Data()
	fmt.Printf("%04x %d\n", data.Address, len(data.Bytes))
}
if err := parser.Err(); err != nil {
	fmt.Println("error:", err)
}
Output:

0000 16
0010 16

func NewParser

func NewParser(r io.Reader) *Parser

NewParser returns a new Parser to read from r.

func (*Parser) CSIP

func (p *Parser) CSIP() (cs uint16, ip uint16, ok bool)

CSIP returns cs and ip with ok true if the parser read a record of type 3; otherwise it returns with ok false.

func (*Parser) Data

func (p *Parser) Data() Record

Data returns the last record read by the Parse method. The underlying data may be overwritten by subsequent calls to Parse.

func (*Parser) EIP

func (p *Parser) EIP() (eip uint32, ok bool)

EIP returns eip with ok true if the parser read a record of type 5; otherwise it returns with ok false.

func (*Parser) Err

func (p *Parser) Err() error

Err returns the first error that was encountered by the Parser.

func (*Parser) Parse

func (p *Parser) Parse() bool

Parse reads the next data record, which can then be accessed by the Data method. It returns false when there are no more data records, or if an error occurred during parsing. After parsing is finished, information from record types 3 or 5 can be accessed by the CSIP or EIP methods; an error, if any, can be accessed by the Err method.

type Record

type Record struct {
	Address uint32
	Bytes   []byte
}

A Record holds the address and data bytes from a data (type 0) record. The Address field is calculated from the load offset of the record plus any segment that is in effect.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL