<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forums.obdev.at/app.php/feed/topic/2076" />

	<title>Objective Development Forums</title>
	
	<link href="https://forums.obdev.at/index.php" />
	<updated>2009-01-21T19:37:56+02:00</updated>

	<author><name><![CDATA[Objective Development Forums]]></name></author>
	<id>https://forums.obdev.at/app.php/feed/topic/2076</id>

		<entry>
		<author><name><![CDATA[christian]]></name></author>
		<updated>2009-01-21T19:37:56+02:00</updated>

		<published>2009-01-21T19:37:56+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=2076&amp;p=7607#p7607</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=2076&amp;p=7607#p7607"/>
		<title type="html"><![CDATA[Interrupt-in endpoint: What am I missing?]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=2076&amp;p=7607#p7607"><![CDATA[
Do you get an error for setting the configuration and claiming the interface? You can't use the interrupt endpoint without claiming the interface.<br /><br />See the RemoteSensor example for how the interrupt endpoint can be used.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=8">christian</a> — Wed Jan 21, 2009 7:37 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[asbjoern]]></name></author>
		<updated>2009-01-05T22:38:11+02:00</updated>

		<published>2009-01-05T22:38:11+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=2076&amp;p=7410#p7410</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=2076&amp;p=7410#p7410"/>
		<title type="html"><![CDATA[Interrupt-in endpoint: What am I missing?]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=2076&amp;p=7410#p7410"><![CDATA[
Hi <br /><br />I am trying to implement a streaming sensor using Interrupt-in endpoint but nothing seems to be working. Control endpoint communication works fine.<br />What am I missing?<br />I am using custom class and have  set the <br /><div class="codebox"><p>Code: </p><pre><code>#define USB_CFG_HAVE_INTRIN_ENDPOINT    1</code></pre></div> Nothing else but iopins has been changed from the usbconfig.h prototype.<br /><br />AVR code:<br /><div class="codebox"><p>Code: </p><pre><code>static uchar    dataBuffer&#91;4&#93;;<br /><br />int main&#40;void&#41; &#123;<br />  newMeas = 0;<br />  hardware_init&#40;&#41;; <br />  uchar i = 0;<br />  usbDeviceDisconnect&#40;&#41;;<br />  while&#40;--i&#41;         /* fake USB disconnect for &gt; 250 ms */<br />        _delay_ms&#40;1&#41;;<br />  usbDeviceConnect&#40;&#41;;<br />  usbInit&#40;&#41;;<br />  sei&#40;&#41;;<br />  <br />  while&#40;1&#41;<br />  &#123;<br />   usbPoll&#40;&#41;;<br />   if&#40;newMeas &amp;&amp; usbInterruptIsReady&#40;&#41;&#41;  &#123;<br />     dataBuffer&#91;0&#93; = 5;<br />     dataBuffer&#91;1&#93; = 5;<br />     usbSetInterrupt&#40;dataBuffer, 2&#41;;<br />     newMeas = 0;<br />   &#125;<br />  &#125;<br />&#125;<br /></code></pre></div><br />usbFunctionSetup() is omitted from the quote as it only handles the control end point<br /><br />Commandlinecode on Linux 2.6.27:<br /><div class="codebox"><p>Code: </p><pre><code>#include &lt;stdio.h&gt;<br />#include &lt;stdlib.h&gt;<br />#include &lt;string.h&gt;<br />#include &lt;usb.h&gt;        <br />#include &quot;opendevice.h&quot;<br /><br />struct usb_bus *busses;<br /><br />usb_dev_handle *find_sensor&#40;void&#41; &#123;<br />  struct usb_bus *bus;<br />  char Manufacturer&#91;256&#93;, Product&#91;256&#93;;<br />  struct usb_device *dev;<br />  struct usb_dev_handle *devh = NULL;<br /><br />  usb_init&#40;&#41;;<br />  usb_find_busses&#40;&#41;;<br />  usb_find_devices&#40;&#41;;<br />  busses = usb_get_busses&#40;&#41;;<br /><br />  for&#40;bus = busses; bus; bus = bus-&gt;next&#41; &#123;<br />    for&#40;dev = bus-&gt;devices; dev; dev = dev-&gt;next&#41; &#123;<br />      if&#40;dev-&gt;descriptor.idVendor == 0x16C0 &amp;&amp;<br />    dev-&gt;descriptor.idProduct == 0x05DC&#41; &#123;<br />   devh = usb_open&#40;dev&#41;;<br />   if&#40;!devh&#41; &#123;<br />     perror&#40;&quot;usb_open&quot;&#41;;<br />     goto xit;<br />   &#125;<br />   if&#40;usb_get_string_simple&#40;devh, dev-&gt;descriptor.iManufacturer,<br />             Manufacturer, 255&#41; &lt; 0&#41; &#123;<br />     perror&#40;&quot;usb_get_string_simple&#40;iManufacturer&#41;&quot;&#41;;<br />     goto xit;<br />   &#125;<br />   if&#40;usb_get_string_simple&#40;devh, dev-&gt;descriptor.iProduct, Product,<br />             255&#41; &lt; 0&#41; &#123;<br />     perror&#40;&quot;usb_get_string_simple&#40;iProduct&#41;&quot;&#41;;<br />     goto xit;<br />   &#125;<br />   printf&#40;&quot;Found %s %s\n&quot;,Manufacturer,Product&#41;;<br /><br />     if&#40;usb_set_configuration&#40;devh, 1&#41; &lt; 0&#41; &#123;<br />       perror&#40;&quot;usb_set_configuration&quot;&#41;; exit&#40;1&#41;;<br />     &#125;<br />     if&#40;usb_claim_interface&#40;devh, 0&#41; &lt; 0&#41; &#123;<br />       perror&#40;&quot;usb_claim_interface&quot;&#41;; exit&#40;1&#41;;<br />     &#125;<br />     if&#40;&#40;dev-&gt;config-&gt;interface-&gt;altsetting-&gt;endpoint-&gt;bmAttributes &amp;<br />         USB_ENDPOINT_TYPE_MASK&#41; != USB_ENDPOINT_TYPE_INTERRUPT&#41; &#123;<br />       fprintf&#40;stderr, &quot;Endpoint 1 is not an interrupt endpoint\n&quot;&#41;;<br />       goto xit;<br />     &#125;<br />     return devh;<br />      &#125;<br />    xit:<br />      if&#40;devh&#41; &#123;<br />   usb_release_interface&#40;devh, 0&#41;;<br />   usb_close&#40;devh&#41;;<br />   devh = NULL;<br />      &#125;<br />    &#125;<br />  &#125;<br />  return NULL;<br />&#125;<br /><br />void close_sensor&#40;usb_dev_handle *devh&#41; &#123;<br />  if&#40;devh&#41; &#123;<br />    usb_release_interface&#40;devh, 0&#41;;<br />    usb_close&#40;devh&#41;;<br />  &#125;<br />&#125;<br /><br />int main&#40;int argc, char **argv&#41;<br />&#123;<br />usb_dev_handle *devh;<br />  int len;<br />  char                buffer&#91;4&#93;;<br /><br />  if&#40;!&#40;devh = find_sensor&#40;&#41;&#41;&#41; &#123;<br />    fprintf&#40;stderr, &quot;No module found\n&quot;&#41;;<br />    exit&#40;1&#41;;<br />  &#125;<br /><br />  printf&#40;&quot;stream begin\n&quot;&#41;;<br />  len = usb_interrupt_read&#40;devh, 1, buffer, sizeof&#40;buffer&#41;, 3000&#41;;<br />  if&#40;len &lt; 0&#41;&#123;<br />    fprintf&#40;stderr, &quot;USB error: %s\n&quot;, usb_strerror&#40;&#41;&#41;;<br />  &#125;else&#123;<br />    printf&#40;&quot;Value is %u\n&quot;, &#40;buffer&#91;0&#93;&lt;&lt;8 | buffer&#91;1&#93;&#41;&amp;0xff&#41;;<br />  &#125;<br />  printf&#40;&quot;stream end\n&quot;&#41;;<br />close_sensor&#40;devh&#41;;<br />    return 0;<br />&#125;<br /></code></pre></div><br /><br />Console output:<br /><div class="codebox"><p>Code: </p><pre><code>Found A.Mejnertsen PowerMeas<br />stream<br />&lt;---3 sec wait---&gt;<br />USB error: No error<br />stream end<br /></code></pre></div><br /><br />I really can't see why this shouldn't be working. Can anybody give me some pointer as to what I'm missing?<br /><br />Best regards<br /><br />Asbjørn Mejnertsen<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=1661">asbjoern</a> — Mon Jan 05, 2009 10:38 pm</p><hr />
]]></content>
	</entry>
	</feed>
