srec

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

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 5 Imported by: 2

README

srec

A library of Motolola Hex(S Record, *.mot, *mhx) file utilities

Usage

You can use following interfaces :

// NewSrec returns a new Srec object
func NewSrec() *Srec {
// EndAddress returns endaddress of the record
func (rec *Record) EndAddress() uint32 {
// CalcChecksum calculates the checksum value of the record from the information of the arguments
func (rec *Record) CalcChecksum() (uint8, error) {
// CalcChecksum calculates the checksum value of the record from the information of the arguments
// S4, S6 are not handled
func (srs *Srec) Parse(fileReader io.Reader) error {
func (srs *Srec) EndAddr() uint32 {
// MakeRec creates and returns a new Record object from the argument information
func MakeRec(srectype string, addr uint32, data []byte) (*Record, error) {

Example

See following files:

./sample/main.go
./sample2/main.go

Installation

go get github.com/akif999/srec

License

MIT

Author

Akifumi Kitabatake(a.k.a akif999)

Documentation

Index

Constants

View Source
const (
	TypeLen   = 1
	LengthLen = 1
	S0AddrLen = 2
	S1AddrLen = 2
	S2AddrLen = 3
	S3AddrLen = 4
	S5AddrLen = 0
	S7AddrLen = 4
	S8AddrLen = 3
	S9AddrLen = 2
	CSumLen   = 1
)

constructed values of a field that always has a fixed length in the S record

Variables

This section is empty.

Functions

This section is empty.

Types

type Record

type Record struct {
	Srectype string
	Length   uint8
	Address  uint32
	Data     []byte
	Checksum uint8
}

Record is a type of structure that expresses S records per row

func MakeRec

func MakeRec(srectype string, addr uint32, data []byte) (*Record, error)

MakeRec creates and returns a new Record object from the argument information

func (*Record) CalcChecksum

func (rec *Record) CalcChecksum() (uint8, error)

CalcChecksum calculates the checksum value of the record from the information of the arguments

func (*Record) EndAddress

func (rec *Record) EndAddress() uint32

EndAddress returns endaddress of the record

func (*Record) String

func (r *Record) String() string

String returns the contents of the Record. If the Record has wrong srectype, it returns "<invalid srectype>"

type Srec

type Srec struct {
	Records []*Record
}

Srec is a type of structure with multiple Record structures

func NewSrec

func NewSrec() *Srec

NewSrec returns a new Srec object

func (*Srec) EndAddr

func (srs *Srec) EndAddr() uint32

EndAddr returns the record's end address from the records of the Srec object Since the end address of the S record is (address of the last record + data length -1), 1 is subtracted Please be aware that processing costs are high as it traverses the entire object

func (*Srec) Parse

func (srs *Srec) Parse(fileReader io.Reader) error

Parse creates a Srec object (basically an opened file) from io.Reader If it contains a character string that starts with S4, S6 or does not start S [0-9] to the first 2 bytes, processing stops and an error will be return

func (*Srec) String

func (sr *Srec) String() string

String return the contents of the entire Srecord.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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