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

	<title>Objective Development Forums</title>
	
	<link href="https://forums.obdev.at/index.php" />
	<updated>2018-10-26T21:12:32+02:00</updated>

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

		<entry>
		<author><name><![CDATA[mostafayasin]]></name></author>
		<updated>2018-10-26T21:12:32+02:00</updated>

		<published>2018-10-26T21:12:32+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=11573&amp;p=34932#p34932</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=11573&amp;p=34932#p34932"/>
		<title type="html"><![CDATA[Re: Can't copy vaiable &quot;data&quot; to another variable inside &quot;usbFunctionWrite&quot;]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=11573&amp;p=34932#p34932"><![CDATA[
Thanks ulao, I solved my problem by using another example, I used hid-custom-rq on the vusb examples instead of hid-data .<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=23997">mostafayasin</a> — Fri Oct 26, 2018 9:12 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ulao]]></name></author>
		<updated>2018-10-24T16:03:38+02:00</updated>

		<published>2018-10-24T16:03:38+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=11573&amp;p=34913#p34913</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=11573&amp;p=34913#p34913"/>
		<title type="html"><![CDATA[Re: Can't copy vaiable &quot;data&quot; to another variable inside &quot;usbFunctionWrite&quot;]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=11573&amp;p=34913#p34913"><![CDATA[
I'm not sure off hand how the c compiler handles shadow vs one to one copying in c but it is generally better to use memcpy.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=1281">ulao</a> — Wed Oct 24, 2018 4:03 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[mostafayasin]]></name></author>
		<updated>2018-10-21T10:36:14+02:00</updated>

		<published>2018-10-21T10:36:14+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=11573&amp;p=34901#p34901</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=11573&amp;p=34901#p34901"/>
		<title type="html"><![CDATA[Can't copy vaiable &quot;data&quot; to another variable inside &quot;usbFunctionWrite&quot;]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=11573&amp;p=34901#p34901"><![CDATA[
Hello guys,<br />I tried to copy the whole content of &quot;data&quot; to global array to deal with it as shown in the for loop below :<br /><div class="codebox"><p>Code: </p><pre><code>volatile static uchar   myData&#91;8&#93;;<br />uchar   usbFunctionWrite(uchar *data, uchar len)<br />{<br />    if(bytesRemaining == 0)<br />        return 1;               /* end of transfer */<br />    if(len &gt; bytesRemaining)<br />        len = bytesRemaining;<br /><br />   currentAddress += len;<br />    bytesRemaining -= len;<br /><br />    // copy the whole content of &quot;data&quot;<br />    uchar i;<br />    for ( i=0 ; i&lt;len ; i++ ){<br />       myData&#91;i&#93; = data&#91;i&#93;;<br />    }<br /><br />    return bytesRemaining == 0; /* return 1 if this was the last chunk */<br />}</code></pre></div><br />But when trying to send it to the host it seems that my array &quot;myData&quot; is empty and the host prints all zeros, the code below shows how I tried to send it to the host :<br /><div class="codebox"><p>Code: </p><pre><code>uchar   usbFunctionRead(uchar *data, uchar len)<br />{<br />    if(len &gt; bytesRemaining)<br />        len = bytesRemaining;<br /><br />    uchar i;<br />    for ( i=0 ; i&lt;len ; i++ ){<br />       data&#91;i&#93; = myData&#91;i&#93;;<br />    }<br /><br />    currentAddress += len;<br />    bytesRemaining -= len;<br />    return len;<br />}<br /></code></pre></div><br />Am I doing something wrongly ?<br />Thanks for the advice.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=23997">mostafayasin</a> — Sun Oct 21, 2018 10:36 am</p><hr />
]]></content>
	</entry>
	</feed>
