{"id":3887,"date":"2018-08-02T11:47:06","date_gmt":"2018-08-02T18:47:06","guid":{"rendered":"https:\/\/www.circuitspecialists.com\/blog\/?p=3887"},"modified":"2021-02-11T13:58:30","modified_gmt":"2021-02-11T20:58:30","slug":"reverse-engineering-communication-protocols-part-2-software-writing","status":"publish","type":"post","link":"https:\/\/www.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-2-software-writing\/","title":{"rendered":"Reverse Engineering Communication Protocols (Part 2: Software Writing)"},"content":{"rendered":"<p>To summarize where we <a href=\"https:\/\/www.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-1-reverse-engineering\/\">left off<\/a>, we have the control scheme for the device, but no way to easily control it, we need a control algorithm.<\/p>\n<p>First we must decide on a programming language. In these types of scenarios I prefer to use python, for a few reasons. The few things I&#8217;ve done with python, -which seems to be growing at an exponential rate for me lately- it&#8217;s easier to implement and test a design. I know python is extremely slow compared to C, C++, or even Java, but it&#8217;s 100% portable code, and if I had to guess my time efficiency is 10:1 python to cpp.<\/p>\n<p>My goal for a control scheme was to have a single class for the power supply object, that way later on electronic loads could be easily added. The second thing I needed was some type of control loop, where I could give it a set of parameters, and it would continuingly send those commands to the unit. I also wanted to something that could essentially &#8216;auto-find&#8217; the device on the USB bus rather than me having to manually specify the port and settings each time. That&#8217;s where I used pyusb, and pyserial packages. Since I&#8217;m using windows, I use the device manager to look up in the details tab-&gt;Hardware Ids, which displays both the vendor id, and product id. By using these, I can have the program auto find the device each time I plug it in. Another benefit of going this route is the possibility to create a single user interface, but a backend process that auto configures based on the device being used.<\/p>\n<p>If you examine the csi305db.py file you&#8217;ll see the device description didn&#8217;t change much if at all from that control scheme prototype. Through instantiation it tries to find the device. You set the parameters through a function, and control the device with an unending &#8216;control&#8217; loop. I then continued to build on that structure trying to keep the power supply object monolithic so that I could add more devices easily, and electronic loads at a later time. With how many support calls I&#8217;ve dealt with this issue, it&#8217;s nice to be able to finally provide a solution.<\/p>\n<p>When I finally finished the script, and the device was working, I then moved on to the PPS2116A. I used many of the same methods as previously referenced, with once exception. Hantek provides a SDK programming guide that helped to implement all the necessary functions. Very interestingly, the PPS used a very similar control scheme to the csi305db at least in terms of the string. The difference being it used a single string series for each set of parameters, thereby not needing a control loop. As an example, to set the voltage send &#8216;su0000\\r\\n&#8217;, and current send &#8216;si0000\\r\\n&#8217;. The sdk guide came in handy considering there were many more functions such as output control, measure voltage, etc showing how much more sophisticated the PPS was over the 305db.<\/p>\n<p>The last hill to climb was the electronic load, and the automatic control scheme&#8230;..Read <a href=\"https:\/\/www.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-3-true-usability\/\">third article<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>To summarize where we left off, we have the control scheme for the device, but no way to easily control<\/p>\n","protected":false},"author":5269,"featured_media":5029,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"colormag_page_layout":"default_layout","footnotes":""},"categories":[1],"tags":[],"class_list":["post-3887","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-all-posts"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.8.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Reverse Engineering Communication Protocols (Part 2: Software Writing) | Simply Smarter Circuitry 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.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-2-software-writing\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Reverse Engineering Communication Protocols (Part 2: Software Writing) | Simply Smarter Circuitry Blog\" \/>\n<meta property=\"og:description\" content=\"To summarize where we left off, we have the control scheme for the device, but no way to easily control\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-2-software-writing\/\" \/>\n<meta property=\"og:site_name\" content=\"Simply Smarter Circuitry Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/CircuitSpecialists\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-08-02T18:47:06+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-02-11T20:58:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2018\/08\/pps2116a-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"1000\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Jake\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@CircuitSpecial\" \/>\n<meta name=\"twitter:site\" content=\"@CircuitSpecial\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jake\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-2-software-writing\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-2-software-writing\/\"},\"author\":{\"name\":\"Jake\",\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/#\/schema\/person\/ce507ab763f120accd0d7ff782270404\"},\"headline\":\"Reverse Engineering Communication Protocols (Part 2: Software Writing)\",\"datePublished\":\"2018-08-02T18:47:06+00:00\",\"dateModified\":\"2021-02-11T20:58:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-2-software-writing\/\"},\"wordCount\":529,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-2-software-writing\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2018\/08\/pps2116a-1.jpg\",\"articleSection\":[\"All Posts\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-2-software-writing\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-2-software-writing\/\",\"url\":\"https:\/\/www.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-2-software-writing\/\",\"name\":\"Reverse Engineering Communication Protocols (Part 2: Software Writing) | Simply Smarter Circuitry Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-2-software-writing\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-2-software-writing\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2018\/08\/pps2116a-1.jpg\",\"datePublished\":\"2018-08-02T18:47:06+00:00\",\"dateModified\":\"2021-02-11T20:58:30+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-2-software-writing\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-2-software-writing\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-2-software-writing\/#primaryimage\",\"url\":\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2018\/08\/pps2116a-1.jpg\",\"contentUrl\":\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2018\/08\/pps2116a-1.jpg\",\"width\":1000,\"height\":1000,\"caption\":\"Blog\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-2-software-writing\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.circuitspecialists.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Reverse Engineering Communication Protocols (Part 2: Software Writing)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/#website\",\"url\":\"https:\/\/www.circuitspecialists.com\/blog\/\",\"name\":\"Simply Smarter Circuitry Blog\",\"description\":\"How To&#039;s, Reviews, and Product News from Circuit Specialists HQ.\",\"publisher\":{\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.circuitspecialists.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/#organization\",\"name\":\"Circuit Specialists\",\"url\":\"https:\/\/www.circuitspecialists.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2016\/03\/csi.jpg\",\"contentUrl\":\"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2016\/03\/csi.jpg\",\"width\":120,\"height\":120,\"caption\":\"Circuit Specialists\"},\"image\":{\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/CircuitSpecialists\/\",\"https:\/\/x.com\/CircuitSpecial\",\"https:\/\/www.youtube.com\/channel\/UCG87WTqDKIqA704uqjumJgg\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/#\/schema\/person\/ce507ab763f120accd0d7ff782270404\",\"name\":\"Jake\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.circuitspecialists.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/0e048b10c132a4ebe114e714e4783f82?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/0e048b10c132a4ebe114e714e4783f82?s=96&r=g\",\"caption\":\"Jake\"},\"url\":\"https:\/\/www.circuitspecialists.com\/blog\/author\/jake\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Reverse Engineering Communication Protocols (Part 2: Software Writing) | Simply Smarter Circuitry 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.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-2-software-writing\/","og_locale":"en_US","og_type":"article","og_title":"Reverse Engineering Communication Protocols (Part 2: Software Writing) | Simply Smarter Circuitry Blog","og_description":"To summarize where we left off, we have the control scheme for the device, but no way to easily control","og_url":"https:\/\/www.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-2-software-writing\/","og_site_name":"Simply Smarter Circuitry Blog","article_publisher":"https:\/\/www.facebook.com\/CircuitSpecialists\/","article_published_time":"2018-08-02T18:47:06+00:00","article_modified_time":"2021-02-11T20:58:30+00:00","og_image":[{"width":1000,"height":1000,"url":"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2018\/08\/pps2116a-1.jpg","type":"image\/jpeg"}],"author":"Jake","twitter_card":"summary_large_image","twitter_creator":"@CircuitSpecial","twitter_site":"@CircuitSpecial","twitter_misc":{"Written by":"Jake","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-2-software-writing\/#article","isPartOf":{"@id":"https:\/\/www.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-2-software-writing\/"},"author":{"name":"Jake","@id":"https:\/\/www.circuitspecialists.com\/blog\/#\/schema\/person\/ce507ab763f120accd0d7ff782270404"},"headline":"Reverse Engineering Communication Protocols (Part 2: Software Writing)","datePublished":"2018-08-02T18:47:06+00:00","dateModified":"2021-02-11T20:58:30+00:00","mainEntityOfPage":{"@id":"https:\/\/www.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-2-software-writing\/"},"wordCount":529,"commentCount":0,"publisher":{"@id":"https:\/\/www.circuitspecialists.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-2-software-writing\/#primaryimage"},"thumbnailUrl":"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2018\/08\/pps2116a-1.jpg","articleSection":["All Posts"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-2-software-writing\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-2-software-writing\/","url":"https:\/\/www.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-2-software-writing\/","name":"Reverse Engineering Communication Protocols (Part 2: Software Writing) | Simply Smarter Circuitry Blog","isPartOf":{"@id":"https:\/\/www.circuitspecialists.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-2-software-writing\/#primaryimage"},"image":{"@id":"https:\/\/www.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-2-software-writing\/#primaryimage"},"thumbnailUrl":"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2018\/08\/pps2116a-1.jpg","datePublished":"2018-08-02T18:47:06+00:00","dateModified":"2021-02-11T20:58:30+00:00","breadcrumb":{"@id":"https:\/\/www.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-2-software-writing\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-2-software-writing\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-2-software-writing\/#primaryimage","url":"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2018\/08\/pps2116a-1.jpg","contentUrl":"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2018\/08\/pps2116a-1.jpg","width":1000,"height":1000,"caption":"Blog"},{"@type":"BreadcrumbList","@id":"https:\/\/www.circuitspecialists.com\/blog\/reverse-engineering-communication-protocols-part-2-software-writing\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.circuitspecialists.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Reverse Engineering Communication Protocols (Part 2: Software Writing)"}]},{"@type":"WebSite","@id":"https:\/\/www.circuitspecialists.com\/blog\/#website","url":"https:\/\/www.circuitspecialists.com\/blog\/","name":"Simply Smarter Circuitry Blog","description":"How To&#039;s, Reviews, and Product News from Circuit Specialists HQ.","publisher":{"@id":"https:\/\/www.circuitspecialists.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.circuitspecialists.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.circuitspecialists.com\/blog\/#organization","name":"Circuit Specialists","url":"https:\/\/www.circuitspecialists.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.circuitspecialists.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2016\/03\/csi.jpg","contentUrl":"https:\/\/www.circuitspecialists.com\/blog\/wp-content\/uploads\/2016\/03\/csi.jpg","width":120,"height":120,"caption":"Circuit Specialists"},"image":{"@id":"https:\/\/www.circuitspecialists.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/CircuitSpecialists\/","https:\/\/x.com\/CircuitSpecial","https:\/\/www.youtube.com\/channel\/UCG87WTqDKIqA704uqjumJgg"]},{"@type":"Person","@id":"https:\/\/www.circuitspecialists.com\/blog\/#\/schema\/person\/ce507ab763f120accd0d7ff782270404","name":"Jake","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.circuitspecialists.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/0e048b10c132a4ebe114e714e4783f82?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0e048b10c132a4ebe114e714e4783f82?s=96&r=g","caption":"Jake"},"url":"https:\/\/www.circuitspecialists.com\/blog\/author\/jake\/"}]}},"_links":{"self":[{"href":"https:\/\/www.circuitspecialists.com\/blog\/wp-json\/wp\/v2\/posts\/3887","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.circuitspecialists.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.circuitspecialists.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.circuitspecialists.com\/blog\/wp-json\/wp\/v2\/users\/5269"}],"replies":[{"embeddable":true,"href":"https:\/\/www.circuitspecialists.com\/blog\/wp-json\/wp\/v2\/comments?post=3887"}],"version-history":[{"count":5,"href":"https:\/\/www.circuitspecialists.com\/blog\/wp-json\/wp\/v2\/posts\/3887\/revisions"}],"predecessor-version":[{"id":3910,"href":"https:\/\/www.circuitspecialists.com\/blog\/wp-json\/wp\/v2\/posts\/3887\/revisions\/3910"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.circuitspecialists.com\/blog\/wp-json\/wp\/v2\/media\/5029"}],"wp:attachment":[{"href":"https:\/\/www.circuitspecialists.com\/blog\/wp-json\/wp\/v2\/media?parent=3887"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.circuitspecialists.com\/blog\/wp-json\/wp\/v2\/categories?post=3887"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.circuitspecialists.com\/blog\/wp-json\/wp\/v2\/tags?post=3887"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}