示例#1
0
文件: monitor.go 项目: qmsk/onewire
func (self *Monitor) Recv() (MonitorDevice, error) {
	for {
		udev_device := C.udev_monitor_receive_device(self.udev_monitor)

		if udev_device == nil {
			continue
		}

		// device
		var device MonitorDevice

		if err := device.fromUdev(udev_device); err != nil {
			return device, err
		}

		cAction := C.udev_device_get_action(udev_device)
		if cAction != nil {
			device.Action = C.GoString(cAction)
		}

		return device, nil
	}
}
示例#2
0
文件: udev.go 项目: jessta/udev
func (m Monitor) ReceiveDevice() Device {
	return Device{C.udev_monitor_receive_device(m.ptr)}
}
示例#3
0
// receiveDevice is a helper function receiving a device while the Mutex is locked
func (m *Monitor) receiveDevice() (d *Device) {
	m.lock()
	defer m.unlock()
	return m.u.newDevice(C.udev_monitor_receive_device(m.ptr))
}