Thursday, 1 October 2020

Web usb transfer data from device to browser not working

enter image description here

Above is my device configuration.I am trying to get data from it ,I am using below code to to get the data

document.getElementById("request").onclick = function() {

  navigator.usb.requestDevice({
      filters: [{
        vendorId: 1659
      }]
    })
    .then((requestedDevice) => {
      device = requestedDevice;
    }).then(() => {
      console.log(device);
      console.log(JSON.stringify(device));
      return device.open();
    }).then(() => device.selectConfiguration(1)) // Select configuration #1 for the device.
    .then(() => {

      return device.reset();
    }).then(() => device.claimInterface(0))
    .then(() => {

      return device.transferIn(3, 64)
    })
    .then((data) => {
      debugger;
      console.log(data)

    }).catch(err => {
      console.log(err);
    });

}

I am selecting the endPointnumber ,and the interface correctly but it doesn't seems to work ,am I missing something here ? .Please help .I am not getting any error ,device seems to connected but the data transfer is not happening from machine to browser.

I saw this question it has same exact scenario as mine WEBUSB getting serial data PL2303

But in my case I am not getting any data even .

I tried this driver https://github.com/tidepool-org/pl2303 in node js and it worked ,but I want to do it web usb api .



from Web usb transfer data from device to browser not working

No comments:

Post a Comment