title: Using libudev to find device dev path by pid and vid
body: <p>I currently have a device that has a known PID and VID that is unique to the device and I want to use that information to find it's dev device path, like <code>/dev/ttyUSB0</code>.</p>
  <p>Is this possible? So far, I have been successful in using libudev to find the correct <code>udev_device</code> for the pid and vid, but unsuccessful finding the path from this.</p>
  <p>Is there any way to get this information?</p>
  <pre class="lang-cpp prettyprint-override"><code>    ud = udev_new();
  
  
      struct udev_enumerate *enumerate = udev_enumerate_new(ud);
  
      udev_enumerate_add_match_subsystem(enumerate, &quot;usb&quot;);
      udev_enumerate_add_match_property(enumerate, &quot;DEVTYPE&quot;, &quot;usb_device&quot;);
      udev_enumerate_scan_devices(enumerate);
  
      struct udev_list_entry *devices;
      devices = udev_enumerate_get_list_entry(enumerate);
  
      struct udev_list_entry *dev_list_entry;
      udev_list_entry_foreach(dev_list_entry, devices)
      {
          const char *sysfs_path = udev_list_entry_get_name(dev_list_entry);
          struct udev_device *raw_dev = udev_device_new_from_syspath(ud, sysfs_path);
  
          uint16_t vendor_id;
          uint16_t product_id;
          udev_get_sysattr_u16_base16(raw_dev, &quot;idVendor&quot;, &amp;vendor_id);
          udev_get_sysattr_u16_base16(raw_dev, &quot;idProduct&quot;, &amp;product_id);
  
          if (vendor_id == VID &amp;&amp; product_id == PID) {
              //find the device path  
          }
          
      }
  </code></pre>