{"id":2810,"date":"2018-05-09T17:01:54","date_gmt":"2018-05-09T22:01:54","guid":{"rendered":"http:\/\/www.logikalsolutions.com\/wordpress\/?p=2810"},"modified":"2018-05-09T17:01:54","modified_gmt":"2018-05-09T22:01:54","slug":"qt-and-usb-pt-2","status":"publish","type":"post","link":"https:\/\/www.logikalsolutions.com\/wordpress\/information-technology\/qt-and-usb-pt-2\/","title":{"rendered":"Qt and USB &#8211; Pt. 2"},"content":{"rendered":"<p>Today&#8217;s post will be the first of at least two posts about identifying your USB device. I started by adding the following code.<\/p>\n<pre>        out &lt;&lt; \"ProductID: \" &lt;&lt; desc.idProduct &lt;&lt; endl;\r\n\r\n        r0_status = libusb_open(dev, &amp;hHandle);\r\n        if (r0_status != LIBUSB_SUCCESS)\r\n        {\r\n            out &lt;&lt; \"Error \" &lt;&lt; r0_status &lt;&lt; \" opening USB device. Error text: \" &lt;&lt; libusb_error_name(r0_status) &lt;&lt; endl;\r\n        }\r\n        else\r\n        {\r\n            unsigned char serialNumber[255] = { };\r\n            unsigned char vendorName[1024] = { };\r\n            unsigned char productName[1024] = { };\r\n\r\n            int textSize = libusb_get_string_descriptor_ascii(hHandle, desc.iSerialNumber, serialNumber, sizeof(serialNumber));\r\n            textSize = libusb_get_string_descriptor_ascii(hHandle, desc.idVendor, vendorName, sizeof(vendorName));\r\n            textSize = libusb_get_string_descriptor_ascii(hHandle, desc.idProduct, productName, sizeof(productName));\r\n\r\n            out &lt;&lt; \"Vendor: \" &lt;&lt; (char *)vendorName &lt;&lt; \"  Product: \" &lt;&lt; (char *)productName &lt;&lt; \"  Serial Number: \" &lt;&lt; (char *)serialNumber &lt;&lt; endl;\r\n        }\r\n\r\n        libusb_config_descriptor *config;\r\n<\/pre>\n<p>I left the first and last line in place so you would have some idea where in the getDeviceReport() method this code was inserted. Yes, libusb does have methods for obtaining this information but it comes with two major drawbacks.<\/p>\n<ol>\n<li>You have to actually be able to open the device. (more on that later)<\/li>\n<li>It expects the device to be able to tell you.<\/li>\n<\/ol>\n<p>My rant about security in Linux will come later in this post. First we need to look at two different sets of output. First, from when this program is run within QtCreator as just little ole me.<\/p>\n<p>&nbsp;<\/p>\n<pre>Current device count: 9\r\n\r\nNumber of possible configurations: 1   Device Class: 9  VendorID: 32903   ProductID: 36\r\nError -3 opening USB device. Error text: LIBUSB_ERROR_ACCESS\r\nInterfaces: 1   Interface Number: 0 | Number of endpoints: 1 | Descriptor Type: 5 | EP Address: 129 | \r\n\r\n\r\nNumber of possible configurations: 1   Device Class: 9  VendorID: 7531   ProductID: 2\r\nError -3 opening USB device. Error text: LIBUSB_ERROR_ACCESS\r\nInterfaces: 1   Interface Number: 0 | Number of endpoints: 1 | Descriptor Type: 5 | EP Address: 129 | \r\n\r\n\r\nNumber of possible configurations: 1   Device Class: 0  VendorID: 2362   ProductID: 9488\r\nError -3 opening USB device. Error text: LIBUSB_ERROR_ACCESS\r\nInterfaces: 1   Interface Number: 0 | Number of endpoints: 1 | Descriptor Type: 5 | EP Address: 129 | \r\n\r\n\r\nNumber of possible configurations: 1   Device Class: 0  VendorID: 1500   ProductID: 43037\r\nError -3 opening USB device. Error text: LIBUSB_ERROR_ACCESS\r\nInterfaces: 1   Interface Number: 0 | Number of endpoints: 2 | Descriptor Type: 5 | EP Address: 129 | Descriptor Type: 5 | EP Address: 2 | \r\n\r\n\r\nNumber of possible configurations: 1   Device Class: 9  VendorID: 32903   ProductID: 36\r\nError -3 opening USB device. Error text: LIBUSB_ERROR_ACCESS\r\nInterfaces: 1   Interface Number: 0 | Number of endpoints: 1 | Descriptor Type: 5 | EP Address: 129 | \r\n\r\n\r\nNumber of possible configurations: 1   Device Class: 9  VendorID: 7531   ProductID: 2\r\nError -3 opening USB device. Error text: LIBUSB_ERROR_ACCESS\r\nInterfaces: 1   Interface Number: 0 | Number of endpoints: 1 | Descriptor Type: 5 | EP Address: 129 | \r\n\r\n\r\nNumber of possible configurations: 1   Device Class: 9  VendorID: 7531   ProductID: 3\r\nError -3 opening USB device. Error text: LIBUSB_ERROR_ACCESS\r\nInterfaces: 1   Interface Number: 0 | Number of endpoints: 1 | Descriptor Type: 5 | EP Address: 129 | \r\n\r\n\r\nNumber of possible configurations: 1   Device Class: 0  VendorID: 1309   ProductID: 2\r\nError -3 opening USB device. Error text: LIBUSB_ERROR_ACCESS\r\nInterfaces: 1   Interface Number: 0 | Number of endpoints: 1 | Descriptor Type: 5 | EP Address: 129 | \r\n\r\n\r\nNumber of possible configurations: 1   Device Class: 9  VendorID: 7531   ProductID: 2\r\nError -3 opening USB device. Error text: LIBUSB_ERROR_ACCESS\r\nInterfaces: 1   Interface Number: 0 | Number of endpoints: 1 | Descriptor Type: 5 | EP Address: 129 | \r\n\r\n<\/pre>\n<p>As little ole me, I don&#8217;t have access. So, let us look at the output when I sudo this executable from the command line.<\/p>\n<pre>Current device count: 9\r\n\r\nNumber of possible configurations: 1   Device Class: 9  VendorID: 32903   ProductID: 36\r\nVendor:   Product:   Serial Number: \r\nInterfaces: 1   Interface Number: 0 | Number of endpoints: 1 | Descriptor Type: 5 | EP Address: 129 | \r\n\r\n\r\nNumber of possible configurations: 1   Device Class: 9  VendorID: 7531   ProductID: 2\r\nVendor:   Product: EHCI Host Controller  Serial Number: 0000:00:1d.0\r\nInterfaces: 1   Interface Number: 0 | Number of endpoints: 1 | Descriptor Type: 5 | EP Address: 129 | \r\n\r\n\r\nNumber of possible configurations: 1   Device Class: 0  VendorID: 2362   ProductID: 9488\r\nVendor:   Product:   Serial Number: \r\nInterfaces: 1   Interface Number: 0 | Number of endpoints: 1 | Descriptor Type: 5 | EP Address: 129 | \r\n\r\n\r\nNumber of possible configurations: 1   Device Class: 0  VendorID: 1500   ProductID: 43037\r\nVendor:   Product:   Serial Number: AA8BF02FAUF8PRH6\r\nInterfaces: 1   Interface Number: 0 | Number of endpoints: 2 | Descriptor Type: 5 | EP Address: 129 | Descriptor Type: 5 | EP Address: 2 | \r\n\r\n\r\nNumber of possible configurations: 1   Device Class: 9  VendorID: 32903   ProductID: 36\r\nVendor:   Product:   Serial Number: \r\nInterfaces: 1   Interface Number: 0 | Number of endpoints: 1 | Descriptor Type: 5 | EP Address: 129 | \r\n\r\n\r\nNumber of possible configurations: 1   Device Class: 9  VendorID: 7531   ProductID: 2\r\nVendor:   Product: EHCI Host Controller  Serial Number: 0000:00:1a.0\r\nInterfaces: 1   Interface Number: 0 | Number of endpoints: 1 | Descriptor Type: 5 | EP Address: 129 | \r\n\r\n\r\nNumber of possible configurations: 1   Device Class: 9  VendorID: 7531   ProductID: 3\r\nVendor:   Product: Linux 4.13.0-41-generic xhci-hcd  Serial Number: 0000:00:14.0\r\nInterfaces: 1   Interface Number: 0 | Number of endpoints: 1 | Descriptor Type: 5 | EP Address: 129 | \r\n\r\n\r\nNumber of possible configurations: 1   Device Class: 0  VendorID: 1309   ProductID: 2\r\nVendor:   Product: Back-UPS RS 1000G FW:869.L3 .D USB FW:L3   Serial Number: 3B1241X11465  \r\nInterfaces: 1   Interface Number: 0 | Number of endpoints: 1 | Descriptor Type: 5 | EP Address: 129 | \r\n\r\n\r\nNumber of possible configurations: 1   Device Class: 9  VendorID: 7531   ProductID: 2\r\nVendor:   Product: xHCI Host Controller  Serial Number: 0000:00:14.0\r\nInterfaces: 1   Interface Number: 0 | Number of endpoints: 1 | Descriptor Type: 5 | EP Address: 129 | \r\n\r\n<\/pre>\n<p>It managed to find my Back-UPS, not who makes it, but, that device was at least polite enough to say what it was. Sadly, I also had a USB mouse and a Lexar thumb drive plugged in. You don&#8217;t have to take my word for it.<\/p>\n<pre>roland@roland-I5-HP-Compaq-8300-Elite-SFF-PC:~$ lsusb\r\nBus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub\r\nBus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub\r\nBus 001 Device 004: ID 093a:2510 <strong>Pixart Imaging, Inc. Optical Mouse<\/strong>\r\nBus 001 Device 003: ID 05dc:a81d <strong>Lexar Media, Inc.<\/strong> \r\nBus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub\r\nBus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub\r\nBus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub\r\nBus 003 Device 002: ID 051d:0002 American Power Conversion Uninterruptible Power Supply\r\nBus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub\r\nroland@roland-I5-HP-Compaq-8300-Elite-SFF-PC:~$ \r\n<\/pre>\n<p>Now, lsusb ultimately uses the usbutils package which provides names_vendor(), names_product() and a host of other handy functions. Sadly this is not cross platform. I really wish our cross platform usb library (libusb) would import one tiny piece of usbutils. <a href=\"http:\/\/www.linux-usb.org\/usb.ids\">The list<\/a>. Thankfully, it exists on-line. We can kind-of-sort-of make a cross platform Qt friendly method of using this information. When running on Linux there is a 99% chance the file usb.ids is local to our machine. We can also add the fallback capability of reaching out to the Web and pulling the most current version down . . . assuming we have an Internet connection.<\/p>\n<p>I want to cut and paste a tiny snippet of this file so you have a frame of reference for our ongoing discussion.<\/p>\n<p>&nbsp;<\/p>\n<pre># Vendors, devices and interfaces. Please keep sorted.\r\n\r\n# Syntax:\r\n# vendor  vendor_name\r\n#\tdevice  device_name\t\t\t\t&lt;-- single tab\r\n#\t\tinterface  interface_name\t\t&lt;-- two tabs\r\n\r\n0001  Fry's Electronics\r\n\t7778  Counterfeit flash drive [Kingston]\r\n0002  Ingram\r\n0003  Club Mac\r\n0004  Nebraska Furniture Mart\r\n0011  Unknown\r\n\t7788  counterfeit flash drive\r\n0053  Planex\r\n\t5301  GW-US54ZGL 802.11bg\r\n0078  Microntek\r\n\t0006  Joystick\r\n0079  DragonRise Inc.\r\n\t0006  PC TWIN SHOCK Gamepad\r\n\t0011  Gamepad\r\n\t1800  Mayflash Wii U Pro Game Controller Adapter [DirectInput]\r\n\t181b  Venom Arcade Joystick\r\n\t1843  Mayflash GameCube Controller Adapter\r\n\t1844  Mayflash GameCube Controller\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>This is a tab and space delimited text file. When we directly pull it down from the Web we will most likely also get a wee bit of HTML. What really turned me off about usbutils is looking at some of the code to fetch the names. This entire file gets parsed into C structures which use a hash for access. I understand, they were working with C and took the minimalist approach, but, what we have here is known as a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Control_break\">control break report<\/a>. Our job is to parse the report in order to get the data in a usable format. Had the usbutils routines parsed this into a pair of indexed files either in memory or written to \/tmp, I would have been more inclined to replicate their works.<\/p>\n<p>If you wish to read up on indexed files with multi-typed records and segmented keys, feel free to find a copy of <a href=\"http:\/\/www.theminimumyouneedtoknow.com\/app_book.html\">this book<\/a> and read it. You may wish to believe &#8220;Oh, I only write Qt code on Linux\/Windows, I don&#8217;t need to know any of that stuff.&#8221; Well young grasshopper, you really do need to know that stuff so you can understand why much of the stuff done in this world is shit.<\/p>\n<p>Take a good look at the output again.<\/p>\n<p>The text file master approach got more vendor names correct, but, take a good look at the UPS line. It didn&#8217;t get the model correct. Any &#8220;list&#8221; approach is going to be a &#8220;much of the time&#8221; solution. What I mean by that is &#8220;much of the time it will have something you can use, just don&#8217;t expect it to be too useful.&#8221; Even if a list were to contain absolutely perfect information for every device on it, there is still going to be a lag between a new device coming out and its information getting on the list.<\/p>\n<p>Relying on a vendor to actually store all needed information in the device __and__ respond to a query with said information is, well, on a good day, fool-hardy. Electronics are in a race to the bottom. People buy the cheapest piece of shit and expect it to work like the high end stuff. Everyone is cutting corners and taking short cuts. I&#8217;m not surprised this generic mouse I got from Staples didn&#8217;t bother to identify itself, but, Lexar is a really big name in thumb drives. Usually their drives come pre-loaded with tons of crap software so a person has to know how to format a thumb drive before they can use it. I was shocked to see it didn&#8217;t bother to answer the query.<\/p>\n<p>So, as time allows, the next step is to come up with our own Qt based class to obtain vendor and device name information. While I would like it to be stand alone, I haven&#8217;t yet noodled on it enough to make the function work. The ideal functionality would be to have the class use both the list _and_ the query. That means a coupling though.<\/p>\n<p>Kids today would also try to come up with a QObject based class to hold both vendorID and ProductID with comparison methods so it could be used as the key for a QMap. The proper method of handling this kind of data is with a database. Either in memory or in a temp directory. A simple SQLite thing.<\/p>\n<p>Hopefully you spend some time looking at that list. It contains many thing one could bump into. To start with it isn&#8217;t a single list.<\/p>\n<p>&nbsp;<\/p>\n<pre># Syntax:\r\n# C class  class_name\r\n#\tsubclass  subclass_name\t\t\t&lt;-- single tab\r\n#\t\tprotocol  protocol_name\t\t&lt;-- two tabs\r\n\r\nC 00  (Defined at Interface level)\r\nC 01  Audio\r\n\t01  Control Device\r\n\t02  Streaming\r\n\t03  MIDI Streaming\r\nC 02  Communications\r\n\t01  Direct Line\r\n\t02  Abstract (modem)\r\n\t\t00  None\r\n\t\t01  AT-commands (v.25ter)\r\n\t\t02  AT-commands (PCCA101)\r\n\t\t03  AT-commands (PCCA101 + wakeup)\r\n\t\t04  AT-commands (GSM)\r\n\t\t05  AT-commands (3G)\r\n\t\t06  AT-commands (CDMA)\r\n\t\tfe  Defined by command set descriptor\r\n\t\tff  Vendor Specific (MSFT RNDIS?)\r\n\r\n...\r\n\r\n# List of Audio Class Terminal Types\r\n\r\n# Syntax:\r\n# AT terminal_type  terminal_type_name\r\n\r\nAT 0100  USB Undefined\r\nAT 0101  USB Streaming\r\nAT 01ff  USB Vendor Specific\r\nAT 0200  Input Undefined\r\nAT 0201  Microphone\r\nAT 0202  Desktop Microphone\r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>It goes on and on.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today&#8217;s post will be the first of at least two posts about identifying your USB device. I started by adding the following code. out &lt;&lt; &#8220;ProductID: &#8221; &lt;&lt; desc.idProduct &lt;&lt; endl; r0_status = libusb_open(dev, &amp;hHandle); if (r0_status != LIBUSB_SUCCESS) { out &lt;&lt; &#8220;Error &#8221; &lt;&lt; r0_status &lt;&lt; &#8221; opening USB device. Error text: &#8221; &lt;&lt; libusb_error_name(r0_status) &lt;&lt; endl; } else { unsigned char serialNumber[255] = { }; unsigned char vendorName[1024] = { }; unsigned char &hellip; <a title=\"Qt and USB &#8211; Pt. 2\" class=\"bnm-read-more\" href=\"https:\/\/www.logikalsolutions.com\/wordpress\/information-technology\/qt-and-usb-pt-2\/\"><span class=\"screen-reader-text\">Qt and USB &#8211; Pt. 2<\/span>Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1309,3,4],"tags":[1608,53,159,1607,1618],"class_list":["post-2810","post","type-post","status-publish","format-standard","hentry","category-experience","category-information-technology","category-thank-you-sir-may-i-have-another","tag-libusb","tag-linux","tag-qt","tag-usb","tag-usbutils","bnm-entry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Qt and USB - Pt. 2 &#8211; Logikal Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.logikalsolutions.com\/wordpress\/information-technology\/qt-and-usb-pt-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Qt and USB - Pt. 2 &#8211; Logikal Blog\" \/>\n<meta property=\"og:description\" content=\"Today&#8217;s post will be the first of at least two posts about identifying your USB device. I started by adding the following code. out &lt;&lt; &quot;ProductID: &quot; &lt;&lt; desc.idProduct &lt;&lt; endl; r0_status = libusb_open(dev, &amp;hHandle); if (r0_status != LIBUSB_SUCCESS) { out &lt;&lt; &quot;Error &quot; &lt;&lt; r0_status &lt;&lt; &quot; opening USB device. Error text: &quot; &lt;&lt; libusb_error_name(r0_status) &lt;&lt; endl; } else { unsigned char serialNumber[255] = { }; unsigned char vendorName[1024] = { }; unsigned char &hellip; Qt and USB &#8211; Pt. 2Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.logikalsolutions.com\/wordpress\/information-technology\/qt-and-usb-pt-2\/\" \/>\n<meta property=\"og:site_name\" content=\"Logikal Blog\" \/>\n<meta property=\"article:published_time\" content=\"2018-05-09T22:01:54+00:00\" \/>\n<meta name=\"author\" content=\"seasoned_geek\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"seasoned_geek\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/information-technology\\\/qt-and-usb-pt-2\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/information-technology\\\/qt-and-usb-pt-2\\\/\"},\"author\":{\"name\":\"seasoned_geek\",\"@id\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/#\\\/schema\\\/person\\\/c077f770ade13de7faaf616c3eac6842\"},\"headline\":\"Qt and USB &#8211; Pt. 2\",\"datePublished\":\"2018-05-09T22:01:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/information-technology\\\/qt-and-usb-pt-2\\\/\"},\"wordCount\":936,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/#\\\/schema\\\/person\\\/c077f770ade13de7faaf616c3eac6842\"},\"keywords\":[\"libusb\",\"Linux\",\"Qt\",\"usb\",\"usbutils\"],\"articleSection\":[\"Experience\",\"Information Technology\",\"Thank You Sir May I Have Another\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/information-technology\\\/qt-and-usb-pt-2\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/information-technology\\\/qt-and-usb-pt-2\\\/\",\"url\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/information-technology\\\/qt-and-usb-pt-2\\\/\",\"name\":\"Qt and USB - Pt. 2 &#8211; Logikal Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/#website\"},\"datePublished\":\"2018-05-09T22:01:54+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/information-technology\\\/qt-and-usb-pt-2\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/information-technology\\\/qt-and-usb-pt-2\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/information-technology\\\/qt-and-usb-pt-2\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Qt and USB &#8211; Pt. 2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/#website\",\"url\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/\",\"name\":\"Logikal Blog\",\"description\":\"No part of this site may be used by AI without first purchasing that right\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/#\\\/schema\\\/person\\\/c077f770ade13de7faaf616c3eac6842\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/#\\\/schema\\\/person\\\/c077f770ade13de7faaf616c3eac6842\",\"name\":\"seasoned_geek\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ae9adac14079d84b909e635d7af986fe4568053af4fd9ff8d4109298c392493e?s=96&d=mm&r=r\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ae9adac14079d84b909e635d7af986fe4568053af4fd9ff8d4109298c392493e?s=96&d=mm&r=r\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ae9adac14079d84b909e635d7af986fe4568053af4fd9ff8d4109298c392493e?s=96&d=mm&r=r\",\"caption\":\"seasoned_geek\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ae9adac14079d84b909e635d7af986fe4568053af4fd9ff8d4109298c392493e?s=96&d=mm&r=r\"},\"description\":\"Roland Hughes started his IT career in the early 1980s. He quickly became a consultant and president of Logikal Solutions, a software consulting firm specializing in OpenVMS application and C++\\\/Qt touchscreen\\\/embedded Linux development. Early in his career he became involved in what is now called cross platform development. Given the dearth of useful books on the subject he ventured into the world of professional author in 1995 writing the first of the \\\"Zinc It!\\\" book series for John Gordon Burke Publisher, Inc. A decade later he released a massive (nearly 800 pages) tome \\\"The Minimum You Need to Know to Be an OpenVMS Application Developer\\\" which tried to encapsulate the essential skills gained over what was nearly a 20 year career at that point. From there \\\"The Minimum You Need to Know\\\" book series was born. Three years later he wrote his first novel \\\"Infinite Exposure\\\" which got much notice from people involved in the banking and financial security worlds. Some of the attacks predicted in that book have since come to pass. While it was not originally intended to be a trilogy, it became the first book of \\\"The Earth That Was\\\" trilogy: Infinite Exposure Lesedi - The Greatest Lie Ever Told John Smith - Last Known Survivor of the Microsoft Wars When he is not consulting Roland Hughes posts about technology and sometimes politics on his blog. He also has regularly scheduled Sunday posts appearing on the Interesting Authors blog.\",\"sameAs\":[\"https:\\\/\\\/theminimumyouneedtoknow.com\"],\"url\":\"https:\\\/\\\/www.logikalsolutions.com\\\/wordpress\\\/author\\\/seasoned_geek\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Qt and USB - Pt. 2 &#8211; Logikal Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.logikalsolutions.com\/wordpress\/information-technology\/qt-and-usb-pt-2\/","og_locale":"en_US","og_type":"article","og_title":"Qt and USB - Pt. 2 &#8211; Logikal Blog","og_description":"Today&#8217;s post will be the first of at least two posts about identifying your USB device. I started by adding the following code. out &lt;&lt; \"ProductID: \" &lt;&lt; desc.idProduct &lt;&lt; endl; r0_status = libusb_open(dev, &amp;hHandle); if (r0_status != LIBUSB_SUCCESS) { out &lt;&lt; \"Error \" &lt;&lt; r0_status &lt;&lt; \" opening USB device. Error text: \" &lt;&lt; libusb_error_name(r0_status) &lt;&lt; endl; } else { unsigned char serialNumber[255] = { }; unsigned char vendorName[1024] = { }; unsigned char &hellip; Qt and USB &#8211; Pt. 2Read more","og_url":"https:\/\/www.logikalsolutions.com\/wordpress\/information-technology\/qt-and-usb-pt-2\/","og_site_name":"Logikal Blog","article_published_time":"2018-05-09T22:01:54+00:00","author":"seasoned_geek","twitter_card":"summary_large_image","twitter_misc":{"Written by":"seasoned_geek","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.logikalsolutions.com\/wordpress\/information-technology\/qt-and-usb-pt-2\/#article","isPartOf":{"@id":"https:\/\/www.logikalsolutions.com\/wordpress\/information-technology\/qt-and-usb-pt-2\/"},"author":{"name":"seasoned_geek","@id":"https:\/\/www.logikalsolutions.com\/wordpress\/#\/schema\/person\/c077f770ade13de7faaf616c3eac6842"},"headline":"Qt and USB &#8211; Pt. 2","datePublished":"2018-05-09T22:01:54+00:00","mainEntityOfPage":{"@id":"https:\/\/www.logikalsolutions.com\/wordpress\/information-technology\/qt-and-usb-pt-2\/"},"wordCount":936,"commentCount":0,"publisher":{"@id":"https:\/\/www.logikalsolutions.com\/wordpress\/#\/schema\/person\/c077f770ade13de7faaf616c3eac6842"},"keywords":["libusb","Linux","Qt","usb","usbutils"],"articleSection":["Experience","Information Technology","Thank You Sir May I Have Another"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.logikalsolutions.com\/wordpress\/information-technology\/qt-and-usb-pt-2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.logikalsolutions.com\/wordpress\/information-technology\/qt-and-usb-pt-2\/","url":"https:\/\/www.logikalsolutions.com\/wordpress\/information-technology\/qt-and-usb-pt-2\/","name":"Qt and USB - Pt. 2 &#8211; Logikal Blog","isPartOf":{"@id":"https:\/\/www.logikalsolutions.com\/wordpress\/#website"},"datePublished":"2018-05-09T22:01:54+00:00","breadcrumb":{"@id":"https:\/\/www.logikalsolutions.com\/wordpress\/information-technology\/qt-and-usb-pt-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.logikalsolutions.com\/wordpress\/information-technology\/qt-and-usb-pt-2\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.logikalsolutions.com\/wordpress\/information-technology\/qt-and-usb-pt-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.logikalsolutions.com\/wordpress\/"},{"@type":"ListItem","position":2,"name":"Qt and USB &#8211; Pt. 2"}]},{"@type":"WebSite","@id":"https:\/\/www.logikalsolutions.com\/wordpress\/#website","url":"https:\/\/www.logikalsolutions.com\/wordpress\/","name":"Logikal Blog","description":"No part of this site may be used by AI without first purchasing that right","publisher":{"@id":"https:\/\/www.logikalsolutions.com\/wordpress\/#\/schema\/person\/c077f770ade13de7faaf616c3eac6842"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.logikalsolutions.com\/wordpress\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.logikalsolutions.com\/wordpress\/#\/schema\/person\/c077f770ade13de7faaf616c3eac6842","name":"seasoned_geek","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/ae9adac14079d84b909e635d7af986fe4568053af4fd9ff8d4109298c392493e?s=96&d=mm&r=r","url":"https:\/\/secure.gravatar.com\/avatar\/ae9adac14079d84b909e635d7af986fe4568053af4fd9ff8d4109298c392493e?s=96&d=mm&r=r","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ae9adac14079d84b909e635d7af986fe4568053af4fd9ff8d4109298c392493e?s=96&d=mm&r=r","caption":"seasoned_geek"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/ae9adac14079d84b909e635d7af986fe4568053af4fd9ff8d4109298c392493e?s=96&d=mm&r=r"},"description":"Roland Hughes started his IT career in the early 1980s. He quickly became a consultant and president of Logikal Solutions, a software consulting firm specializing in OpenVMS application and C++\/Qt touchscreen\/embedded Linux development. Early in his career he became involved in what is now called cross platform development. Given the dearth of useful books on the subject he ventured into the world of professional author in 1995 writing the first of the \"Zinc It!\" book series for John Gordon Burke Publisher, Inc. A decade later he released a massive (nearly 800 pages) tome \"The Minimum You Need to Know to Be an OpenVMS Application Developer\" which tried to encapsulate the essential skills gained over what was nearly a 20 year career at that point. From there \"The Minimum You Need to Know\" book series was born. Three years later he wrote his first novel \"Infinite Exposure\" which got much notice from people involved in the banking and financial security worlds. Some of the attacks predicted in that book have since come to pass. While it was not originally intended to be a trilogy, it became the first book of \"The Earth That Was\" trilogy: Infinite Exposure Lesedi - The Greatest Lie Ever Told John Smith - Last Known Survivor of the Microsoft Wars When he is not consulting Roland Hughes posts about technology and sometimes politics on his blog. He also has regularly scheduled Sunday posts appearing on the Interesting Authors blog.","sameAs":["https:\/\/theminimumyouneedtoknow.com"],"url":"https:\/\/www.logikalsolutions.com\/wordpress\/author\/seasoned_geek\/"}]}},"_links":{"self":[{"href":"https:\/\/www.logikalsolutions.com\/wordpress\/wp-json\/wp\/v2\/posts\/2810","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.logikalsolutions.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.logikalsolutions.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.logikalsolutions.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.logikalsolutions.com\/wordpress\/wp-json\/wp\/v2\/comments?post=2810"}],"version-history":[{"count":0,"href":"https:\/\/www.logikalsolutions.com\/wordpress\/wp-json\/wp\/v2\/posts\/2810\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.logikalsolutions.com\/wordpress\/wp-json\/wp\/v2\/media?parent=2810"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.logikalsolutions.com\/wordpress\/wp-json\/wp\/v2\/categories?post=2810"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.logikalsolutions.com\/wordpress\/wp-json\/wp\/v2\/tags?post=2810"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}