mash / go-intelhex

Intel HEX file format parser/formatter in golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed to parse address

niondir opened this issue · comments

In parser.go I had to fix the address parsing like this:

	addressString, ok := p.acceptValue(fieldAddress)
	if !ok {
		return p.errorf("Address expected but got something else")
	}
	address, err := strconv.ParseInt(addressString, 16, 64)
	if err != nil {
		return p.errorf("%s. Failed to parse address: %s", err, addressString)
	}

Parsing the address with bitSize = 16 failed for bigger address values. I increased it to 64 to be safe. Also the original error message was not printed which would have been very helpful. With my code the reported error is:

ERRO[0000] Bad record error="strconv.ParseInt: parsing "8000": value out of range. Failed to parse address: 8000"

Add this to your tests:

	{ // max addr
		":01FFFF00CB36\n",
		[]Record{
			{1, 65535, RecordTypeData, "CB"},
		},
		1,
		32,
	},

Thanks!