0

I am using WEBUSB to read data from a weighing machine. The device is returning with status: stall when data is sent on the control transfer .

The Serial port from the weighing machine has been connected to RS232 USB to Serial port converter (BAFO BF-810 which has IC PL2303) and the usb is connected to the computer. Reading data from the same IC PL2303 was working before do not know suddenly why this issue has popped up.


  vendorRead(value, index) {
    return this.device.controlTransferIn({
      requestType: 'class',
      request: 0x01,
      recipient: 'device',
      value: value,
      index: index
    }, 1).then(buffer => buffer[0]);
  }

  vendorWrite(value, index) {
    return this.device.controlTransferOut({
      requestType: 'class',
      request: 0x01,
      recipient: 'device',
      value: value,
      index: index
    });
  }

  setBaudRate() {
    return this.device.controlTransferIn({
      requestType: 'class',
      request: 0x21,
      recipient: 'interface',
      value: 0,
      index: 0
    }, 7).then((data) => {
      console.log(data)
      const parameters = data.data.buffer;
      parameters[4] = 0;
      parameters[5] = 0;
      parameters[6] = 0;
      return this.device.controlTransferOut({
        requestType: 'class',
        request: 0x20,
        recipient: 'interface', 
        value: 0,
        index: 0
      }, parameters)
    }).then(() => this.vendorWrite(0x0, 0x0)) // no flow control
    .then(() => this.vendorWrite(8, 0)) // reset upstream data pipes
    .then(() => this.vendorWrite(9, 0));
  }

  initialize(device, range) {
    this.device = device;
    this.range = range;
    this.active = true;
    this.device.open()
    .then(() => this.device.selectConfiguration(1))
    .then(() => {
      return this.device.claimInterface(0)
    })
    .then(() => this.vendorRead(0x8484, 0))
    .then(() => this.vendorWrite(0x0404, 0))
    .then(() => this.vendorRead(0x8484, 0))
    .then(() => this.vendorRead(0x8383, 0))
    .then(() => this.vendorRead(0x8484, 0))
    .then(() => this.vendorWrite(0x0404, 1))
    .then(() => this.vendorRead(0x8484, 0))
    .then(() => this.vendorRead(0x8383, 0))
    .then(() => this.vendorWrite(0, 1))
    .then(() => this.vendorWrite(1, 0))
    .then(() => this.vendorWrite(2, 0x44))
    .then(() => this.setBaudRate())
    .then(() => this.readData())
    .catch(err => {
      console.log(err);
    });
    return this.readingChanged;
  }

Got stuck here for the past 1 week. Any help will be greatly appreciated . Thanks in Advance.

Haresh
  • 207
  • 1
  • 4
  • 11
  • It seems that this is related. [Connecting to Serial USB device via WebUSB](https://stackoverflow.com/q/54430134/9014308), [WebUSB with FT230x serial chip](https://stackoverflow.com/q/46132921/9014308) – kunif Jun 01 '19 at 14:35
  • There is some information missing from this question. Please post the entire code (it appears the readData() function is missing) and also try to figure out which control transfer is stalling. A stall is the way the device indicates that the parameters were invalid. – Reilly Grant Jun 02 '19 at 17:21

0 Answers0