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

	<title>Objective Development Forums</title>
	
	<link href="https://forums.obdev.at/index.php" />
	<updated>2010-08-31T15:01:09+02:00</updated>

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

		<entry>
		<author><name><![CDATA[Vaidotas]]></name></author>
		<updated>2010-08-31T15:01:09+02:00</updated>

		<published>2010-08-31T15:01:09+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=4604&amp;p=15734#p15734</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=4604&amp;p=15734#p15734"/>
		<title type="html"><![CDATA[Re: A problem confuse me long time-Can't read data]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=4604&amp;p=15734#p15734"><![CDATA[
Maybe I don't understand your problem, becouse my english is not good, but I'll try to help you. The problem is that you describe buffer as char, but you do not write any information in it. I think you want to know why buffer[1-4]0=NULL, this is becouse you do not put information in it. I think it could help you.<br />Maybe in this forum is more people who is making programs with builder c++ and maybe they want to share information about it.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=4230">Vaidotas</a> — Tue Aug 31, 2010 3:01 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[M.H.Jack]]></name></author>
		<updated>2010-07-10T02:09:58+02:00</updated>

		<published>2010-07-10T02:09:58+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=4604&amp;p=15131#p15131</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=4604&amp;p=15131#p15131"/>
		<title type="html"><![CDATA[Re: A problem confuse me long time-Can't read data]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=4604&amp;p=15131#p15131"><![CDATA[
Nobody help me? <img class="smilies" src="./../../../images/smilies/icon_sad.gif" alt=":(" title="Sad" /><p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=4094">M.H.Jack</a> — Sat Jul 10, 2010 2:09 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[M.H.Jack]]></name></author>
		<updated>2010-07-10T02:11:17+02:00 </updated>

		<published>2010-07-09T07:57:23+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=4604&amp;p=15118#p15118</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=4604&amp;p=15118#p15118"/>
		<title type="html"><![CDATA[A problem confuse me long time-Can't read data]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=4604&amp;p=15118#p15118"><![CDATA[
I study V-USB probably two weeks. At first I don't know how to compile the firmware and the commandline tool, usually get into all kinds of trouble. Finally two days ago, I was so happy,I succeeded in compiling them without a error.  However, a new problem comes.<br />Now I am studying the custom-class example. My device can recognized by computer, and I can control the device with the commandline tool. Then I want to build a GUI tool with C++Builder. Now I have builded the tool, I can sent data to device to control the LED, but can't read data from device to get the LED status.<br /><br />Run the program and press the &quot;Get Status&quot; Button, result is:<br />cnt=1;<br />buffer[0]=null;<br />buffer[1]=null;<br />buffer[2]=null;<br />buffer[3]=null;<br /><br />I post the code below, hope somebody can help me <img class="smilies" src="./../../../images/smilies/icon_sad.gif" alt=":(" title="Sad" /> <br /><div class="codebox"><p>Code: </p><pre><code>//---------------------------------------------------------------------------<br /><br />#include &lt;vcl.h&gt;<br />#pragma hdrstop<br /><br />#include &quot;Unit1.h&quot;<br />#include &quot;usb.h&quot;<br />//---------------------------------------------------------------------------<br />#pragma package(smart_init)<br />#pragma resource &quot;*.dfm&quot;<br />#define   USBDEV_VENDOR   0x16c0   <br />#define   USBDEV_PRODUCT   0x05dc    <br />TForm1 *Form1;<br />static usb_dev_handle *usbhandle;<br />//---------------------------------------------------------------------------<br />__fastcall TForm1::TForm1(TComponent* Owner)<br />        : TForm(Owner)<br />{<br />  usbled_open();<br />}<br />//---------------------------------------------------------------------------<br />int usb_open()<br />{<br />  struct usb_bus    *bus;<br />  struct usb_device *dev = 0;<br />  usb_init();<br />  usb_find_busses();<br />  usb_find_devices();<br />  for(bus=usb_get_busses(); bus; bus=bus-&gt;next)<br />   {<br />    for(dev=bus-&gt;devices; dev; dev=dev-&gt;next)<br />     {<br />      if((dev-&gt;descriptor.idVendor == USBDEV_VENDOR) &amp;&amp; (dev-&gt;descriptor.idProduct == USBDEV_PRODUCT))<br />   break;<br />     }<br />    if(dev)<br />      break;<br />   }<br />  if(!dev){<br />    ShowMessage(&quot;Can't find USB device！&quot;);<br />    usbhandle=NULL;<br />    return 1;<br />  }<br />  usbhandle = usb_open(dev);<br />  if(!usbhandle){<br />    ShowMessage(&quot;Can't open USB！&quot;);<br />    usbhandle=NULL;<br />    return 2;<br />  }<br />  return 0;<br />}<br />//---------------------------------------------------------------------------<br />void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &amp;Action)<br />{<br />  if(!usbhandle)<br />   return;<br />  usb_close(usbhandle);        <br />}<br />//LED ON---------------------------------------------------------------------------<br />void __fastcall TForm1::Button1Click(TObject *Sender)<br />{<br />int cnt;<br />char send&#91;4&#93;;<br />char buffer&#91;4&#93;;<br />cnt = usb_control_msg(usbhandle,<br />                      USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT,<br />                      1,<br />                      1,<br />                      0,<br />                      buffer,<br />                      0,<br />                      5000);<br />}<br />//LED OFF---------------------------------------------------------------------------<br />void __fastcall TForm1::Button2Click(TObject *Sender)<br />{<br />int cnt;<br />char send&#91;4&#93;;<br />char buffer&#91;4&#93;;<br />cnt = usb_control_msg(usbhandle,<br />                      USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT,<br />                      1,<br />                      0,<br />                      0,<br />                      buffer,<br />                      0,<br />                      5000);<br />}<br />//GET Status---------------------------------------------------------------------------<br />void __fastcall TForm1::Button3Click(TObject *Sender)<br />{<br />int cnt;<br />char send&#91;4&#93;;<br />char buffer&#91;4&#93;;<br />cnt = usb_control_msg(usbhandle,<br />                      USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN,<br />                      2,<br />                      0,<br />                      0,<br />                      (char *)buffer,<br />                      sizeof(buffer),<br />                      5000);<br />Edit2-&gt;Text=cnt;<br />Edit1-&gt;Text=buffer&#91;0&#93;;<br />Edit3-&gt;Text=sizeof(buffer);<br />Edit4-&gt;Text=buffer&#91;0&#93;;<br />Edit5-&gt;Text=buffer&#91;1&#93;;<br />Edit6-&gt;Text=buffer&#91;2&#93;;<br />Edit7-&gt;Text=buffer&#91;3&#93;;<br />}<br />//---------------------------------------------------------------------------</code></pre></div><p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=4094">M.H.Jack</a> — Fri Jul 09, 2010 7:57 am</p><hr />
]]></content>
	</entry>
	</feed>
