WICG / webhid

Web API for accessing Human Interface Devices (HID)
Other
140 stars 35 forks source link

Failed to write the report. #5

Closed joshberg closed 4 years ago

joshberg commented 5 years ago

I am working with a Mettler Toledo PS60 scale. I am able to open the device, but am having trouble consistently sending reports to the device. If I restart the scale, I can write the report and I get data back that I can use. I continuously get data sent back for roughly 10 to 60 seconds before I stop getting the reports. When I attempt to send the report to the device again, it says "Failed to write the report" and continues to do so until I reset the device.

I am assuming this is a device issue and I have sent them a request. Has anyone else experienced intermittent connectivity like my example using this API? I do not have another device with which to test at the moment.

If there is a better place to discuss these issues, please let me know. I have not found a lot of documentation on this yet.

eoghanoh commented 4 years ago

Hi Josh,

I just started playing around with this API. Granted, it's a good few months since your post and perhaps things have changed and perhaps you even have this working. But as you had no replies I thought I would offer something that might help. I had a similar issue just yesterday. Fortunately I realised straight away what it was so I didn't lose too much time on it. Garbage collection was throwing away the device as there was no path to it through references from the root. This was early on because my code was very basic at that stage and I probably would have coded my way out of it eventually as my app progressed. But I wanted to fix it immediately. My fix was to save a reference to the device at the root of the document and then reference that object from a function. It means the garbage collector would not throw away the object and the corresponding handlers etc. Hope you got it working whether it was this or something else.

Thanks, Eoghan.

joshberg commented 4 years ago

Thanks for the excellent tip. It may be that was the issue... More than likely though it was the device. From my research if I remember correctly, there is a lot of instability from the USB.