openForFfi method

  1. @override
Future<UsbOpenResult> openForFfi(
  1. String path
)
override

Implementation

@override
Future<UsbOpenResult> openForFfi(String path) async {
  if (openDelay != Duration.zero) await Future<void>.delayed(openDelay);
  if (openError != null) throw openError!;
  final device = devices.firstWhere(
    (d) => d.path == path,
    orElse: () => throw StateError('FakeUsbPlatform: no device at $path'),
  );
  final id = _nextHandleId++;
  _handles[id] = _FakeHandle(device);
  return UsbOpenResult(
    platformHandle: id,
    vendorId: device.vendorId,
    productId: device.productId,
    serialNumber: device.serialNumber,
    claimedInterfaceNumber: device.interfaceNumber ?? 0,
    bulkInEndpoint: device.bulkInEndpoint ?? 0x81,
    bulkOutEndpoint: device.bulkOutEndpoint ?? 0x01,
    wMaxPacketSizeOut: device.wMaxPacketSizeOut ?? 64,
  );
}