{"id":11,"date":"2008-09-15T15:25:23","date_gmt":"2008-09-15T05:55:23","guid":{"rendered":"http:\/\/www.clearchain.com\/blog\/?p=11"},"modified":"2010-01-22T08:19:14","modified_gmt":"2010-01-21T22:49:14","slug":"resetting-the-usb-bus-under-linux","status":"publish","type":"post","link":"https:\/\/www.clearchain.com\/blog\/posts\/resetting-the-usb-bus-under-linux","title":{"rendered":"Resetting the USB Bus under linux"},"content":{"rendered":"<p>Today Snappy, the little photo box<a title=\"Wearable Computer Lab\" href=\"http:\/\/wearables.unisa.edu.au\"> we<\/a> have taking photos of the new Bruce Lab, broke again. Hence I quickly came up with a way of resetting the USB device under linux based on libusb. Sadly whilst I can confirm this does reset the device gphoto2 still doesn&#8217;t like our little Canon Ixus 400 and we still get timeouts after about 12 hours of taking photos &#8211; 1 photo every 2 minutes. Below is the hack of a program I used.<\/p>\n<p>To compile use: gcc -o outputname resetusb.c -lusb<\/p>\n<pre>#include &lt;stdio.h&gt;\r\n#include &lt;usb.h&gt;\r\n\r\nint main(void)\r\n{\r\n      struct usb_bus *busses;\r\n      usb_init();\r\n      usb_find_busses();\r\n      usb_find_devices();\r\n      busses = usb_get_busses();\r\n      struct usb_bus *bus;\r\n      int c, i, a;\r\n      \/* ... *\/\r\n      for (bus = busses; bus; bus = bus-&gt;next) {\r\n        struct usb_device *dev;\r\n        int val;\r\n        usb_dev_handle *junk;\r\n        for (dev = bus-&gt;devices; dev; dev = dev-&gt;next) {\r\n          char buf[1024];\r\n          junk = usb_open ( dev );\r\n          usb_get_string_simple(junk,2,buf,1023);\r\n          if ( junk == NULL ){\r\n            printf(\"Can't open %p (%s)\\n\", dev, buf );\r\n          } else {\r\n            val = usb_reset(junk);\r\n            printf( \"reset %p %d (%s)\\n\", dev, val, buf );\r\n          }\r\n          usb_close(junk);\r\n        }\r\n      }\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Today Snappy, the little photo box we have taking photos of the new Bruce Lab, broke again. Hence I quickly came up with a way of resetting the USB device under linux based on libusb. Sadly whilst I can confirm this does reset the device gphoto2 still doesn&#8217;t like our little Canon Ixus 400 and<a href=\"https:\/\/www.clearchain.com\/blog\/posts\/resetting-the-usb-bus-under-linux\"> <font size=-2>[..more..]<\/font><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[278,177,277,276],"class_list":["post-11","post","type-post","status-publish","format-standard","hentry","category-unisa","tag-bus","tag-linux","tag-reset","tag-usb"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Resetting the USB Bus under linux - ClearChain<\/title>\n<meta name=\"description\" content=\"Today Snappy, the little photo box we have taking photos of the new Bruce Lab, broke again. Hence I quickly came up with a way of resetting the USB device\" \/>\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.clearchain.com\/blog\/posts\/resetting-the-usb-bus-under-linux\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Benjamin Close\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.clearchain.com\/blog\/posts\/resetting-the-usb-bus-under-linux#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.clearchain.com\/blog\/posts\/resetting-the-usb-bus-under-linux\"},\"author\":{\"name\":\"Benjamin Close\",\"@id\":\"https:\/\/www.clearchain.com\/blog\/#\/schema\/person\/aef6faa2c32188398139db9270ca1c98\"},\"headline\":\"Resetting the USB Bus under linux\",\"datePublished\":\"2008-09-15T05:55:23+00:00\",\"dateModified\":\"2010-01-21T22:49:14+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.clearchain.com\/blog\/posts\/resetting-the-usb-bus-under-linux\"},\"wordCount\":93,\"commentCount\":17,\"keywords\":[\"bus\",\"linux\",\"reset\",\"usb\"],\"articleSection\":[\"UniSA\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.clearchain.com\/blog\/posts\/resetting-the-usb-bus-under-linux#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.clearchain.com\/blog\/posts\/resetting-the-usb-bus-under-linux\",\"url\":\"https:\/\/www.clearchain.com\/blog\/posts\/resetting-the-usb-bus-under-linux\",\"name\":\"Resetting the USB Bus under linux - ClearChain\",\"isPartOf\":{\"@id\":\"https:\/\/www.clearchain.com\/blog\/#website\"},\"datePublished\":\"2008-09-15T05:55:23+00:00\",\"dateModified\":\"2010-01-21T22:49:14+00:00\",\"author\":{\"@id\":\"https:\/\/www.clearchain.com\/blog\/#\/schema\/person\/aef6faa2c32188398139db9270ca1c98\"},\"description\":\"Today Snappy, the little photo box we have taking photos of the new Bruce Lab, broke again. Hence I quickly came up with a way of resetting the USB device\",\"breadcrumb\":{\"@id\":\"https:\/\/www.clearchain.com\/blog\/posts\/resetting-the-usb-bus-under-linux#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.clearchain.com\/blog\/posts\/resetting-the-usb-bus-under-linux\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.clearchain.com\/blog\/posts\/resetting-the-usb-bus-under-linux#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.clearchain.com\/blog\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Resetting the USB Bus under linux\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.clearchain.com\/blog\/#website\",\"url\":\"https:\/\/www.clearchain.com\/blog\/\",\"name\":\"ClearChain\",\"description\":\"-= Daily Happenings =-\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.clearchain.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.clearchain.com\/blog\/#\/schema\/person\/aef6faa2c32188398139db9270ca1c98\",\"name\":\"Benjamin Close\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.clearchain.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/19dca0aa372edfa901b93c556dfda2e78ad4434558fe4d139598e086315d714a?s=96&d=mm&r=pg\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/19dca0aa372edfa901b93c556dfda2e78ad4434558fe4d139598e086315d714a?s=96&d=mm&r=pg\",\"caption\":\"Benjamin Close\"},\"sameAs\":[\"http:\/\/www.clearchain.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Resetting the USB Bus under linux - ClearChain","description":"Today Snappy, the little photo box we have taking photos of the new Bruce Lab, broke again. Hence I quickly came up with a way of resetting the USB device","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.clearchain.com\/blog\/posts\/resetting-the-usb-bus-under-linux","twitter_misc":{"Written by":"Benjamin Close","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.clearchain.com\/blog\/posts\/resetting-the-usb-bus-under-linux#article","isPartOf":{"@id":"https:\/\/www.clearchain.com\/blog\/posts\/resetting-the-usb-bus-under-linux"},"author":{"name":"Benjamin Close","@id":"https:\/\/www.clearchain.com\/blog\/#\/schema\/person\/aef6faa2c32188398139db9270ca1c98"},"headline":"Resetting the USB Bus under linux","datePublished":"2008-09-15T05:55:23+00:00","dateModified":"2010-01-21T22:49:14+00:00","mainEntityOfPage":{"@id":"https:\/\/www.clearchain.com\/blog\/posts\/resetting-the-usb-bus-under-linux"},"wordCount":93,"commentCount":17,"keywords":["bus","linux","reset","usb"],"articleSection":["UniSA"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.clearchain.com\/blog\/posts\/resetting-the-usb-bus-under-linux#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.clearchain.com\/blog\/posts\/resetting-the-usb-bus-under-linux","url":"https:\/\/www.clearchain.com\/blog\/posts\/resetting-the-usb-bus-under-linux","name":"Resetting the USB Bus under linux - ClearChain","isPartOf":{"@id":"https:\/\/www.clearchain.com\/blog\/#website"},"datePublished":"2008-09-15T05:55:23+00:00","dateModified":"2010-01-21T22:49:14+00:00","author":{"@id":"https:\/\/www.clearchain.com\/blog\/#\/schema\/person\/aef6faa2c32188398139db9270ca1c98"},"description":"Today Snappy, the little photo box we have taking photos of the new Bruce Lab, broke again. Hence I quickly came up with a way of resetting the USB device","breadcrumb":{"@id":"https:\/\/www.clearchain.com\/blog\/posts\/resetting-the-usb-bus-under-linux#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.clearchain.com\/blog\/posts\/resetting-the-usb-bus-under-linux"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.clearchain.com\/blog\/posts\/resetting-the-usb-bus-under-linux#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.clearchain.com\/blog"},{"@type":"ListItem","position":2,"name":"Resetting the USB Bus under linux"}]},{"@type":"WebSite","@id":"https:\/\/www.clearchain.com\/blog\/#website","url":"https:\/\/www.clearchain.com\/blog\/","name":"ClearChain","description":"-= Daily Happenings =-","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.clearchain.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.clearchain.com\/blog\/#\/schema\/person\/aef6faa2c32188398139db9270ca1c98","name":"Benjamin Close","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.clearchain.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/19dca0aa372edfa901b93c556dfda2e78ad4434558fe4d139598e086315d714a?s=96&d=mm&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/19dca0aa372edfa901b93c556dfda2e78ad4434558fe4d139598e086315d714a?s=96&d=mm&r=pg","caption":"Benjamin Close"},"sameAs":["http:\/\/www.clearchain.com"]}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.clearchain.com\/blog\/wp-json\/wp\/v2\/posts\/11","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.clearchain.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.clearchain.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.clearchain.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.clearchain.com\/blog\/wp-json\/wp\/v2\/comments?post=11"}],"version-history":[{"count":4,"href":"https:\/\/www.clearchain.com\/blog\/wp-json\/wp\/v2\/posts\/11\/revisions"}],"predecessor-version":[{"id":679,"href":"https:\/\/www.clearchain.com\/blog\/wp-json\/wp\/v2\/posts\/11\/revisions\/679"}],"wp:attachment":[{"href":"https:\/\/www.clearchain.com\/blog\/wp-json\/wp\/v2\/media?parent=11"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.clearchain.com\/blog\/wp-json\/wp\/v2\/categories?post=11"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.clearchain.com\/blog\/wp-json\/wp\/v2\/tags?post=11"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}