{"id":7,"date":"2005-08-10T16:39:50","date_gmt":"2005-08-10T20:39:50","guid":{"rendered":"http:\/\/blogs.law.harvard.edu\/dreamseeker\/2005\/08\/10\/reading-data-from-an-usb-input-in"},"modified":"2006-06-11T17:49:15","modified_gmt":"2006-06-11T21:49:15","slug":"reading-data-from-an-usb-input-interrupt-pipe-endpoint","status":"publish","type":"post","link":"https:\/\/archive.blogs.harvard.edu\/dreamseeker\/2005\/08\/10\/reading-data-from-an-usb-input-interrupt-pipe-endpoint\/","title":{"rendered":"Reading data from an USB input interrupt pipe (endpoint)"},"content":{"rendered":"<p><a name='a9'><\/a><\/p>\n<p>Taking the kext file out, the Device was treated as an HID device. I have found two xcode projects which work, HID explorer and HID examples, but I am stuck right now, because these HID projects talk about elements, and USB prober talks about endpoint. I have not yet found what the link is between endpoints and elements.<br \/>\nPutting the kext file back in, I found several xcode projects for the USB, USBPrivateDAtaSample and SimpleUserClient (which still give me error messages) and USBSimple Example which I got to work: I put the vendor and product id, looked for interrupt pipes instead of bulk pipes, and added a synchronous readpipe command.<\/p>\n<p>char gBuffer[8];<\/p>\n<p>UInt32\t numBytesRead;<\/p>\n<p>numBytesRead = sizeof(gBuffer);<\/p>\n<p>err = (*intf)-&gt;ReadPipe(intf, inPipeRef, gBuffer, &amp;numBytesRead);<\/p>\n<p>if (err) printf(&#8220;Unable to perform interrupt read %2x %4x %4x\\n&#8221;,err_get_system(err),err_get_sub(err),err_get_code(err));<\/p>\n<p>for (i = 1; i USElessthanSYMBOLHERE numBytesRead; i++) printf(&#8220;Read %x (%ld bytes) from interrupt endpoint\\n&#8221;, gBuffer[i],gBuffer[0]);<\/p>\n<p>(the first byte of data is a number, 7 usually, the rest are characters)<\/p>\n<p>The key to success was being able to interpret the error message! I read how to print and interprete the error code ox38 ox00 ox2e8<\/p>\n<p>http:\/\/developer.apple.com\/qa\/qa2001\/qa1075.html<\/p>\n<p>looking up in IOreturn.h, 0x028 is data overrun!<\/p>\n<p>#define kIOReturnOverrun iokit_common_err(0x2e8) \/\/<\/p>\n<p>The other key to success was the apple USB forum site who helped with the error code<\/p>\n<p>http:\/\/lists.apple.com\/archives\/Usb<\/p>\n<p>where I was told that I should try reading at least maxPacketSize bytes, where maxPacketSize bytes is a USB prober info on the enpoint pipe. So I tried with a buffer size of 8, instead of 64 or 2, and bingo, the error message went away, and I was reading data!<\/p>\n<p>Of course it helps that I have the PC opensource code to figure out what to do with the data!!!!<\/p>\n<p>So a bright day, I talked to my device. Now I have to learn how to access it asynchronously.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Taking the kext file out, the Device was treated as an HID device. I have found two xcode projects which work, HID explorer and HID examples, but I am stuck right now, because these HID projects talk about elements, and USB prober talks about endpoint. I have not yet found what the link is between [&hellip;]<\/p>\n","protected":false},"author":130,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[616],"tags":[],"class_list":["post-7","post","type-post","status-publish","format-standard","hentry","category-usb"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/archive.blogs.harvard.edu\/dreamseeker\/wp-json\/wp\/v2\/posts\/7","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/archive.blogs.harvard.edu\/dreamseeker\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/archive.blogs.harvard.edu\/dreamseeker\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/dreamseeker\/wp-json\/wp\/v2\/users\/130"}],"replies":[{"embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/dreamseeker\/wp-json\/wp\/v2\/comments?post=7"}],"version-history":[{"count":0,"href":"https:\/\/archive.blogs.harvard.edu\/dreamseeker\/wp-json\/wp\/v2\/posts\/7\/revisions"}],"wp:attachment":[{"href":"https:\/\/archive.blogs.harvard.edu\/dreamseeker\/wp-json\/wp\/v2\/media?parent=7"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/dreamseeker\/wp-json\/wp\/v2\/categories?post=7"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/dreamseeker\/wp-json\/wp\/v2\/tags?post=7"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}