none
Failed to create Device Family via HCK API (powershell RRS feed

  • Question

  • Hi, 

    I copy the powershell from http://msdn.microsoft.com/en-us/library/windows/hardware/hh998554.aspx  and change the line 

    [string[]]$HardwareIds = "HID\VID_045E&PID_006A&REV_1717&Col01", "HID\VID_045E&PID_006A&Col01", "HID_DEVICE_SYSTEM_MOUSE"

    to

    [string[]]$HardwareIds = "PCI\VEN_1AF4&DEV_1002&SUBSYS_00051AF4&REV_00 "  job will failed to do can not create device family

    I also tried [string[]]$HardwareIds = "PCI\VEN_1AF4&DEV_1002&SUBSYS_00051AF4 "

    I also tried [string[]]$HardwareIds = "PCI\VEN_1AF4&DEV_1002"

    job all failed , referring to  following log info below .

    Could anyone tell me the way to specify HardwareIds ?

    Exception calling "CreateDeviceFamily" with "2" argument(s): "Could not create Device family"
    At C:\Users\Administrator\Desktop\TargetFamily.ps1:41 char:44
    + $DeviceFamily = $Manager.CreateDeviceFamily <<<< ("My Device Family", $HardwareIds)
        + CategoryInfo          : NotSpecified: ( [], MethodInvocationException
        + FullyQualifiedErrorId : DotNetMethodException

    Exception calling "CreateTargetFamily" with "1" argument(s): "Value cannot be null.
    Parameter name: deviceFamily"
    At C:\Users\Administrator\Desktop\TargetFamily.ps1:50 char:52
    + $TargetFamily = $ProductInstance.CreateTargetFamily <<<< ($DeviceFamily)
        + CategoryInfo          : NotSpecified: ( [], MethodInvocationException
        + FullyQualifiedErrorId : DotNetMethodException

    Exception calling "FindTargetFromDeviceFamily" with "1" argument(s): "Value cannot be null.
    Parameter name: family"
    At C:\Users\Administrator\Desktop\TargetFamily.ps1:53 char:44
    + $ProductInstance.FindTargetFromDeviceFamily <<<< ($DeviceFamily) | foreach {
        + CategoryInfo          : NotSpecified: ( [], MethodInvocationException
        + FullyQualifiedErrorId : DotNetMethodException


    Best Regards, Mike

    • Moved by HLK ModeratorModerator Wednesday, October 3, 2012 6:06 PM Move to new forum (From:Windows Hardware WDK and Driver Development)
    Monday, July 30, 2012 10:27 AM

Answers

  • I'm assuming you've attempted to run this script at least once before you hit these issues. When it comes to target families and the hardware ids assigned to the target family, the target families and hardware ids must be unique to the DB (not just the projects). As such, there is some cleanup that will need to happen.

    You will need to remove the existing target and device family entries.

    The target family entries are probably associated with a project via the creation of the project and product instances (lines 45, 48, and 51). This means that the project(s) need to be removed. This can be done via HCK Studio. Look for projects names "My Device Family Project <timestamp>".

    Removing the device family entry can be done by running the powerscript line -

    $Manager.DeleteDeviceFamily("My Device Family")

    (I just added in before the CreateDeviceFamily statement on line 41.

    *************

    To avoid getting into this situation, any time you change the hardware ids in this script, you must change the name of the device family (i.e. "My Device Family" --> "My Device Family 2") and hardware ids. In short, there can only be one instance of the device family name and hardware ids can only be associated to one device family.


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

    Monday, July 30, 2012 6:31 PM
  • 1. I'll refer you to the help documentation which explains -

    A DeviceFamily object is a collection of hardware IDs that are cached
    in the data store under a common name. DeviceFamily is useful for
    treating a large number of devices that have different hardware IDs as one
    device to test in parallel. For example, a video-card manufacturer might have
    100 different video cards (with different hardware IDs) that all have
    essentially the same functionality.

    Hardware IDs that are added to a DeviceFamily must match the hardware
    IDs that Windows® reports for a device.

    As for HCK Studio, it doesn't support creating, and therefore, displaying information around device families. Device families can only be setup via the OM API.

    2. That particular exception is strange. I'm not finding any test definitions with that as a parameter. This looks more like an issue with powershell trying to colorize a message and has a binding mismatch of its data to its UI target.


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

    • Proposed as answer by John Garcia (HCK) Tuesday, July 31, 2012 5:42 PM
    • Marked as answer by Mike_Cao Thursday, August 2, 2012 2:50 AM
    Tuesday, July 31, 2012 5:42 PM
  • I remember there is a API to add manual jobs ,you can view my scripts as a reference https://github.com/vipmike007/whql_powershell

    Best Regards, Mike

    • Marked as answer by Mike_Cao Friday, November 1, 2013 6:57 AM
    Thursday, October 31, 2013 8:13 AM

All replies

  • I'm assuming you've attempted to run this script at least once before you hit these issues. When it comes to target families and the hardware ids assigned to the target family, the target families and hardware ids must be unique to the DB (not just the projects). As such, there is some cleanup that will need to happen.

    You will need to remove the existing target and device family entries.

    The target family entries are probably associated with a project via the creation of the project and product instances (lines 45, 48, and 51). This means that the project(s) need to be removed. This can be done via HCK Studio. Look for projects names "My Device Family Project <timestamp>".

    Removing the device family entry can be done by running the powerscript line -

    $Manager.DeleteDeviceFamily("My Device Family")

    (I just added in before the CreateDeviceFamily statement on line 41.

    *************

    To avoid getting into this situation, any time you change the hardware ids in this script, you must change the name of the device family (i.e. "My Device Family" --> "My Device Family 2") and hardware ids. In short, there can only be one instance of the device family name and hardware ids can only be associated to one device family.


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

    Monday, July 30, 2012 6:31 PM
  • Thanks, It works 

    I have 2 more questions :

    1. what's relationship between device family and HardwareIds ? in HCK Studio GUI ,which part stands for Device family ?

    2.the jobs could run automately ,but in the scripts it has following errors :

    Write-Host : Cannot bind parameter 'ForegroundColor'. Cannot convert value "Device Install Check For Other Device Stabi
    lity (Certification)" to type "System.ConsoleColor" due to invalid enumeration values. Specify one of the following enu
    meration values and try again. The possible enumeration values are "Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, Dark
    Magenta, DarkYellow, Gray, DarkGray, Blue, Green, Cyan, Red, Magenta, Yellow, White".
    At C:\Users\Administrator\Desktop\TargetFamily.ps1:65 char:38
    +     Write-Host "running test {0} " -f <<<<  $_.Name
        + CategoryInfo          : InvalidArgument: (:) [Write-Host], ParameterBindingException
        + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.WriteHostCommand

    Any idea about it ?

    Thanks


    Best Regards, Mike

    Tuesday, July 31, 2012 3:05 AM
  • <ship>The target family entries are probably associated with a project via the creation of the project and product instances (lines 45, 48, and 51). This means that the project(s) need to be removed. This can be done via HCK Studio. Look for projects names "My Device Family Project <timestamp>". </ship>

    Actually before I ask the questions ,I deleted the whole project in HCK studio and deleted machine pool in HCK manager manually ,why still hit that issue ?


    Best Regards, Mike

    Tuesday, July 31, 2012 3:07 AM
  • 1. I'll refer you to the help documentation which explains -

    A DeviceFamily object is a collection of hardware IDs that are cached
    in the data store under a common name. DeviceFamily is useful for
    treating a large number of devices that have different hardware IDs as one
    device to test in parallel. For example, a video-card manufacturer might have
    100 different video cards (with different hardware IDs) that all have
    essentially the same functionality.

    Hardware IDs that are added to a DeviceFamily must match the hardware
    IDs that Windows® reports for a device.

    As for HCK Studio, it doesn't support creating, and therefore, displaying information around device families. Device families can only be setup via the OM API.

    2. That particular exception is strange. I'm not finding any test definitions with that as a parameter. This looks more like an issue with powershell trying to colorize a message and has a binding mismatch of its data to its UI target.


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

    • Proposed as answer by John Garcia (HCK) Tuesday, July 31, 2012 5:42 PM
    • Marked as answer by Mike_Cao Thursday, August 2, 2012 2:50 AM
    Tuesday, July 31, 2012 5:42 PM
  • hi Mike_Cao,

    is this problem solved for you? how did you get it done please help me to solve it. i am still facing the same problem. when i run the TargetFamily.ps1 script following are the errors coming.

    I have deleted all the projects in the Studio, deleted all the pools.  

    Usage: %SystemRoot%\syswow64\WindowsPowerShell\v1.0\powershell.exe -file TargetFamily.ps1 <<ControllerMachineName>>
    connecting to the controller RIBDI
    BEAS
    HALFLIFE
    True
    True
    Exception calling "CreateDeviceFamily" with "2" argument(s): "Couldn't use the provided hardware id's for this device
    amily"
    At C:\Users\Administrator\Desktop\TargetFamily.ps1:41 char:44
    + $DeviceFamily = $Manager.CreateDeviceFamily <<<< ("Device Family", $HardwareIds)
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : DotNetMethodException

    Exception calling "CreateTargetFamily" with "1" argument(s): "Value cannot be null.
    Parameter name: deviceFamily"
    At C:\Users\Administrator\Desktop\TargetFamily.ps1:50 char:52
    + $TargetFamily = $ProductInstance.CreateTargetFamily <<<< ($DeviceFamily)
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : DotNetMethodException

    Exception calling "FindTargetFromDeviceFamily" with "1" argument(s): "Value cannot be null.
    Parameter name: family"
    At C:\Users\Administrator\Desktop\TargetFamily.ps1:53 char:44
    + $ProductInstance.FindTargetFromDeviceFamily <<<< ($DeviceFamily) | foreach {
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : DotNetMethodException

    -> Is the following way to add devices?

    [string[]]$HardwareIds = "PCI\VEN_1425&DEV_4403&SUBSYS_00001425&REV_00" , "PCI\VEN_1425&DEV_4403&SUBSYS_00001425" , "PCI\VEN_1425&DEV_4403&CC_020000" , "PCI\VEN_1425&DEV_4403&CC_0200"

    I could able to create Machine pool, Project  but adding target is failing.


    Krishna

    Monday, August 13, 2012 10:02 AM
  • Hi, Krishna 

    1.Did you do following steps suggested by MSFT engineer 

    $Manager.DeleteDeviceFamily("My Device Family")

    (I just added in before the CreateDeviceFamily statement on line 41.

    *************

    2.for the HardwareIds , I remove &REV_00 ,then it works 

    Mike


    Best Regards, Mike

    Monday, August 13, 2012 11:36 AM
  • hi Mike,

    I tried adding the line you mentioned, i am getting folloiwng error.

    Usage: %SystemRoot%\syswow64\WindowsPowerShell\v1.0\powershell.exe -file TargetFamily.ps1 <<ControllerMachineName>>
    connecting to the controller RIBDI
    BEAS
    HALFLIFE
    True
    True
    Exception calling "DeleteDeviceFamily" with "1" argument(s): "Couldn't find the correct device family to remove"
    At C:\Users\Administrator\Desktop\TargetFamily.ps1:39 char:28
    + $Manager.DeleteDeviceFamily <<<< ("My Device Family")
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : DotNetMethodException

    Exception calling "CreateDeviceFamily" with "2" argument(s): "Couldn't use the provided hardware id's for this device f
    amily"
    At C:\Users\Administrator\Desktop\TargetFamily.ps1:44 char:44
    + $DeviceFamily = $Manager.CreateDeviceFamily <<<< ("My Device Family", $HardwareIds)
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : DotNetMethodException

    Exception calling "CreateTargetFamily" with "1" argument(s): "Value cannot be null.
    Parameter name: deviceFamily"
    At C:\Users\Administrator\Desktop\TargetFamily.ps1:53 char:52
    + $TargetFamily = $ProductInstance.CreateTargetFamily <<<< ($DeviceFamily)
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : DotNetMethodException

    Exception calling "FindTargetFromDeviceFamily" with "1" argument(s): "Value cannot be null.
    Parameter name: family"
    At C:\Users\Administrator\Desktop\TargetFamily.ps1:56 char:44
    + $ProductInstance.FindTargetFromDeviceFamily <<<< ($DeviceFamily) | foreach {
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : DotNetMethodException

    =====

    script

    =====

    $ObjectModel = [Reflection.Assembly]::LoadFrom($env:WTTSTDIO + "microsoft.windows.Kits.Hardware.objectmodel.dll")
    $ObjectModel = [Reflection.Assembly]::LoadFrom($env:WTTSTDIO + "microsoft.windows.Kits.Hardware.objectmodel.dbconnection.dll")

    Clear-Host

    write-Host "Usage: %SystemRoot%\syswow64\WindowsPowerShell\v1.0\powershell.exe -file TargetFamily.ps1 <<ControllerMachineName>> "

    $ControllerName = $args[0]
    if ($ControllerName -eq $null -OR $ControllerName -eq "")
    {
        write-host "Need to supply the controller Name as a parameter to this script"
        return
    }
    else
    {
        write-host connecting to the controller $ControllerName
    }


    # connect to the controller
    $Manager = new-object -typename Microsoft.Windows.Kits.Hardware.ObjectModel.DBConnection.DatabaseProjectManager -Args $ControllerName, DTMJobs


    $RootPool = $Manager.GetRootMachinePool()
    $DefaultPool = $RootPool.DefaultPool

    # create the pool
    $TestPool = $RootPool.CreateChildPool("TestPool")

    # find all the computers in the default pool, and move them into the test pool
    $DefaultPool.GetMachines() | foreach {
        write-host $_.Name
        $DefaultPool.MoveMachineTo($_, $TestPool)
        }

    # now, make sure that the computers are in a ready state
    $TestPool.GetMachines() | foreach { $_.SetMachineStatus([Microsoft.Windows.Kits.Hardware.ObjectModel.MachineStatus]::Ready, 1) }

    $Manager.DeleteDeviceFamily("My Device Family")
    # create a device family

    [string[]]$HardwareIds = "PCI\VEN_1425&DEV_4402&SUBSYS_00001425&REV_00\4&476E768&0&0428", "{4D36E97D-E325-11CE-BFC1-08002BE10318}\CHT4NDIS\5&25CBEC1A&0&0001"

    $DeviceFamily = $Manager.CreateDeviceFamily("My Device Family", $HardwareIds)

    # create a project
    $Project = $Manager.CreateProject("NIC 2K12 {0}" -f [DateTime]::Now.ToString())

    # create a product instance by using the OS Platform of the first computer that you find
    $ProductInstance = $Project.CreateProductInstance("Product Instance", $TestPool, $TestPool.GetMachines()[0].OSPlatform)

    # create a target family by using the device family that you created earlier
    $TargetFamily = $ProductInstance.CreateTargetFamily($DeviceFamily)

    #find all the devices in this machine pool that are in this device family
    $ProductInstance.FindTargetFromDeviceFamily($DeviceFamily) | foreach {
        "attempting to add target $_.Name on machine $_.Machine.Name to TargetFamily"
        # and add those to the target family
        
        # check this first, to make sure that this can be added to the target family
        if ($TargetFamily.IsValidTarget($_)) {
            $TargetFamily.CreateTarget($_)
            }
        }

    #schedule all tests
    $Project.GetTests() | foreach {
        "test {0} is {1}" -f  $_.Name, $_.ScheduleOptions.ToString()
        Write-Host "running test {0} " -f $_.Name
        $_.QueueTest();        
        }


    Krishna

    Monday, August 13, 2012 12:08 PM
  • hi Mike,

    I cleared existing device familes with GetDeviceFamilies and DeleteDeviceFamily methods. then i was able to create a Devicefamily for both NDIS & VBD id's.

    Problem is for VBD device it didn't duplicate the tests. but for NDIS driver it had duplicate all the tests when i select two devices in the selection tab.

    Is this expected, could you let me know how do for NDIS.

    HW ids:

    [string[]]$HardwareIds = "PCI\VEN_1425&DEV_4402&SUBSYS_00001425", "{4D36E97D-E325-11CE-BFC1-08002BE10318}\CHT4NDIS"

    VBD tests total 22: when i add two VBD devices i got 29 tests

    NDIS tests total 77: when i add two NDIS devices i got 154 tests. how to achieve this like VBD.

    Thanks


    Krishna

    Tuesday, August 14, 2012 8:11 AM
  • Hi,  Krishna

    I am also reseaching how to run NDIS job and  Remote Debug job (win2012) only via powershell now ,

    If still no progress ,I think I will turn MSFT engineer for help 


    Best Regards, Mike

    Tuesday, August 14, 2012 8:21 AM
  • Hi, Krishna

    I think API for MachineRole could solve you issue . ,could you show me your scripts about NDIS jobs if possible ?


    Best Regards, Mike

    Monday, August 20, 2012 8:14 AM
  • hi Mike,

    -> following is the way I am providing the HW ids.

    [string[]]$HardwareIds = "PCI\VEN_1425&DEV_4402&SUBSYS_00001425", "{4D36E97D-E325-11CE-BFC1-08002BE10318}\CHT4NDIS"

    -> full script is shown below.

    $ObjectModel = [Reflection.Assembly]::LoadFrom($env:WTTSTDIO + "microsoft.windows.Kits.Hardware.objectmodel.dll")
    $ObjectModel = [Reflection.Assembly]::LoadFrom($env:WTTSTDIO + "microsoft.windows.Kits.Hardware.objectmodel.dbconnection.dll")

    Clear-Host

    write-Host "Usage: %SystemRoot%\syswow64\WindowsPowerShell\v1.0\powershell.exe -file TargetFamily.ps1 <<ControllerMachineName>> "

    $ControllerName = $args[0]
    if ($ControllerName -eq $null -OR $ControllerName -eq "")
    {
        write-host "Need to supply the controller Name as a parameter to this script"
        return
    }
    else
    {
        write-host connecting to the controller $ControllerName
    }


    # Connect to the controller
    $Manager = new-object -typename Microsoft.Windows.Kits.Hardware.ObjectModel.DBConnection.DatabaseProjectManager -Args $ControllerName, DTMJobs


    $RootPool = $Manager.GetRootMachinePool()
    $DefaultPool = $RootPool.DefaultPool

    # create the pool
    $TestPool = $RootPool.CreateChildPool("AutoTestPool")

    #move all machines in the default pool
    $DefaultPool.GetMachines() | foreach {
        write-host $_.Name
        $DefaultPool.MoveMachineTo($_, $TestPool)
        }

    #reset all machines
    $TestPool.GetMachines() | foreach { $_.SetMachineStatus([Microsoft.Windows.Kits.Hardware.ObjectModel.MachineStatus]::Ready, 1) }

    #create a device family
    [string[]]$HardwareIds = "PCI\VEN_1425&DEV_4402&SUBSYS_00001425", "{4D36E97D-E325-11CE-BFC1-08002BE10318}\CHT4NDIS"
    $DeviceFamily = $Manager.CreateDeviceFamily("VBD_Test_14", $HardwareIds)

    #create a project
    $Project = $Manager.CreateProject("VBD_Test_1 Project {0}" -f [DateTime]::Now.ToString())

    #create a product instance, using the OS Platform of the first machine we find
    $ProductInstance = $Project.CreateProductInstance("My Product Instance", $TestPool, $TestPool.GetMachines()[0].OSPlatform)

    # create a target family, using the Device Family we created earlier
    $TargetFamily = $ProductInstance.CreateTargetFamily($DeviceFamily)

    #find all of the devices in this machine pool, which are in this device family
    $ProductInstance.FindTargetFromDeviceFamily($DeviceFamily) | foreach {
        "attempting to add target $_.Name on machine $_.Machine.Name to TargetFamily"
        # and add those to the target family
        if ($TargetFamily.IsValidTarget($_)) {
            $TargetFamily.CreateTarget($_)
            }
        }



    Krishna

    Monday, August 20, 2012 8:41 AM
  • Can you explain this line,  "API for MachineRole could solve you issue" .

    Krishna

    Monday, August 20, 2012 9:03 AM
  • Hi,

    NDIS need 2 guests , one is NDIS client (sut) ,another one is NDIS server .I think we usually use driver on NDIS client to do whql test . use machine role could specify which guest is used to test ( I think ,but not sure ,need to research it )


    Best Regards, Mike

    Monday, August 20, 2012 9:26 AM
  • Hi, Krishna 

    follwowing scrips works for NDIS job although it is hardcode and lots of bugs in it .feel free to modify it .

    $TestPoolGroup.GetMachines() | foreach {
        $MachineName = $_.Name
        if ($_.name -eq "WIN-R6E454KO4MO") {
        $SlaveMachine = $_
        }
        $ProductInstance.FindTargetFromDeviceFamily($DeviceFamily) | foreach {
            "attempting to add target $_.Name on machine $_.Machine.Name to TargetFamily"
            # and add those to the target family
        
            # check this first, to make sure that this can be added to the target family
            if ($TargetFamily.IsValidTarget($_) -and $MachineName -match "SER") {
                "Mike Cao machinename is {0}" -f $MachineName
                $TargetFamily.CreateTarget($_)
                }
            }
        }


    $Project.GetTests()| foreach {
        
        "Test name :{0}" -f $_.Name 
        $MachineRole = $_.GetMachineRole()   #return machineset
        if ($MachineRole -eq "" -OR $MachineRole -eq $null) {
            $_.QueueTest()
        }
        else {
            $MachineRole.Roles[1].AddMachine($SlaveMachine)
            $_.QueueTest($MachineRole)
        }
       


    Best Regards, Mike

    Friday, August 24, 2012 2:21 AM
  • Hi Mike,

    I'm facing the problem while creating the device family for which hardware Id's starting with EVB\LND&PCI........&REV_10.. if I'm removing '&REV_10' test, it's able to create device family but not able to select the test device based on provided hardware id.

    Regards,

    Mudit



    • Edited by Mudit Garg Saturday, October 26, 2013 4:46 AM
    Friday, October 25, 2013 6:26 PM
  • Can you paste you code here or error code here?

    Best Regards, Mike

    Monday, October 28, 2013 11:30 AM
  • Hi Mike,

    I found the other way to create project. I'm scanning the existing device families  (which are already created when creating the project through GUI) in the HCK Controller and if it matches my Hardware Id, then it's taking that device family and proceeding further.

    In this case, it's able to create project and listing test case, but now the issue is that, it's not able to identify the features associated with the test device, like my test device is NDIS Miniport which supports QoS, SRIOV, VMQ, RSS etc, so it's not listing the test cases related to these features as these features are not selected in Device Features. So , because of this, the 'Product Type' field in showing nothing, it should 'LAN(Server)'.

    However, I'm able to add features manually through script to the project, but is it a right to achieve the aim? What I want to achieve is that, when we are creating any project through GUI, it's scan all the supported features of the test device and create the project accordingly and also list the 'product type'. this is what I want to achieve through powershell.

    Regards,

    Mudit


    • Edited by Mudit Garg Tuesday, October 29, 2013 5:18 AM
    • Marked as answer by Mike_Cao Thursday, October 31, 2013 8:11 AM
    • Unmarked as answer by Mike_Cao Thursday, October 31, 2013 8:11 AM
    Tuesday, October 29, 2013 4:32 AM
  • I remember there is a API to add manual jobs ,you can view my scripts as a reference https://github.com/vipmike007/whql_powershell

    Best Regards, Mike

    • Marked as answer by Mike_Cao Friday, November 1, 2013 6:57 AM
    Thursday, October 31, 2013 8:13 AM
  • Thanks Mike. i'll check at the provided link.

    Regards,

    Mudit

    Monday, November 4, 2013 11:15 AM