Package com.kosdev.kos.core.service.udev
Class UdevDevice
java.lang.Object
com.kosdev.kos.core.service.udev.UdevDevice
- All Implemented Interfaces:
AttributeAware
Device from udev adapter. This represents a device discovered by udev
during an insertion / discovery event. These are typically devices that
can be inserted / removed on the fly and need to be processed accordingly.
A
UdevDevice is fairly low level and is typically abstracted by
SerialService and StorageService which make them easier
to work with. However, in the event of a device that is neither storage
nor serial, direct access to the UdevDevice allows a way to
handle custom processing of the device.
A majority of the properties in this object come directly from udev. Please see udev documentation to understand their meaning.
A UdevDevice is claimed by an owner, which has exclusive
access to the device and receives lifecycle events. The owner
should not be modified directly as it is typically assigned
during device discovery.
- Since:
- 1
- Version:
- 9
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetAttribute(Object key) Given a key, returns its attribute.getAttrs()getId()getNode()getOwner()getProperty(String name) Return the named udev device property value.longReturn how long the device has been running in ms.getUsbId()Return theUsbIdof the device.Return the usb path which is unique to a given usb port.removeAttribute(Object key) Given a key, removes the attribute.voidsetAttribute(Object key, Object value) Sets the attribute for the given key.voidvoidsetCurrentTags(List<String> currentTags) voidsetDevLinks(List<String> devLinks) voidsetDevname(String devname) voidvoidvoidsetNodePath(String nodePath) voidsetOwner(UdevDeviceOwner owner) voidsetProperties(Map<String, String> properties) voidsetSubsystem(String subsystem) voidsetSysname(String sysname) voidsetSyspath(String syspath) voidtoString()
-
Constructor Details
-
UdevDevice
public UdevDevice()
-
-
Method Details
-
getRunTimeMs
public long getRunTimeMs()Return how long the device has been running in ms. This is how long since the device was first discovered.- Since:
- 1
-
getProperty
Return the named udev device property value.- Parameters:
name- the property name- Returns:
- the named property or null
- Since:
- 9
-
getUsbId
Return theUsbIdof the device. If this device is not a valid usb device, thevendorIdandproductIdwill be -1.- Since:
- 9
-
getUsbPath
Return the usb path which is unique to a given usb port. This can be used to bind hardware to the physical port it is attached to.- Since:
- 9
-
setAttribute
Description copied from interface:AttributeAwareSets the attribute for the given key.- Specified by:
setAttributein interfaceAttributeAware- Parameters:
key- the attribute keyvalue- the attribute value
-
getAttribute
Description copied from interface:AttributeAwareGiven a key, returns its attribute.- Specified by:
getAttributein interfaceAttributeAware- Parameters:
key- the attribute key- Returns:
- the value of the attribute, or
nullif it doesn't exist
-
removeAttribute
Description copied from interface:AttributeAwareGiven a key, removes the attribute.- Specified by:
removeAttributein interfaceAttributeAware- Parameters:
key- the attribute key- Returns:
- the value of the attribute being removed, or
nullif it didn't exist
-
toString
-
getId
-
getNodePath
-
getSyspath
-
getSubsystem
-
getDevname
-
getSysname
-
getProperties
-
getCurrentTags
-
getDevLinks
-
getOwner
-
getNode
-
getAttrs
-
setId
-
setNodePath
-
setSyspath
-
setSubsystem
-
setDevname
-
setSysname
-
setProperties
-
setCurrentTags
-
setDevLinks
-
setOwner
-
setNode
-
setUsbId
-
setAttrs
-