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

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

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

		<entry>
		<author><name><![CDATA[stf92]]></name></author>
		<updated>2014-01-21T19:17:56+02:00</updated>

		<published>2014-01-21T19:17:56+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=8816&amp;p=26485#p26485</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=8816&amp;p=26485#p26485"/>
		<title type="html"><![CDATA[usb.h and libusb.]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=8816&amp;p=26485#p26485"><![CDATA[
Hi:<div class="codebox"><p>Code: </p><pre><code>#include &lt;usb.h&gt;<br />#include &lt;stdio.h&gt;<br />#include &lt;string.h&gt;<br />unsigned short IDVendor=   0x1384;              /*VID must be changed. */<br />unsigned short IDProduct=  0x8888;              /*PID must be changed. */<br /><br />...........................<br /><br />int main(int argc, char **argv)<br />{<br />        usb_dev_handle *d=NULL;<br />        unsigned char buffer&#91;3&#93;;<br />        int i, mode, ret;<br />        char string&#91;256&#93;;<br /><br />        if(argc &lt;2)<br />        {<br />                printf(&quot;give the voltage value.\n&quot;);<br />                exit(1);<br />        }<br />        i=floor(atof(argv&#91;1&#93;)*51) ;<br /> if(i&gt;255){printf(&quot;value must be between 0 and 5V\n&quot;); exit(1);} <br />        mode=0;<br />usb_init();<br />ret=usbOpenDevice(&amp;d, IDVendor,IDProduct);<br />if(ret!=0){printf(&quot;usbOpenDevice failed\n&quot;); return 0;}<br /><br />   ret=usb_control_msg(d, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, mode, i, 0, (char *)buffer, sizeof(buffer), 5000);<br /><br />//      printf(&quot;buffer %d \n&quot;, buffer&#91;0&#93;);<br />        return 0;<br />}<br /></code></pre></div><br />This is part of an application program running on linux. Looking for documentation for usb_control_msg(), shown in the last lines above, I first went to /usr/include/usb.h, that is in the #include's (first lines), and the function was there. Looking for the source, I found /usr/src/linux-3.2.29/drivers/usb/core/message.c, where it is defined but, alas, here it has the arguments in different order and they are 9 instead of <img class="smilies" src="./../../../images/smilies/icon_cool.gif" alt="8)" title="Cool" />. As the author asks for the libusb library, the logical thing was to look in its sources, which I installed, just now, from the O.S. distribution disks. But here there is no usb_control_msg(), nor even the usb.h file! <br /><br />So, what should the source for usb.h be? <br /><br />Note: in usb.h there is declared a function usb_control_msg with the same number and order of parameters as in my source.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=20156">stf92</a> — Tue Jan 21, 2014 7:17 pm</p><hr />
]]></content>
	</entry>
	</feed>
