コード例 #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))
}