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

	<title>Objective Development Forums</title>
	
	<link href="https://forums.obdev.at/index.php" />
	<updated>2013-05-11T22:51:10+02:00</updated>

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

		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2013-05-11T22:51:10+02:00</updated>

		<published>2013-05-11T22:51:10+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=8409&amp;p=25255#p25255</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=8409&amp;p=25255#p25255"/>
		<title type="html"><![CDATA[Re: Send Integer to PC with usbMsgPtr]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=8409&amp;p=25255#p25255"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>        int temp = (buffer&#91;0&#93; &lt;&lt; 8) | buffer&#91;1&#93;;<br /><br />        printf(&quot;Temperature: %i\n&quot;, temp);<br /></code></pre></div><br /><br />That was what I did too... I guess I will try it again.<p>Statistics: Posted by Guest — Sat May 11, 2013 10:51 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2013-05-06T16:30:38+02:00</updated>

		<published>2013-05-06T16:30:38+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=8409&amp;p=25234#p25234</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=8409&amp;p=25234#p25234"/>
		<title type="html"><![CDATA[Re: Send Integer to PC with usbMsgPtr]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=8409&amp;p=25234#p25234"><![CDATA[
<blockquote class="uncited"><div>Remember: &quot;setupData&quot; needs to be at least 8 bytes.</div></blockquote><br /><br />At host end of course you need to do:<br /><ul>int result = ((int)buffer[3]&lt;&lt;8) | ((int)buffer[2]);<br />printf(&quot;%i\n&quot;,result);<br /></ul><br />So long<p>Statistics: Posted by Guest — Mon May 06, 2013 4:30 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2013-05-06T15:57:15+02:00</updated>

		<published>2013-05-06T15:57:15+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=8409&amp;p=25233#p25233</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=8409&amp;p=25233#p25233"/>
		<title type="html"><![CDATA[Re: Send Integer to PC with usbMsgPtr]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=8409&amp;p=25233#p25233"><![CDATA[
But that was what I was doing at first.<br /><br />In my very first post:<br /><br /><div class="codebox"><p>Code: </p><pre><code>  <br />int temp = 255;<br />t_char&#91;2&#93; = {0};<br />t_char&#91;0&#93; = (temp &gt;&gt; 8) &amp; 0xff;<br />t_char&#91;1&#93; = (temp) &amp; 0xff;<br />usbMsgPtr = t_char;<br />return sizeof(t_char);<br /></code></pre></div><br /><br />Which does not work.<br /><br />So long, nictex<p>Statistics: Posted by Guest — Mon May 06, 2013 3:57 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2013-05-06T14:25:08+02:00</updated>

		<published>2013-05-06T14:25:08+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=8409&amp;p=25232#p25232</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=8409&amp;p=25232#p25232"/>
		<title type="html"><![CDATA[Re: Send Integer to PC with usbMsgPtr]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=8409&amp;p=25232#p25232"><![CDATA[
For example you could do this. Remember: &quot;setupData&quot; needs to be at least 8 bytes.<br />On the host side you again could decode the single bytes together to an int.<br /><br /><ul>  usbMsgPtr = (usbMsgPtr_t)setupData;<br />  switch (rq-&gt;bRequest) {<br />[...]<br />case PSCMD_CALL_GETBUFFERSIZE: {<br />      setupData[0] = rq-&gt;bRequest;<br />      setupData[1] = PSCMD_RETN_OKAY;<br />      setupData[2] = (singlebuffersize)&amp;0xff;<br />      setupData[3] = (singlebuffersize)&gt;&gt;8;<br />      cli();<br />[...]<br /></ul><br />Best regards<p>Statistics: Posted by Guest — Mon May 06, 2013 2:25 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2013-05-06T09:30:14+02:00</updated>

		<published>2013-05-06T09:30:14+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=8409&amp;p=25231#p25231</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=8409&amp;p=25231#p25231"/>
		<title type="html"><![CDATA[Re: Send Integer to PC with usbMsgPtr]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=8409&amp;p=25231#p25231"><![CDATA[
Hey,<br /><br />as far as I know both AVR-gcc and gcc on windows use little ebdian. Besides that I also bit shifted the numbers in another way so that it should resemble endianness conversion.<br /><br />How do I really send an integer number now? The method i've put into my last post does not work!<br /><br />so long, nictex<p>Statistics: Posted by Guest — Mon May 06, 2013 9:30 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2013-05-03T12:52:30+02:00</updated>

		<published>2013-05-03T12:52:30+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=8409&amp;p=25212#p25212</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=8409&amp;p=25212#p25212"/>
		<title type="html"><![CDATA[Re: Send Integer to PC with usbMsgPtr]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=8409&amp;p=25212#p25212"><![CDATA[
Hi.<br /><br />Your AVR has an &quot;other understanding&quot; of integer, than your host.<br /><br />One thing is the endianness (<!-- m --><a class="postlink" href="http://en.wikipedia.org/wiki/Endianness">http://en.wikipedia.org/wiki/Endianness</a><!-- m -->).<br />Your AVR is BIG endian - your PC little endian.<br />Also your AVR uses just 16bit (??) for int, while your PC uses 4 bytes.<br /><br />As a convention data always is transmitted in little endian trough networks.<br />(Usually your PC has much more CPU power to transform it in its own format,<br />than little microcontrollers have.)<br /><br />To simplify platform independent code see <!-- m --><a class="postlink" href="http://www.gnu.org/software/libc/manual/html_node/Byte-Order.html">http://www.gnu.org/software/libc/manual ... Order.html</a><!-- m --> .<br />(Use hton on the AVR side and ntoh on the PC side)<br /><br />To avoid type misinterpretation on both sides use &quot;#include &lt;stdint.h&gt;&quot; and then the std-type uint32_t or int32_t.<br />(<!-- m --><a class="postlink" href="http://www.gnu.org/software/gnulib/manual/html_node/stdint_002eh.html">http://www.gnu.org/software/gnulib/manu ... 002eh.html</a><!-- m -->   AND<br /><!-- m --><a class="postlink" href="http://www.nongnu.org/avr-libc/user-manual/group__avr__stdint.html">http://www.nongnu.org/avr-libc/user-man ... tdint.html</a><!-- m -->)<br /><br />Best regards<p>Statistics: Posted by Guest — Fri May 03, 2013 12:52 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2013-05-02T13:36:18+02:00</updated>

		<published>2013-05-02T13:36:18+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=8409&amp;p=25208#p25208</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=8409&amp;p=25208#p25208"/>
		<title type="html"><![CDATA[Re: Send Integer to PC with usbMsgPtr]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=8409&amp;p=25208#p25208"><![CDATA[
I know haha <img class="smilies" src="./../../../images/smilies/icon_biggrin.gif" alt=":D" title="Very Happy" /><br /><br />Okay, could you provide me with some functioning code?<br /><br />I now did this:<br /><br /><div class="codebox"><p>Code: </p><pre><code>      case USB_GET_TEMP:<br />         {<br />            usbMsgPtr = temp;<br />            return sizeof(temp);<br />         }<br /></code></pre></div><br /><br />But how do I get the value then in my PC program?<br />I am using this code <a href="http://codeandlife.com/2012/02/04/avr-attiny-usb-tutorial-part-4/" class="postlink">http://codeandlife.com/2012/02/04/avr-attiny-usb-tutorial-part-4/</a><br />How do I get the 2 byte integer into the PC? It seems that you do not really understand my problem. Have you tried doing it?<br />I cannot just do this:<br /><div class="codebox"><p>Code: </p><pre><code>       int16_t temp;<br />        nBytes = usb_control_msg(handle,<br />            USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN,<br />            USB_GET_TEMP, 0, 0, temp, sizeof(temp), 5000);<br />        printf(&quot;Bytecount: %d, Buffer: %i\n&quot;, nBytes, temp);</code></pre></div><br /><br />It just does not work.<br /><br />So long, nictex<p>Statistics: Posted by Guest — Thu May 02, 2013 1:36 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2013-04-28T16:06:12+02:00</updated>

		<published>2013-04-28T16:06:12+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=8409&amp;p=25198#p25198</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=8409&amp;p=25198#p25198"/>
		<title type="html"><![CDATA[Re: Send Integer to PC with usbMsgPtr]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=8409&amp;p=25198#p25198"><![CDATA[
I am confused.<br /><br />But for usbMsgPtr it is just imprtant to have<strong class="text-strong"> at least </strong>8 bytes accessable memory.<br />If it is memory of &quot;type&quot; int, char or void  -  not even the programming language really cares.<br /><br />Important is just the memory (space).<br /><br />For formated output (like printf) you need to tell the function how to &quot;interpret&quot; the memory. If the memory contains &quot;data&quot; of an integer you need to use %i instead %s.<br /><br />Best regards,<p>Statistics: Posted by Guest — Sun Apr 28, 2013 4:06 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2013-04-27T16:41:28+02:00</updated>

		<published>2013-04-27T16:41:28+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=8409&amp;p=25192#p25192</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=8409&amp;p=25192#p25192"/>
		<title type="html"><![CDATA[Re: Send Integer to PC with usbMsgPtr]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=8409&amp;p=25192#p25192"><![CDATA[
Hey vouvoume,<br /><br />did you understand what I was trying to do with the code in my first post?<br />Can I just point the usbMsgPtr to a 16bit variable instead of an array of 8bit variables??? (Char array) Because if you read through my first posted code segments you See that I bit shifted the integer into a char array of size 2 and then shifted it back in the PC program. So you think I just Have To do usbMsgPtr = temp; ?<br /><br />so long, nictex<p>Statistics: Posted by Guest — Sat Apr 27, 2013 4:41 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2013-04-27T02:30:17+02:00</updated>

		<published>2013-04-27T02:30:17+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=8409&amp;p=25191#p25191</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=8409&amp;p=25191#p25191"/>
		<title type="html"><![CDATA[Re: Send Integer to PC with usbMsgPtr]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=8409&amp;p=25191#p25191"><![CDATA[
Hi.<br /><br /><div class="codebox"><p>Code: </p><pre><code>printf(&quot;Bytecount: %d, Buffer: %s\n&quot;, nBytes, buffer);</code></pre></div><br /><br />Then you should not do a %s, but a something like an %i instead?<p>Statistics: Posted by Guest — Sat Apr 27, 2013 2:30 am</p><hr />
]]></content>
	</entry>
	</feed>
