hathach / tinyusb

An open source cross-platform USB stack for embedded system

Home Page:https://www.tinyusb.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WebUSB example crash when a max size packet and a ZLP received

HiFiPhile opened this issue · comments

Operating System

Windows 10

Board

STM32F723E-DISCO

Firmware

examples\device\webusb_serial

What happened ?

Receiver stopped working, seems ZLP caused error in console:

application.js:42 Uncaught (in promise) RangeError: Offset is outside the bounds of the DataView
    at DataView.prototype.getInt8 (<anonymous>)
    at port.onReceive (application.js:42:20)
    at serial.js:35:14
                        port.onReceive = data => {
                                  let textDecoder = new TextDecoder();
                                  console.log(textDecoder.decode(data));
 #Crashed here#  ->      if (data.getInt8() === 13) {
                                    currentReceiverLine = null;
                                  } else {
                                    appendLines('receiver_lines', textDecoder.decode(data));
                                  }
                                };

Never done JS, not sure how to fix :)

How to reproduce ?

Run #911 and send ZLP

Debug Log as txt file (LOG/CFG_TUSB_DEBUG=2)

  CDC xfer callback
  Queue EP 02 with 64 bytes ...
  Queue EP 83 with 64 bytes ...
  Queue EP 82 with 64 bytes ...
USBD Xfer Complete on EP 83 with 64 bytes
  VENDOR xfer callback
  Queue EP 83 with 0 bytes ...
USBD Xfer Complete on EP 82 with 64 bytes
  CDC xfer callback
  Queue EP 82 with 0 bytes ...
USBD Xfer Complete on EP 83 with 0 bytes
  VENDOR xfer callback
USBD Xfer Complete on EP 82 with 0 bytes
  CDC xfer callback
USBD Xfer Complete on EP 02 with 64 bytes
  CDC xfer callback
  Queue EP 02 with 64 bytes ...
  Queue EP 83 with 64 bytes ...
  Queue EP 82 with 64 bytes ...
USBD Xfer Complete on EP 82 with 64 bytes
  CDC xfer callback
  Queue EP 82 with 0 bytes ...
USBD Xfer Complete on EP 82 with 0 bytes