devicePathFromIndex method
Device path from index Given a UART index get the associated device path. Can return null if the index does not map to a UART device
Implementation
String devicePathFromIndex(int index) {
if (index < 0) {
return '';
}
final ptrDevicePath = ffi.calloc.allocate<Pointer<Char>>(1024);
final ret = _impl.mraa_uart_settings(index, ptrDevicePath, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr);
// If not success return null
if (MraaReturnCode.returnCode(ret) != MraaReturnCode.success) {
return '';
}
// Set the output parameters
try {
return ptrDevicePath.value.cast<ffi.Utf8>().toDartString();
} on FormatException {
return '';
}
}