The following forum(s) have migrated to Microsoft Q&A (Preview): Developing Universal Windows apps!
Visit Microsoft Q&A (Preview) to post new questions.

Learn More

 locked
[UWP]Getting "A device attached to the system is not functioning" when trying to enable barcode scanner RRS feed

  • Question

  • Hello all (including @Terry Warwick). 

    I have noticed something that seems to be a bug that is a major issue because it requires a restart of the device to get it working again. I am using a Honeywell CT50 device, running Windows 10 Mobile. While I do have a UWP that runs on the device, I have noticed that the issue is not just caused by my app (ie: after restart, I never even launch my app). Honeywell also supplies a scanner demo app (ScanDemoW10). The issue seems to be with the interaction between a claimed barcode scanner and the camera. For example, if you have a claimed barcode scanner (and the scanner is working) but then you launch the camera/app and switch back to the ScanDemoW10 app (or my app or any app that uses the barcode scanner for that matter) you will see that it causes an exception with ClaimedScanner.EnableAsync(); and the error message is:

    A device attached to the system is not functioning. (Exception from HRESULT: 0x8007001F)

    If I am lucky, once I start getting this, I can close ALL apps and try to start the scanner again and it will recover. But in most cases, once I start getting this, I have to reboot the device to be able to enable the scanner again. 

    When it is in the "failure mode", I can still detect the scanner and claim it, it is just when I try to enable it. 

    The error comes from source "System.Private.CoreLib"

    I need to know how to either prevent this or recover from it when I happens without having to reboot the device everytime. Our application requires barcode scanning capability but it cannot stop working if the user launches the camera.

    Thanks!!!

    Mike


    Tuesday, July 10, 2018 10:35 PM

All replies

  • Hi ,

    This problem is strange and it is not suitable to discuss via the forum. It needs more professional support. I suggest that you might need to open a support ticket for this. Please contact our paid phone support at MS Support. You will get 1:1 support on that. Please kindly note that your support ticket will be free if it is Microsoft's issue.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, July 11, 2018 6:36 AM
  • @MBedford2016,

    According to Honeywell, the camera and barcode scanner on the CT50 share the same UART connection.  You must make sure to release and dispose the barcode scanner prior to using the camera.  For additional information on this issue, please contact Honeywell.

    Terry Warwick
    Microsoft

    Monday, July 23, 2018 1:39 PM
  • @Terry Warwick, 

    Thank you for the reply. Yes, I did contact Honeywell and found out about the sharing of the UART connection. I then took the barcode scanning sample that Honeywell wrote (which is just based on the BarcodeScanner API), implemented my camera/video code and then tried to get everything working by adding code to switch to camera and back which essentially does what you describe by disposing of the barcode scanner before instantiating camera/video. 

    However, the issue now is when I do this very thing that I am supposed to be doing, I am still running in to issues where the barcode scanner gives alert/error tones and intermittently locks up. I suspect it is a timing issue where I dispose of the barcode scanner but it is still not fully disposed before I make the calls to switch to camera/video (MediaCapture API). This is because the barcode scanners dispose call is not awaitable and there is no event I can subscribe to in order to know for sure that the barcode scanner has been disposed and it is safe to switch to MediaCapture. 

    You mentioned I need to "release and dispose" the barcode scanner. Can you explain that a bit more? Maybe I am missing something. I was just calling dispose before, however, when I suspected that there is a timing issue, I also now call and await on DisableAsync (which did not help/fix the issue) in hopes that awaiting on disable would ensure it is safe to then initialize the MediaCapture. 

    For the record, I did create a support case for this issue and shared the app sample that I am using with the support team so they can look at it. 

    Thanks!

    Mike

    Monday, July 23, 2018 4:22 PM
  • @MBedford2016,

    Dispose is normally thought of for freeing up resources that are used in a shared environment such as network connected receipt printers, but sounds like it is applicable here for the special situation in the Honeywell hardware.  We have a conceptual document on Sharing peripherals with others, which documents the use of Dispose and provides links to the appropriate reference materials.

    DisableAsync does not release the claim on the barcode scanner, it simply reverses the EnableAsync call.  In order to fully release the claim on the barcode scanner you should call Close and Dispose from the ClaimedBarcodeScanner object.  You can further Close and Dispose the unclaimed BarcodeScanner object as well.

    This situation is very unique to the Honeywell device.  I do not know if this will put the Honeywell device into the right state to switch between the use of the scanner and the use of the camera.  You may need to work closely with them for the best resolution.

    Terry Warwick
    Microsoft

    Monday, August 13, 2018 2:25 PM