<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Relating COM port name and Segger ID</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/6220/relating-com-port-name-and-segger-id</link><description>Dear Fellow developers 
 I am developing an application where I need several nrf51 USB dongles (S120) attached to a PC, and I need a way to distinguish one dongle from another. I am using the ble_driver_win_0.3.0 S120 softdevice with unmanaged C++ on</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 29 Dec 2020 18:01:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/6220/relating-com-port-name-and-segger-id" /><item><title>RE: Relating COM port name and Segger ID</title><link>https://devzone.nordicsemi.com/thread/286883?ContentTypeID=1</link><pubDate>Tue, 29 Dec 2020 18:01:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:53ebfacf-c926-4c72-a529-efb65a8fd5b1</guid><dc:creator>PDKshade</dc:creator><description>&lt;p&gt;here&amp;#39;s a simpler replacement for jlink_comports_get.py that doesn&amp;#39;t rely on windows or the windows registry. Works on OSX and Windows for me.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="python"&gt;from pynrfjprog import LowLevel  # NB old code relied on API which is depreicated

def connected_device_serials_get():
    families = [&amp;#39;NRF51&amp;#39;, &amp;#39;NRF52&amp;#39;]
    devices = {}
    for family in families:
        api = LowLevel.API(family)
        api.open()
        snr = api.enum_emu_snr()
        for sn in snr:
            ports = api.enum_emu_com_ports(sn)
            for port in ports:
                device = {&amp;#39;comport&amp;#39;: port.path, &amp;#39;serial&amp;#39;: port.serial_number}
                devices[port.serial_number] = device
        api.close()
    dlist = [devices[d] for d in devices]
    return dlist&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Relating COM port name and Segger ID</title><link>https://devzone.nordicsemi.com/thread/21778?ContentTypeID=1</link><pubDate>Tue, 02 Aug 2016 14:37:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:15d8438d-1d0e-4f07-a209-db8cc4d73b51</guid><dc:creator>Zoltan</dc:creator><description>&lt;p&gt;I&amp;#39;m attaching a Python 2 script that I wrote for personal use and prints Segger serial number + COM port pairs in Windows.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/jlink_5F00_comports_5F00_get.py"&gt;jlink_comports_get.py&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Relating COM port name and Segger ID</title><link>https://devzone.nordicsemi.com/thread/21777?ContentTypeID=1</link><pubDate>Thu, 09 Jul 2015 12:30:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ed04755b-a4ad-411b-b04a-e1db860f44fa</guid><dc:creator>jpo38</dc:creator><description>&lt;p&gt;Let&amp;#39;s do that: &lt;a href="https://devzone.nordicsemi.com/question/44253/windows-how-to-distinguish-ble-dongle-from-ble-dev-board/"&gt;devzone.nordicsemi.com/.../&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Relating COM port name and Segger ID</title><link>https://devzone.nordicsemi.com/thread/21776?ContentTypeID=1</link><pubDate>Thu, 09 Jul 2015 12:23:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f9f7ef08-c346-4cd1-8067-eb8b81077ded</guid><dc:creator>Rasmus</dc:creator><description>&lt;p&gt;If you open nRFgo Studio the Device Manager window will tell if the Segger ID is a nRF51 Development board or dongle, so surely there is some mechanism to find out. You should ask on the forum :)
EDIT: I&amp;#39;ve searched the registry and found that the value of VID_1366&amp;amp;PID_1015&amp;lt;Segger_ID&amp;gt;\Capabilities are different between my development board and dongles. On the development board Capabilities has a value of 0x00000090 (144) and on my three dongles Capabilities has a value of 0x00000094 (148). I don&amp;#39;t know if this is reliable data, but it is the only thing I can find separating dongles from boards in the registry.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Relating COM port name and Segger ID</title><link>https://devzone.nordicsemi.com/thread/21775?ContentTypeID=1</link><pubDate>Thu, 09 Jul 2015 12:19:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:521814ab-42ae-481c-be02-a3ff4601ae76</guid><dc:creator>jpo38</dc:creator><description>&lt;p&gt;You mean for the dev kits I have inhouse? This would work but looks more like a hack ;-)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Relating COM port name and Segger ID</title><link>https://devzone.nordicsemi.com/thread/21774?ContentTypeID=1</link><pubDate>Thu, 09 Jul 2015 12:12:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5cd8173f-c986-42a4-8136-f3b78e4e53e2</guid><dc:creator>Rasmus</dc:creator><description>&lt;p&gt;You could make an exclude list and skip the Segger IDs that is on the list. I suppose you have a limited amount of dev kits to exclude.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Relating COM port name and Segger ID</title><link>https://devzone.nordicsemi.com/thread/21773?ContentTypeID=1</link><pubDate>Thu, 09 Jul 2015 12:09:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fd488ac7-5a15-40f7-85ac-6c64f1e2376b</guid><dc:creator>jpo38</dc:creator><description>&lt;p&gt;Hello Rasmus. I tested that, and in my case it works, except if I have both the dongle and the dev kit (plugged to the PC by USB to get power supply). Then both port names are found and we cannot know which one should be picked up...is there a way to fix that?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Relating COM port name and Segger ID</title><link>https://devzone.nordicsemi.com/thread/21772?ContentTypeID=1</link><pubDate>Wed, 25 Mar 2015 13:20:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a8d833d6-1995-4dfd-971f-3f9b11dd74fa</guid><dc:creator>Rasmus</dc:creator><description>&lt;p&gt;For future reference, here is a way to implement in C++: &lt;a href="http://stackoverflow.com/questions/7718471/c-search-windows-registry"&gt;stackoverflow.com/.../c-search-windows-registry&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Relating COM port name and Segger ID</title><link>https://devzone.nordicsemi.com/thread/21771?ContentTypeID=1</link><pubDate>Wed, 25 Mar 2015 11:47:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1e3a8855-426b-498e-b92f-867e1beafb74</guid><dc:creator>Carles</dc:creator><description>&lt;p&gt;One way is to use the Windows Registry:&lt;/p&gt;
&lt;p&gt;SYSTEM\CurrentControlSet\Enum\USB&lt;/p&gt;
&lt;p&gt;Search for &amp;quot;VID_1366&amp;quot; and then take a look at the layout of the Registry tree.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s some sample code in C# to do this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;public bool getCOMPort(string snr, out string com)
{
  snr = snr.Trim();
  com = &amp;quot;NOT_SET&amp;quot;;
  string segger_id_pidprefix = &amp;quot;&amp;quot;;
  Dictionary&amp;lt;string, string&amp;gt; com_ports = new Dictionary&amp;lt;string, string&amp;gt;();
  string ROOT = &amp;quot;SYSTEM\\CurrentControlSet\\Enum\\USB&amp;quot;;

  using (RegistryKey key = Registry.LocalMachine.OpenSubKey(ROOT))
  {
    foreach (var segger_root_entry in key.GetSubKeyNames())
    {
      // Filter on Segger Vendor ID
      if (! segger_root_entry.StartsWith(&amp;quot;VID_1366&amp;quot;)) continue;

      using (RegistryKey segger_root_key = Registry.LocalMachine.OpenSubKey(ROOT + &amp;quot;\\&amp;quot; + segger_root_entry))
      {
        foreach (var segger_entry in segger_root_key.GetSubKeyNames())
        {
          using (RegistryKey segger_key = Registry.LocalMachine.OpenSubKey(ROOT + &amp;quot;\\&amp;quot; + segger_root_entry + &amp;quot;\\&amp;quot; + segger_entry))
          {
            string service = Convert.ToString(segger_key.GetValue(&amp;quot;Service&amp;quot;));
            if (service == &amp;quot;usbccgp&amp;quot;)
            {
              var segger_entry_trimmed = segger_entry.TrimStart(&amp;#39;0&amp;#39;);
              Console.WriteLine(&amp;quot;usbccgp &amp;quot; + segger_entry_trimmed + &amp;quot; - &amp;quot; + Convert.ToString(segger_key.GetValue(&amp;quot;ParentIdPrefix&amp;quot;)));
              if (segger_entry_trimmed.StartsWith(snr))
              {
                if (segger_id_pidprefix != &amp;quot;&amp;quot;)
                {
                  Console.WriteLine(&amp;quot;Error: Found more than one usbccgp entry for snr&amp;quot;);
                }
                segger_id_pidprefix = Convert.ToString(segger_key.GetValue(&amp;quot;ParentIdPrefix&amp;quot;));
              }
            }
            if (service == &amp;quot;usbser&amp;quot; || service == &amp;quot;JLinkCDC_x64&amp;quot;)
            {
              using (RegistryKey dev_param_key = Registry.LocalMachine.OpenSubKey(ROOT + &amp;quot;\\&amp;quot; + segger_root_entry + &amp;quot;\\&amp;quot; + segger_entry + &amp;quot;\\Device Parameters&amp;quot;))
              {
                if (dev_param_key == null) continue;

                string portname = Convert.ToString(dev_param_key.GetValue(&amp;quot;PortName&amp;quot;));
                com_ports[segger_entry] = portname;
                Console.WriteLine(&amp;quot;usbser &amp;quot; + segger_entry + &amp;quot; - &amp;quot; + portname);
              }
            }
          }
        }
      }
    }
  }

  Console.WriteLine(&amp;quot;segger_id_pidprefix &amp;quot; + segger_id_pidprefix);

  if (segger_id_pidprefix == &amp;quot;&amp;quot;)
  {
    Console.WriteLine(&amp;quot;Error: Could not find com port (empty pidprefix) for &amp;quot; + snr);
    return false;
  }

  foreach (var item in com_ports)
  {
    if (item.Key.StartsWith(segger_id_pidprefix))
    {
      com = item.Value;
      Console.WriteLine(&amp;quot;Found com &amp;quot; + com);
      return true;
    }
  }
  Console.WriteLine(&amp;quot;Error: Could not find com port (unknown pidprefix) for &amp;quot; + snr);
  return false;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Carles&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Relating COM port name and Segger ID</title><link>https://devzone.nordicsemi.com/thread/21770?ContentTypeID=1</link><pubDate>Wed, 25 Mar 2015 11:13:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a894d28c-edba-457a-ab61-53d2b39c399d</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@Rasmus: Do you want to detect the Segger ID on each COMport automatically in runtime in the code or it&amp;#39;s OK if you can have the list and use them manually ?&lt;/p&gt;
&lt;p&gt;If you simply need a list that matches COM Port and Segger ID, you can just open Master Control Panel on PC there is a dropdown list of COM Port-SeggerID there.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>