How to use the usb.LIBUSB_ENDPOINT_OUT function in usb

To help you get started, we’ve selected a few usb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / usb / usb-tests.ts View on Github external
const CHECK_LIBUSB_REQUEST_GET_INTERFACE: number = usb.LIBUSB_REQUEST_GET_INTERFACE;
const CHECK_LIBUSB_REQUEST_SET_INTERFACE: number = usb.LIBUSB_REQUEST_SET_INTERFACE;
const CHECK_LIBUSB_REQUEST_SYNCH_FRAME: number = usb.LIBUSB_REQUEST_SYNCH_FRAME;
// libusb_descriptor_type
const CHECK_LIBUSB_DT_DEVICE: number = usb.LIBUSB_DT_DEVICE;
const CHECK_LIBUSB_DT_CONFIG: number = usb.LIBUSB_DT_CONFIG;
const CHECK_LIBUSB_DT_STRING: number = usb.LIBUSB_DT_STRING;
const CHECK_LIBUSB_DT_INTERFACE: number = usb.LIBUSB_DT_INTERFACE;
const CHECK_LIBUSB_DT_ENDPOINT: number = usb.LIBUSB_DT_ENDPOINT;
const CHECK_LIBUSB_DT_HID: number = usb.LIBUSB_DT_HID;
const CHECK_LIBUSB_DT_REPORT: number = usb.LIBUSB_DT_REPORT;
const CHECK_LIBUSB_DT_PHYSICAL: number = usb.LIBUSB_DT_PHYSICAL;
const CHECK_LIBUSB_DT_HUB: number = usb.LIBUSB_DT_HUB;
// libusb_endpoint_direction
const CHECK_LIBUSB_ENDPOINT_IN: number = usb.LIBUSB_ENDPOINT_IN;
const CHECK_LIBUSB_ENDPOINT_OUT: number = usb.LIBUSB_ENDPOINT_OUT;
// libusb_transfer_type
const CHECK_LIBUSB_TRANSFER_TYPE_CONTROL: number = usb.LIBUSB_TRANSFER_TYPE_CONTROL;
const CHECK_LIBUSB_TRANSFER_TYPE_ISOCHRONOUS: number = usb.LIBUSB_TRANSFER_TYPE_ISOCHRONOUS;
const CHECK_LIBUSB_TRANSFER_TYPE_BULK: number = usb.LIBUSB_TRANSFER_TYPE_BULK;
const CHECK_LIBUSB_TRANSFER_TYPE_INTERRUPT: number = usb.LIBUSB_TRANSFER_TYPE_INTERRUPT;
// libusb_iso_sync_type
const CHECK_LIBUSB_ISO_SYNC_TYPE_NONE: number = usb.LIBUSB_ISO_SYNC_TYPE_NONE;
const CHECK_LIBUSB_ISO_SYNC_TYPE_ASYNC: number = usb.LIBUSB_ISO_SYNC_TYPE_ASYNC;
const CHECK_LIBUSB_ISO_SYNC_TYPE_ADAPTIVE: number = usb.LIBUSB_ISO_SYNC_TYPE_ADAPTIVE;
const CHECK_LIBUSB_ISO_SYNC_TYPE_SYNC: number = usb.LIBUSB_ISO_SYNC_TYPE_SYNC;
// libusb_iso_usage_type
const CHECK_LIBUSB_ISO_USAGE_TYPE_DATA: number = usb.LIBUSB_ISO_USAGE_TYPE_DATA;
const CHECK_LIBUSB_ISO_USAGE_TYPE_FEEDBACK: number = usb.LIBUSB_ISO_USAGE_TYPE_FEEDBACK;
const CHECK_LIBUSB_ISO_USAGE_TYPE_IMPLICIT: number = usb.LIBUSB_ISO_USAGE_TYPE_IMPLICIT;
// libusb_transfer_status
const CHECK_LIBUSB_TRANSFER_COMPLETED: number = usb.LIBUSB_TRANSFER_COMPLETED;
github sandeepmistry / rtlsdrjs / lib / usb.js View on Github external
return new Promise((resolve, reject) => {
    let requestType = 0;
    let lengthOrData = ti.length ? ti.length : Buffer.from(ti.data);

    if (ti.requestType === 'vendor') {
      requestType |= usb.LIBUSB_REQUEST_TYPE_VENDOR;
    }

    if (ti.recipient === 'device') {
      requestType |= usb.LIBUSB_RECIPIENT_DEVICE;
    }

    if (ti.direction === 'out') {
      requestType |= usb.LIBUSB_ENDPOINT_OUT;
    } else if (ti.direction === 'in') {
      requestType |= usb.LIBUSB_ENDPOINT_IN;
    }

    this._device.controlTransfer(requestType, ti.request, ti.value, ti.index, lengthOrData, (err, data) => {
      if (err) {
        return reject(err);
      }

      if (data) {
        return resolve(Uint8Array.from(data).buffer);
      }

      resolve();
    });
  });