예제 #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 (d Device) Action() string {
	return C.GoString(C.udev_device_get_action(d.ptr))
}
예제 #3
0
파일: device.go 프로젝트: jochenvg/go-udev
// Action returns the action for the event.
// This is only valid if the device was received through a monitor.
// Devices read from sys do not have an action string.
// Usual actions are: add, remove, change, online, offline.
func (d *Device) Action() string {
	d.lock()
	defer d.unlock()
	return C.GoString(C.udev_device_get_action(d.ptr))
}