use

open suspend override fun <T> use(callback: suspend (ISerialPortWrapper) -> T): T

Opens a connection to the serial port and closes it automatically after the callback has completed.

This is to mimic the way that Closeable classes work. But in this case, the class inheriting from this interface is a wrapper around the closeable resource, so we can't use Closeable directly.

Return

Result of the callback operation

Parameters

callback

Callback which is invoked after the serial port has been opened