Exemple #1
0
func openDevice() (*eeprom.Device, error) {
	var device *eeprom.Device

	err := eeprom.Walk(func(d *eeprom.Device) error {
		if device == nil && (deviceID == "" || deviceID == d.ID()) {
			device = d
			return d.Open()
		}
		return nil
	})
	return device, err
}
Exemple #2
0
func 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)
	})
}