qzind / tray

Browser plugin for sending documents and raw commands to a printer or attached device.
https://qz.io
Other
831 stars 272 forks source link

Windows HID no error on device failure #293

Open klabarge opened 6 years ago

klabarge commented 6 years ago

Quoting @kunnis

I then unplugged the scale from the computer (to simulate a cable/connector failure). No error events were raised to indicate that things had gone wrong.

On Windows, there is no error when there is a hardware failure while streaming is occurring (USB cable disconnect, power, etc.).

On macOS, there will be a "Failed to read from device" error when there is a hardware failure while streaming. Below is what we would expect to see in the logs.

[ERROR] 2018-03-27 22:32:36,071 @ qz.utils.UsbUtilities:?
    USB stream error
qz.communication.DeviceException: Failed to read from device
    at qz.communication.H4J_HidIO.readData(Unknown Source)
    at qz.utils.UsbUtilities$1.run(Unknown Source)

Steps to reproduce:

  1. Load sample.html and go to the HID tab
  2. Claim your HID device and click "Open Stream"
  3. Unplug USB cable
kunnis commented 6 years ago

from @tresf

You'll get the reports you want if you switch back to the hid4java library per #292 (comment). I understand the stuck values can be a problem and the current 2.0 will fix that. I'm not sure if we can fix #293 though, we'll have to dig deeper.

Even a partial fix so that we know when the connected device is unplugged would be useful, even if it's not a full fix for the problem. Knowing the device dropped out will at least let me display an error to the user.

tresf commented 6 years ago

@kunnis the "partial fix" you explain would be a regression in stability, so it comes as a trade-off.

We didn't author either HID library, so we're at the mercy of the upstream library maintainers. I'm sure purejavahidapi would accept a pull request for these features, which may be the direction we end up going.