<?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/8597" />

	<title>Objective Development Forums</title>
	
	<link href="https://forums.obdev.at/index.php" />
	<updated>2013-08-28T21:26:44+02:00</updated>

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

		<entry>
		<author><name><![CDATA[ulao]]></name></author>
		<updated>2013-08-28T21:26:44+02:00</updated>

		<published>2013-08-28T21:26:44+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=8597&amp;p=25734#p25734</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=8597&amp;p=25734#p25734"/>
		<title type="html"><![CDATA[Re: SOLVED: How to send mulitple reports over one interrupt]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=8597&amp;p=25734#p25734"><![CDATA[
its been understood for a long time that Linux will not work with mutiple descriptor reports like that, are you saying you over came that?<br /><br />like this for example.<br /><!-- l --><a class="postlink-local" href="http://forums.obdev.at/viewtopic.php?f=8&amp;t=2926&amp;p=9925&amp;hilit=multi+linux#p9925">viewtopic.php?f=8&amp;t=2926&amp;p=9925&amp;hilit=multi+linux#p9925</a><!-- l --><p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=1281">ulao</a> — Wed Aug 28, 2013 9:26 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[frampy]]></name></author>
		<updated>2013-08-28T03:09:52+02:00</updated>

		<published>2013-08-28T03:09:52+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=8597&amp;p=25731#p25731</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=8597&amp;p=25731#p25731"/>
		<title type="html"><![CDATA[Re: How to send mulitple reports over one interrupt endpoint]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=8597&amp;p=25731#p25731"><![CDATA[
I figured out why the code gets stuck in the loop waiting for usbInterruptIsReady() to return true.<br /><br />The OS I'm using (Linux) won't poll the USB device unless there is a program actually using the device. In my case I'm running the following command to poll the device.<br /><div class="codebox"><p>Code: </p><pre><code>jstest --event /dev/input/js0</code></pre></div><br />Which polls the device just fine.<br /><br />I was also able to reduce USB_CFG_INTR_POLL_INTERVAL to 2ms (not tested on windows).<br /><br />I managed to get the two reports sending successfully using the following code. - this is mostly inspired by code found on raphnet.net<br /><br /><div class="codebox"><p>Code: </p><pre><code>    uint8_t must_report = 0;<br />    while(1) {<br /><br />        wdt_reset();<br />        usbPoll(); //this must be called approx every 50ms<br /><br />        pollButtons(&amp;must_report);<br /><br />        if (must_report) {<br />            for (gp = 0; gp &lt; NUM_GAMEPADS; gp++) {<br />                if (must_report &amp; (1 &lt;&lt; gp) == 0)<br />                    continue;<br /><br />                if (usbInterruptIsReady()) {<br />                    buildReport(&amp;gamepads&#91;gp&#93;, reportBuffer);<br />                    usbSetInterrupt(reportBuffer, REPORT_SIZE);<br />                    must_report &amp;= ~(1 &lt;&lt; gp);<br /><br />                    while (!usbInterruptIsReady()) {<br />                        usbPoll();<br />                        wdt_reset();<br />                        pollButtons(&amp;must_report);<br />                    }<br />                }<br />            }<br />        }<br />    }<br /><br /></code></pre></div><p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=19897">frampy</a> — Wed Aug 28, 2013 3:09 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[frampy]]></name></author>
		<updated>2013-08-28T03:10:23+02:00 </updated>

		<published>2013-08-27T11:07:22+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=8597&amp;p=25729#p25729</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=8597&amp;p=25729#p25729"/>
		<title type="html"><![CDATA[SOLVED: How to send mulitple reports over one interrupt endp]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=8597&amp;p=25729#p25729"><![CDATA[
I've been building a USB joystick controller for use in an arcade machine using V-USB. I've setup my report descriptor to contain two different reports using the REPORT_ID field (one for each player on tha machine).<br /><br />I can send a report for each of the players individually, like so.<br /><div class="codebox"><p>Code: </p><pre><code>if (TCNT0 &gt; 47)  //47 == 4ms approx<br />{<br />    if (usbInterruptIsReady())<br />    {<br />        // this works fine, but only send a report for player 1<br />        buildReport(&amp;gamepads&#91;0&#93;, reportBuffer);<br />        usbSetInterrupt(reportBuffer, REPORT_SIZE);<br />    }<br />}<br /></code></pre></div><br /><br />But I cannot send both reports squentially, I found some example code at <!-- m --><a class="postlink" href="http://www.raphnet.net/electronique/2nes2usb/index_en.php">http://www.raphnet.net/electronique/2ne ... dex_en.php</a><!-- m --> which I've used to template this, but it doesn't work for me. Reference the following code sample, after usbSetInterrupt() is called, the code enters a loop waiting for the buffer to clear so we can set another interrupt, but the code gets stuck in this loop and never returns.<br /><br />Someone help please! Programmer in peril.<br /><br /><div class="codebox"><p>Code: </p><pre><code>if (TCNT0 &gt; 47) //47 == 4ms approx<br />{<br />    TCNT0 = 0;<br />    for (gp = 0; gp &lt; NUM_GAMEPADS; gp++)<br />    {<br />        buildReport(&amp;gamepads&#91;gp&#93;, reportBuffer);<br />        if (usbInterruptIsReady())<br />        {<br />            usbSetInterrupt(reportBuffer, REPORT_SIZE);<br />            while (!usbInterruptIsReady())<br />            {<br />                // code hangs in this loop<br />                usbPoll();<br />                wdt_reset();<br /><br />                // when uncommented, this toggles furiously!<br />                //toggle_pin();<br />            }<br />        }<br />    }<br />    // never see this toggled<br />    toggle_pin();<br />}<br /><br /></code></pre></div><br /><br />Thanks for your time<br /><br />--Mike<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=19897">frampy</a> — Tue Aug 27, 2013 11:07 am</p><hr />
]]></content>
	</entry>
	</feed>
