none
Object Model, please give me the list of HardwareIDs on that test machine RRS feed

  • Question

  • "Object Model, please give me the list of HardwareIDs on that test machine.  If I have to, I'll look for the one with my Vendor ID.  If you can do it for me, even better."

    While attempting to automate WHQL testing using the HCK Object Model, I see there are two approaches shown in sample power shell scripts.

    One method is simply assign the hard-coded hardware ID:

    #this is the hardware id that corresponds to MOST keyboards, which all systems seem to have.
    $data = $ProductInstance.FindTargetFromId("HID_DEVICE_SYSTEM_KEYBOARD")
     

    Another method is to create a Device Family:

    # create a device family
    [string[]]$HardwareIds = "HID\VID_045E&PID_006A&REV_1717&Col01", "HID\VID_045E&PID_006A&Col01", "HID_DEVICE_SYSTEM_MOUSE"
    $DeviceFamily = $Manager.CreateDeviceFamily("My Device Family", $HardwareIds)

    In each case, they're hard-coded in there.  Ok, "not a problem, I have only one device to test".  Well, no.  I have many devices I want to test, and they all share the same vendorID, while the rest of the HardwareID is often unique.  

    In the GUI (HCK Studio), we can manually set up the machine and the device in the machine to test ('configuration' and 'selection' areas/menus).  So my question is this:  How, using the Object Model, can I obtain a list of the HardwareIDs on a given test machine, so that I can look for the one with my matching VendorID, and so I can pick that one to run the test against?  The GUI gets them all automatically and lets us place check marks in boxes to specify what to test.

    Thursday, March 28, 2013 6:56 PM

All replies

  • The GUI gets all the targets by calling Machine::GetTestTargets(). From the returned list, you can query for the target desired by looking at attributes such as Name, TargetType and Key.

    You can also cast the Target (based on TargetType to IXXXTargetData) and get additional properties (i.e. hardware id for IDeviceTargetData types).


    John -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Thursday, March 28, 2013 7:13 PM
  • Whoa, is it that simple?  I'll go try it!  Thanks : )

    Actually, before I do that, what is the IXXXTargetData part?  Perhaps it would be instructive to learn more about that, specifically as it applies to obtaining the HardwareID, which I believe is needed to specify the target I want to run the tests against.

    • Edited by hh-hh-hh Thursday, March 28, 2013 7:29 PM
    Thursday, March 28, 2013 7:27 PM
  • The XXX in IXXXTargetData represents the targets type (i.e. Device, System, Filter, DeviceCollection). See OM API in http://msdn.microsoft.com/en-us/library/windows/hardware/jj124347.aspx.

    John -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Thursday, March 28, 2013 8:32 PM
  • Ah, this is making some more sense now.  And being a bit new to PowerShell, I am wondering how to cast the Target so I might get the VendorID or HardwareID?  Is there an example that can be used, based on something like this:

    # Subpool is already defined earlier on, and is a test pool.
    $subpool.GetChildPools() | foreach { write-host $_.getMachines().getTestTargets().name }

    The code above lists the targets successfully, and I'm so close to being able to list the VendorIDs.  Just needing to understand the syntax for the cast.

    Or in other words, I know the machine name and desire to choose the target based on my VendorID.
    • Edited by hh-hh-hh Monday, April 8, 2013 9:45 PM Edited for a little more explanation.
    Monday, April 8, 2013 8:10 PM
  • I wonder if this is the approach?  I don't think so, because I did not really did cast the target as mentioned  above...

    $desiredTarget = $testMachine.GetTestTargets() | where { [string]($_.HardwareId) -like "*1234*" }

    (where "1234" would be substituted with my actual VendorId).  I also noticed that '-contains' did not work for me, neither did the above work until I added the '**' wildcards.

    This code did work, I was able to get the HCK to go run a test against my device in my machine (yea : ) but I'm still open to a better way.


    • Edited by hh-hh-hh Tuesday, April 9, 2013 11:55 PM
    Tuesday, April 9, 2013 11:55 PM
  • Do you think this can be extended to differentiating by device serial number?

    Tsang Chan

    Wednesday, April 10, 2013 6:28 AM
  • Tsang,

    Good question, and I don't yet know the answer.  For example, I looked at one of the targets and noticed that we have access to the Hardware and Vendor IDs, but it doesn't seem to have Serial numbers set aside for our convenience.  Though there may be a way to get them, I'm not yet aware how to do that.


    To get information about a target object, I tried something like: "$tm.GetTestTargets()", where '$tm' is defined as the test machine that I want to query.  I was given many results, including the example below, which happens to be one of the USB devices on the system:

    Name            : USB Input Device
    Manufacturer    : (Standard system devices)
    VendorId        : VID_0557
    HardwareId      : {USB\VID_0557&PID_2221&REV_0100&MI_01, USB\VID_0557&PID_2221&MI_01}
    Drivers         : {C:\Windows\inf\input.inf, c:\windows\system32\drivers\hidusb.sys}
    DriverHash      : {3E2579E3F554A09277EF7AF0AF74F3B9F83FE84B, A27DB70A945C2569E6340013A294B3153D055E7D}
    DeviceClass     : HIDClass
    ContainerId     : {4358fa52-c421-53ff-934b-e5d0ffc924b0}
    InstanceId      : USB\VID_0557&PID_2221&MI_01\6&1C019A14&0&0001
    AllInboxDrivers : InboxDrivers
    IsHiddenDevice  : False
    Description     : 
    Machine         : Microsoft.Windows.Kits.Hardware.ObjectModel.DBConnection.WttMachine
    Key             : USB\VID_0557&PID_2221&MI_01\6&1C019A14&0&0001
    TargetType      : Device
    XmlData         : < ( a large XML output was omitted here to be polite on the thread : ) ) >


    -- hh



    • Edited by hh-hh-hh Wednesday, April 10, 2013 4:30 PM
    Wednesday, April 10, 2013 4:22 PM