How to determine the PPK2 Serial Number

Hi,

I have tried to look through the forums but I cannot find exactly how the nRF Connect -> Power Profiler application is able to get/obtain the device SN? 

In the log, and in the connection drop-down menu, the Power Profiler app shows a list of all connected PPK2's by SN so this information must be easily derived or stored somewhere, but I cannot find it?

I tried looking through all the Device Manager Properties for the device, and I can find a lot of different ID's and strings, but none that resemble the SN of the device?!

This information is quite important to us for using and tracking the PPK2 devices in our factory, and it is a huge problem that we are not able to read or infer this from the information available to us!  

If anyone can point me to a post or a resource about this, I would be grateful!

PS: I also cannot seem to find it as a readable property using the unofficial  GitHub - IRNAS/ppk2-api-python: Power Profiling Kit 2 unofficial python api.  

Parents Reply Children
  • Hi Bendik,

    I somehow missed it when I (tried) to inspect all the properties earlier, I am able to see the "Parent" property Value similar to how you show, and my SN# is F0D53E50C7CD

    However, I have been unable to get this property value listed via CLI in Windows (11). 

    Am I just missing some property? Should I use another command?

    Does anyone know how to retrieve this programmatically on Windows?  (Can we have it as a future FW update that it can be included in the MetaData?)

    For example I have tried variations of: 

    1. Get PNPDeviceID: 

    wmic path Win32_SerialPort where "DeviceID='COM9'" get PNPDeviceID

    2. list info of PNPDeviceID:

    wmic path Win32_PnPEntity where "DeviceID='USB\\VID_1915&PID_C00A&MI_01\\6&1A807EFB&0&0001'" get /format:list

    Which gives this listing, and I may have gone blind but for some reason that particular info does not appear to be in any of the many listed values?!

    Availability=
    Caption=nRF Connect USB CDC ACM (COM9)
    ClassGuid={4d36e978-e325-11ce-bfc1-08002be10318}
    CompatibleID={"USB\COMPAT_VID_1915&Class_02&SubClass_02&Prot_00","USB\COMPAT_VID_1915&Class_02&SubClass_02","USB\COMPAT_VID_1915&Class_02","USB\Class_02&SubClass_02&Prot_00","USB\Class_02&SubClass_02","USB\Class_02"}
    ConfigManagerErrorCode=0
    ConfigManagerUserConfig=FALSE
    CreationClassName=Win32_PnPEntity
    Description=nRF Connect USB CDC ACM
    DeviceID=USB\VID_1915&PID_C00A&MI_01\6&1A807EFB&0&0001
    ErrorCleared=
    ErrorDescription=
    HardwareID={"USB\VID_1915&PID_C00A&REV_0305&MI_01","USB\VID_1915&PID_C00A&MI_01"}
    InstallDate=
    LastErrorCode=
    Manufacturer=Nordic Semiconductor ASA
    Name=nRF Connect USB CDC ACM (COM9)
    PNPClass=Ports
    PNPDeviceID=USB\VID_1915&PID_C00A&MI_01\6&1A807EFB&0&0001
    PowerManagementCapabilities=
    PowerManagementSupported=
    Present=TRUE
    Service=usbser
    Status=OK
    StatusInfo=
    SystemCreationClassName=Win32_ComputerSystem

  • I have found *a solution* for Windows users - at least one that works on my dev computer.. time will tell! Smiley

    It takes two calls to the CLI via whatever tool you use (I use LabVIEW), but I only found the value I need through PowerShell (rumor is you can also find it in windows registry but that has even more "concerns" in terms of programmatic access and access rights).  Anyway, I found the parameter name in Windows to be> DEVPKEY_Device_Parent

    2-step solution, assuming you already know the COM port the device is on, in my example below it was on COM9:

    1. Issue command to get PNPDeviceID:

    wmic path Win32_SerialPort where "DeviceID='COM9'" get PNPDeviceID

    (parse the CLI output to obtain the PNPDeviceID, in my case it was USB\VID_1915&PID_C00A&MI_01\6&1A807EFB&0&0001)

    2. Issue a CLI command to run a Powershell Script.  The whole thing gets a bit "messy" but the below CLI goes in as one lump and executes in a second or so:

    cmd /c powershell.exe -Command "$deviceId = 'USB\VID_1915&PID_C00A&MI_01\6&1A807EFB&0&0001'; $parentProperty = Get-PnpDeviceProperty -InstanceId $deviceId | Where-Object { $_.KeyName -eq 'DEVPKEY_Device_Parent' }; $parentInstanceId = $parentProperty.Data; Write-Output "Parent Instance ID: $parentInstanceId""

    Parse the output to get the ParentID value, for me it was USB\VID_1915&PID_C00A\F0D53E50C7CD

    ....tada?! :D

    EDIT>>>

    Depending on your tools and needs, I found a way to speed it up by making one CLI call, and then getting the ParentID value from a Windows Registry Read.  Of course, if you use .NET you can also avoid the CLI entirely which may speed up the process even more.  I did not want to depend on .NET on the target machines so my method currently is this:

    1: get info on all (connected/active) SerialPorts via CLI (takes the same amount of time as getting one port)>
    wmic path Win32_SerialPort get DeviceID, PNPDeviceID, Description

    2: parse the CLI output and make a list of PNPDeviceIDs (and COM Port) filtered by the Description field which should contain "nRF Connect" etc.

    3: Open Windows Registry with "KEY_READ" privileges to HKEY_LOCAL_MACHINE (this should be allowed on most systems I think).  The SubKeys you want to list/read consists of the "first part, up to the second &" of the PNPDeviceID USB\VID_1915&PID_C00A&MI_01\6&1A807EFB&0&0001 (VID = VendorID so I suspect this is constant over time but ...)  

    4: when you read the subkey above you should get a list (array) of them, representing the SN# of all the matching VID devices that has at some point been connected.  From there I open each subkey from the list in step 3, using additional info from the PNPDeviceID string I started with to find which SN# belongs to it.  E.g. Open key "SYSTEM\CurrentControlSet\Enum\USB\VID_1915&PID_C00A\F0D53E50C7CD" and Read Value of "ParentIdPrefix" and match this against the "6&1A807EFB&0" - If it matches you found your device SN.

    Sorry if the above is hard to follow but basically if you open regedit to the Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB you will see all USB items, most likely including many other VID devices as well. so step 3 is to get a list of all the nRF device based on the VID number we got from CLI (or .NET or...).  Then under e.g. Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\VID_1915&PID_C00A you will see the SN of every PPK you ever had attached, and inside each SN key, there will be a ParentIdPrefix to match against the "last part" of the PNPDeviceID string (from the last \ to the end of the string). 

    So in my current implementation, I now do one CLI that takes around 300ms - then using various regex and filters I cross-check against the registry (the registry reads are on the 1ms level on my system), and out of this I return an array of COM# and SN# currently connected. 

Related