# Windows: Errors 31 or 7 after some time of successful operation

**URL:** <https://forums.blinkstick.com/t/windows-errors-31-or-7-after-some-time-of-successful-operation/1306>\
**Category:** Support\
**Created:** [January 20, 2020, 1:04pm UTC](https://forums.blinkstick.com/t/windows-errors-31-or-7-after-some-time-of-successful-operation/1306 "2020-01-20T13:04:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![stijn.sanders](https://forums.blinkstick.com/letter_avatar_proxy/v4/letter/s/8e8cbc/32.png) [@stijn.sanders](https://forums.blinkstick.com/u/stijn.sanders)\
**Post date:** [January 20, 2020, 1:04pm UTC](https://forums.blinkstick.com/t/windows-errors-31-or-7-after-some-time-of-successful-operation/1306/1 "2020-01-20T13:04:27Z")

</div>

We’re using two BlinkStick Flex’s on each computer in a packaging environment to indicate which items to pick per customer package. We’re using SetupDiEnumDeviceInterfaces and HidD\_SetFeature ourselves to connect to the devices and this works great. Sadly now and again this fails, and GetLastError returns 31 or 7, also after repeated retries. Disconnecting the USB devices (or the USB hub they’re on) helps, but we can’t depend on this method for daily operation.

We’ve tried using blinkstick.exe as a proof-of-concept, but this also isn’t usable in normal operation as it performs much too slowly. Also when the BlinkStick Flex’s are failing, blinkstick.exe responds with “Device opened successfully.” but with nothing where the serial number is supposed to be.

Would you have idea’s of things we could try? Of would you like to have a demo application that mimics typical operation and the commands we send to the devices to have a try yourself?

---

<div class="post-metadata">

**Author:** ![stijn.sanders](https://forums.blinkstick.com/letter_avatar_proxy/v4/letter/s/8e8cbc/32.png) [@stijn.sanders](https://forums.blinkstick.com/u/stijn.sanders)\
**Post date:** [January 21, 2020, 10:52am UTC](https://forums.blinkstick.com/t/windows-errors-31-or-7-after-some-time-of-successful-operation/1306/2 "2020-01-21T10:52:13Z")

</div>

We’ve also been investigating for a way to reproduce this, but haven’t found anything yet. There’s a very slim chance that the barcode scanner, connected over USB also, may be involved, but it’s not straightforward to prove this.

---

<div class="post-metadata">

**Author:** ![stijn.sanders](https://forums.blinkstick.com/letter_avatar_proxy/v4/letter/s/8e8cbc/32.png) [@stijn.sanders](https://forums.blinkstick.com/u/stijn.sanders)\
**Post date:** [January 22, 2020, 9:32am UTC](https://forums.blinkstick.com/t/windows-errors-31-or-7-after-some-time-of-successful-operation/1306/3 "2020-01-22T09:32:28Z")

</div>

I tried a few things on a system where it failed again today, and ‘uninstalled’ from the device manager, and then ‘scan for hardware changes’. The item reappears, but if I remove “HID-compliant vendor-defined device” blinkstick.exe still answers “Device opened successfully.” without serial number, if I remove the parent “USB Input Device” (devices are shown ‘by connection’ here:)  
 ![image](https://forums.blinkstick.com/uploads/default/original/1X/8f3bddb7424e69feceb04263385bdd0b4eab4bac.png)  
blinkstick.exe does get the serrial number, but after a few minutes the BlinkStick Flex starts to fail again, throwing 31 errors “A device attached to the system is not functioning”

---

<div class="post-metadata">

**Author:** ![stijn.sanders](https://forums.blinkstick.com/letter_avatar_proxy/v4/letter/s/8e8cbc/32.png) [@stijn.sanders](https://forums.blinkstick.com/u/stijn.sanders)\
**Post date:** [January 23, 2020, 1:39pm UTC](https://forums.blinkstick.com/t/windows-errors-31-or-7-after-some-time-of-successful-operation/1306/4 "2020-01-23T13:39:08Z")

</div>

I’ve been able to avoid _some_ of the errors 31 by _spacing_ the HidD\_SetFeature calls in time by keeping at least 50 milliseconds between them, but I’m not sure if this will prevent the system of going into this error-condition where _all_ calls get error 31.

---

<div class="post-metadata">

**Author:** ![stijn.sanders](https://forums.blinkstick.com/letter_avatar_proxy/v4/letter/s/8e8cbc/32.png) [@stijn.sanders](https://forums.blinkstick.com/u/stijn.sanders)\
**Post date:** [February 7, 2020, 10:20am UTC](https://forums.blinkstick.com/t/windows-errors-31-or-7-after-some-time-of-successful-operation/1306/5 "2020-02-07T10:20:04Z")

</div>

It doesn’t. We’ve also have gotten a few times that the mouse cursor started to move, without mouse input. Could this be a problem with Windows’ hid.dll?
