readReport method

Future<Uint8List> readReport(
  1. int? timeoutMillis
)

Read an Input report from a HID device.

Input reports are returned to the host through the INTERRUPT IN endpoint. The first byte will contain the Report number if the device uses numbered reports.

This function returns the actual bytes read or throws an error. An optional timeout_millis can be specified. If timeout happens, the returned buffer will have length 0.

Implementation

Future<Uint8List> readReport(int? timeoutMillis) async {
  var responsePort = ReceivePort();
  commandPort.send(USBIsolateCommand(responsePort.sendPort,
      USBDeviceCommand.readReport, null, timeoutMillis));
  var resp = await responsePort.first as USBIsolateResponse;
  if (resp.status != USBDeviceStatus.ok) {
    throw Exception("Error reading device: ${resp.errorMsg}");
  }
  return resp.buffer as Uint8List;
}