Class SerialService

java.lang.Object
com.kosdev.kos.core.service.udev.serial.SerialService

public final class SerialService extends Object
Service that manages serial devices.
Since:
1
Version:
1
  • Method Details

    • restartMatching

      public void restartMatching()
      Restart the matching process for all pending devices.
      Since:
      1
    • claimDevice

      public void claimDevice(SerialDevice device)
      Ask SerialService to claim ownership of the device.
      Since:
      1
    • addDevicePrefix

      public void addDevicePrefix(String devicePrefix, Object reference)
      Add a new serial prefix to the udev device matcher. This is used to match serial device names that aren't included in the default list ( ttyUSB , ttyACM ). For example, if your device contains onboard serial, it may appear as /dev/ttyS0 . To have this device appear via udev support, add the prefix ttyS0 .

      When this prefix is installed, it will immediately generate a callback of any devices that match the prefix. The caller should account for this.

      A prefix is added with a reference object. This object effectively represents a use count on the prefix. If two application add the same prefix and one later removes it, this ensures the prefix will remain in place due to the other application. Any object can be used as the reference, but the same object must be used in removeDevicePrefix() .

      Parameters:
      devicePrefix - the prefix of the serial device syspath (no /dev/ )
      reference - the reference object to hold the use count
      Since:
      10
    • removeDevicePrefix

      public void removeDevicePrefix(String devicePrefix, Object reference)
      Remove a serial prefix from the udev device matcher. When the last reference to the matcher is removed, it will actually be removed from the monitor. When this happens, any devices that matched on the removed matcher will generate device remove events. The caller should account for this.
      Parameters:
      devicePrefix - the prefix to remove from the device matcher list
      reference - the corresponding reference object that was specified in addDevicePrefix()
      Since:
      10