writeRead(_:writeCount:into:readCount:address:)
Writes an array of UInt8 to the slave device with the given address and then read bytes from it.
@discardableResult func writeRead(_ data: [UInt8], writeCount: Int? = nil, into buffer: inout [UInt8], readCount: Int? = nil, address: UInt8) -> Result<(), Errno>
Parameters
- data
An array of UInt8 to be sent to the slave device.
- writeCount
The number of elements in
data
to be sent. Make sure it doesn’t exceed the length of thedata
. If it’s nil, all will be sent.- buffer
A UInt8 array to store the received bytes.
- readCount
The number of bytes to read. Make sure it doesn’t exceed the length of the
buffer
. If it’s nil, it equals the length of thebuffer
.- address
The address of the slave device to communicate with.
Returns
Whether the communication succeeds. If not, it returns the specific error.