open method

int open()

call hid_open to open the specified device.

return 0 on success, -1 on failure

Implementation

int open() {
  Pointer buffer = nullptr.cast();
  var _serial = this.serial;

  using((Arena arena) {
    if (_serial != null) {
      var cpcount = _serial.runes.length;
      buffer = allocateWString(cpcount, data: _serial, allocator: arena);
    }

    this._device = _openDevice(this.idVendor, this.idProduct, buffer);
  });

  return this._device == nullptr ? -1 : 0;
}