示例#1
0
文件: device.go 项目: sstallion/go
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
}
示例#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)
	})
}