Beispiel #1
0
func main() {
	flag.Parse()

	if hidrawList, err := hidraw.List(deviceConfig); err != nil {
		log.Fatalf("hidraw.List %v: %v\n", deviceConfig, err)
	} else {
		log.Printf("hidraw.List...\n")
		for _, deviceInfo := range hidrawList {
			if hidrawDevice, err := hidraw.Open(deviceInfo); err != nil {
				log.Printf("hidraw.Open: %v\n", deviceInfo, err)
			} else if avrtempDevice, err := avrtemp.Open(hidrawDevice); err != nil {
				log.Printf("avrtemp.Open: %v\n", deviceInfo, err)
			} else {
				log.Printf("%#v\n", deviceInfo, avrtempDevice)

				log.Printf("avrtempDevice %v: Read...\n", avrtempDevice)
				for {
					if report, err := avrtempDevice.Read(); err != nil {
						log.Fatalf("avrtemp.Device %v: Read: %v\n", avrtempDevice, err)
					} else {
						log.Printf("%v\n", report)
					}
				}
			}
		}
	}
}
Beispiel #2
0
func (s *Server) AddHidrawDevice(deviceInfo hidraw.DeviceInfo) {
	device := Device{
		hidraw: deviceInfo,
	}

	if hidrawDevice, err := hidraw.Open(deviceInfo); err != nil {
		log.Printf("AddHidrawDevice %#v: hidraw.Open: %v\n", deviceInfo, err)
	} else if avrtempDevice, err := avrtemp.Open(hidrawDevice); err != nil {
		log.Printf("AddHidrawDevice %#v: avrtemp.Open: %v\n", deviceInfo, err)
	} else {
		log.Printf("AddHidrawDevice %#v: %#v\n", deviceInfo, avrtempDevice)

		device.avrtemp = avrtempDevice
	}

	s.deviceChan <- device
}