read

abstract suspend fun read(numBytes: Int): ByteArray

Reads the specified number of bytes from the port.

Parameters

numBytes

Number of bytes to read from the port

Throws

CancellationException

If operation takes longer than the time specified by defaultReadTimeout


abstract suspend fun read(numBytes: Int, timeout: Long): ByteArray

Reads the specified number of bytes from the port.

Parameters

numBytes

Number of bytes to read from the port

timeout

Time to wait in milliseconds before aborting the request prematurely

Throws

CancellationException

If operation takes longer than the time specified by timeout


abstract fun read(numBytes: Int, scope: CoroutineScope): Deferred<ByteArray>

Reads the specified number of bytes from the port in an asynchronous manner.

Return

Deferred result containing the bytes which were read from the serial port. May throw a cancellation exception

Parameters

numBytes

Number of bytes to read from the port

scope

Coroutine scope within which to run this operation


abstract fun read(numBytes: Int, timeout: Long, scope: CoroutineScope): Deferred<ByteArray>

Reads the specified number of bytes from the port in an asynchronous manner.

Return

Deferred result containing the bytes which were read from the serial port. May throw a cancellation exception

Parameters

numBytes

Number of bytes to read from the port

timeout

Time to wait in milliseconds before aborting the request prematurely

scope

Coroutine scope within which to run this operation