A_GetUSBDeviceInfo method

List A_GetUSBDeviceInfo(
  1. int nPort
)

Implementation

List A_GetUSBDeviceInfo(int nPort) {
  ffi.Pointer<ffi.Char> pDeviceName = malloc.allocate(128);
  ffi.Pointer<ffi.Int> pDeviceNameLen = malloc();
  pDeviceNameLen.value = 128;
  ffi.Pointer<ffi.Char> pDevicePath = malloc.allocate(128);
  ffi.Pointer<ffi.Int> pDevicePathLen = malloc();
  pDevicePathLen.value = 128;

  final res = _A_GetUSBDeviceInfo(
    nPort,
    pDeviceName.toString().toNativeUtf8().cast<ffi.Int8>(),
    pDeviceNameLen.toString().toNativeUtf8().cast<ffi.Int32>(),
    pDevicePath.toString().toNativeUtf8().cast<ffi.Int8>(),
    pDevicePathLen.toString().toNativeUtf8().cast<ffi.Int32>(),
  );
  final result = [
    res,
    pDeviceName.cast<ffi.Char>().toString(),
    pDevicePath.cast<ffi.Char>().toString()
  ];
  malloc.free(pDeviceName);
  malloc.free(pDevicePath);
  malloc.free(pDeviceNameLen);
  malloc.free(pDevicePathLen);

  return result;
}