Class SerialAdapterFactory

java.lang.Object
com.tccc.kos.core.service.udev.serial.SerialAdapterFactory

public abstract class SerialAdapterFactory extends Object
Factory that is notified of serial devices and can return an adapter for a given device to claim the device and have the adapter automatically started.
Since:
1.0
Version:
2023-09-19
  • Constructor Details

    • SerialAdapterFactory

      public SerialAdapterFactory()
  • Method Details

    • matchDevice

      public abstract Adapter matchDevice(SerialDevice device)
      Called with a SerialDevice to see if it matches this factory. If so, return a SerialAdapter instance for the device. This will claim the device and start the adapter.

      This may be called multiple times for the same device if no factory claims it. The callback interval and max retry time are both config options in SerialService .

      In some cases, hardware needs to be probed to identify what it actually is (when the same usb serial hardware is used on multiple boards). The SerialDevice supports opening the serial device for the purpose of probing the hardware. This should only be used for probing and care should be taken to close the device if opened.

      Some devices can take time to boot once connected. Use device.getRunTimeMs() to determine how long the device has been connected. For devices that need boot time allowances, this method can return null until the required boot time has passed and then probe the hardware.

      Returns:
      SerialAdapter for the device or null