readBytes method
Read unsigned bytes - mraa_uart_read
Read bytes from the device into a buffer Returns the number of bytes read, or Mraa.generalError.
Implementation
int readBytes(MraaUartContext dev, MraaUartBuffer buffer, int length) {
if (length <= 0) {
return Mraa.generalError;
}
final ptrBuffer = ffi.calloc.allocate<Char>(length);
final ret = _impl.mraa_uart_read(dev, ptrBuffer, length);
if (ret == Mraa.generalError) {
return ret;
}
try {
buffer.byteData = ptrBuffer.cast<Uint8>().asTypedList(ret);
} on Exception {
return Mraa.generalError;
}
return ret;
}