Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9289715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:14:50+00:00 2026-06-18T20:14:50+00:00

Something I can’t seem to find the answer for. Please bare in mind I

  • 0

Something I can’t seem to find the answer for. Please bare in mind I am not an expert so I may be missing simple, perhaps how I’m printing the device I want.
I am trying to store a device version number (dvm from herein), off a USB device. The problem is the USB device has two columns for reporting, feature and output.

So when I print the device I receive two sets of print statements.

#

def device(target_usage, target_vendor_id):

hidDevice = False
all_devices = hid.HidDeviceFilter(vendor_id = target_vendor_id).get_devices()
print "\n", all_devices
if len(all_devices) == 0:
    # Exit if no devices found, report error.
    hidDevice = False
    time.sleep(0.2)
    print "No devices can be detected, please check device is connected."
    sys.exit(1)
    return
elif len(all_devices) > 2:
    # announce there are more than 1 device connected to prevent conflicting upgrades
    hidDevice = True
    time.sleep(0.2)
    print "Too many devices connected, ensure the only device connected is the device needed to test."
    sys.exit(1)

else:
    # loop through all devices
    for device in all_devices:
        try:
            device.open()

            # print device details
            device_name = unicode("=== INFO: Found %s %s (vID=[%04x], pID=[%04x], version number [%04x]) ===" % \
            (device.vendor_name, device.product_name, device.vendor_id, device.product_id, device.version_number))
            dvm = unicode("%04x" % \
            (device.version_number))
            print dvm;
            print device_name; 

        finally:
            device.close()

    hidDevice = True

return hidDevice

#

When this function is called it will print all devices but I end up with the following result (Modified pids/vids etc for privacy issues.)

[HID device (vID=0x0000, pID=0x0000, v=0x0000); Make; Model, Path: \?\hid#vid_0000&pid_0000&col01#7&00000000&1&0000#{00000000-0000-0000-0000-000000000000}, HID device (vID=0x0000, pID=0x0000, v=0x0000); Make; Model, Path: \?\hid#vid_0000&pid_0000&col02#7&00000000&1&0000#{00000000-0000-0000-0000-000000000000}

The important part is the col01 and col02.

How can I filter that second enumerated HID device out?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T20:14:52+00:00Added an answer on June 18, 2026 at 8:14 pm

    Included the following code.

    for report in device.find_output_reports(): 
                        if target_usage in report:
                            # add to target list
                            Targets.append(device)
    
                finally:
                    device.close()
    
            for item in Targets:        
    
                try:
                    item.open(output_only = True)
                    dvm = unicode("%04x" % \
                    (device.version_number))
                    print dvm
                finally:
                    item.close()
    

    Problem resolved.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question concerning volatile keyword I can't seem to find an answer
Assume we need a function that returns something. But that something can be not
According to Martin Fowler Something can be public but that does not mean you
In a PHP function, sometimes I find that something can be echoed, yet it
how can something print 3 times when it only goes the printing code twice?
Ideally something I can plug and play pretty readily an quickly that supports GeoCoding
There is something I can't digest. I'm learning some assembler and right now I'm
Is there an IDE/Tool/script/something that can show call hierarchy and/or data flow in Scala+Java
I need a c# number something that can handle very large numbers but also
Does anyone know of a gamification gem? I'm looking for something that can provide

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.