readBytes method
Reads len
bytes from the I2C device with the address
.
Implementation
List<int> readBytes(int address, int len) {
var data = <I2Cmsg>[];
data.add(I2Cmsg(address, [I2CmsgFlags.i2c_m_rd], len));
var result = transfer(data);
var msg2 = result._messages[0];
try {
var read = msg2.len;
var ptr = msg2.buf;
var list = <int>[];
for (var i = 0; i < read; ++i) {
list.add(ptr[i]);
}
return list;
} finally {
result.dispose();
}
}