eeprom

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

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

Go to latest
Published: Oct 19, 2021 License: BSD-2-Clause Imports: 8 Imported by: 0

README

USB EEPROM Programming

Package eeprom provides an idiomatic interface to USB EEPROM programmers that conform to http://github.com/sstallion/usb-eeprom/wiki/Protocol. Due to the chip-agnostic nature of the protocol, constraints such as capacity and alignment must be enforced by the caller.

Documentation

Up-to-date documentation can be found on GoDoc, or by issuing the go doc command after installing the package:

$ go doc -all github.com/sstallion/go-eeprom

Installation

Note: libusb, is required to use this package and should be installed using the system package manager (eg. libusb-dev on Debian-based distributions via apt-get).

Package eeprom may be installed via the go get command:

$ go get github.com/sstallion/go-eeprom
eeprom

A command named eeprom is provided, which manages USB EEPROM programmers. eeprom may be installed by issuing:

$ go get github.com/sstallion/go-eeprom/cmd/eeprom

Once installed, issue eeprom help to display usage.

Contributing

Pull requests are welcome! If a problem is encountered using this package, please file an issue on GitHub.

License

Source code in this repository is licensed under a Simplified BSD License. See LICENSE for more details.

Documentation

Overview

Package eeprom provides an idiomatic interface to USB EEPROM programmers that conform to http://github.com/sstallion/usb-eeprom/wiki/Protocol. Due to the chip-agnostic nature of the protocol, constraints such as capacity and alignment must be enforced by the caller.

Example
var start uint16
var data []byte

// Program attached devices sequentially:
eeprom.Walk(func(d *eeprom.Device) error {
	if err := d.Open(); err != nil {
		return err
	}
	defer d.Close()

	if err := d.Erase(); err != nil {
		return err
	}
	return d.WriteBytes(start, data)
})
Output:

Index

Examples

Constants

View Source
const (
	// MaxBytes is the maximum amount of addressable data.
	MaxBytes = 1 << 16
)

Variables

This section is empty.

Functions

func Walk

func Walk(fn func(*Device) error) error

Walk calls the specified function for each supported device attached to the host. To ensure proper reference counting, Open must be called within the context of a Walk.

Types

type Device

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

Device represents an attached USB EEPROM programmer.

func First

func First() (*Device, error)

First returns the first supported device attached to the host. Unlike Walk, the returned Device is opened automatically. This function exists primarily for testing.

func (*Device) Close

func (d *Device) Close() error

Close releases the interface and closes the device. A device may not be opened again after calling this method. Returned errors may be safely ignored.

func (*Device) Erase

func (d *Device) Erase() error

Erase issues a Chip Erase.

func (*Device) ID

func (d *Device) ID() string

ID returns a string suitable for uniquely identifying the device.

func (*Device) Open

func (d *Device) Open() error

Open opens an attached device and claims the interface. To ensure proper reference counting, Open must be called within the context of a Walk.

func (*Device) Read

func (d *Device) Read(start uint16, data []byte) error

Read reads into the given slice at the supplied starting address.

func (*Device) Reset

func (d *Device) Reset() error

Reset issues a device reset. This method may be called after a failed transfer to reset the interface. Returned errors may be safely ignored.

func (*Device) SetPageSize

func (d *Device) SetPageSize(pagesize int)

SetPageSize sets the number of bytes written per page by WritePages. By default, the maximum packet size supported by the endpoint is used.

func (*Device) WriteBytes

func (d *Device) WriteBytes(start uint16, data []byte) error

WriteBytes writes the given slice starting at the supplied starting address.

func (*Device) WritePages

func (d *Device) WritePages(start uint16, data []byte) error

WritePages writes the given slice starting at the supplied starting address.

Directories

Path Synopsis
cmd
eeprom
eeprom is a tool that manages USB EEPROM programmers that conform to http://github.com/sstallion/usb-eeprom/wiki/Protocol.
eeprom is a tool that manages USB EEPROM programmers that conform to http://github.com/sstallion/usb-eeprom/wiki/Protocol.

Jump to

Keyboard shortcuts

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