Class SerialService
java.lang.Object
com.kosdev.kos.core.service.udev.serial.SerialService
Service that manages serial devices.
- Since:
- 1
- Version:
- 1
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddDevicePrefix(String devicePrefix, Object reference) Add a new serial prefix to the udev device matcher.voidclaimDevice(SerialDevice device) AskSerialServiceto claim ownership of the device.voidremoveDevicePrefix(String devicePrefix, Object reference) Remove a serial prefix from the udev device matcher.voidRestart the matching process for all pending devices.
-
Method Details
-
restartMatching
public void restartMatching()Restart the matching process for all pending devices.- Since:
- 1
-
claimDevice
AskSerialServiceto claim ownership of the device.- Since:
- 1
-
addDevicePrefix
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 prefixttyS0.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
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 listreference- the corresponding reference object that was specified inaddDevicePrefix()- Since:
- 10
-