Class UdevDevice

java.lang.Object
com.kosdev.kos.core.service.udev.UdevDevice
All Implemented Interfaces:
AttributeAware

public class UdevDevice extends Object implements 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 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

      public String getProperty(String name)
      Return the named udev device property value.
      Parameters:
      name - the property name
      Returns:
      the named property or null
      Since:
      9
    • getUsbId

      public UsbId getUsbId()
      Return the UsbId of the device. If this device is not a valid usb device, the vendorId and productId will be -1.
      Since:
      9
    • getUsbPath

      public String 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

      public void setAttribute(Object key, Object value)
      Description copied from interface: AttributeAware
      Sets the attribute for the given key.
      Specified by:
      setAttribute in interface AttributeAware
      Parameters:
      key - the attribute key
      value - the attribute value
    • getAttribute

      public Object getAttribute(Object key)
      Description copied from interface: AttributeAware
      Given a key, returns its attribute.
      Specified by:
      getAttribute in interface AttributeAware
      Parameters:
      key - the attribute key
      Returns:
      the value of the attribute, or null if it doesn't exist
    • removeAttribute

      public Object removeAttribute(Object key)
      Description copied from interface: AttributeAware
      Given a key, removes the attribute.
      Specified by:
      removeAttribute in interface AttributeAware
      Parameters:
      key - the attribute key
      Returns:
      the value of the attribute being removed, or null if it didn't exist
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getId

      public String getId()
    • getNodePath

      public String getNodePath()
    • getSyspath

      public String getSyspath()
    • getSubsystem

      public String getSubsystem()
    • getDevname

      public String getDevname()
    • getSysname

      public String getSysname()
    • getProperties

      public Map<String,String> getProperties()
    • getCurrentTags

      public List<String> getCurrentTags()
    • getDevLinks

      public List<String> getDevLinks()
    • getOwner

      public UdevDeviceOwner getOwner()
    • getNode

      public UdevNode getNode()
    • getAttrs

      public Map<Object,Object> getAttrs()
    • setId

      public void setId(String id)
    • setNodePath

      public void setNodePath(String nodePath)
    • setSyspath

      public void setSyspath(String syspath)
    • setSubsystem

      public void setSubsystem(String subsystem)
    • setDevname

      public void setDevname(String devname)
    • setSysname

      public void setSysname(String sysname)
    • setProperties

      public void setProperties(Map<String,String> properties)
    • setCurrentTags

      public void setCurrentTags(List<String> currentTags)
    • setDevLinks

      public void setDevLinks(List<String> devLinks)
    • setOwner

      public void setOwner(UdevDeviceOwner owner)
    • setNode

      public void setNode(UdevNode node)
    • setUsbId

      public void setUsbId(UsbId usbId)
    • setAttrs

      public void setAttrs(Map<Object,Object> attrs)