[prev in list] [next in list] [prev in thread] [next in thread] 

List:       libusb-devel
Subject:    Re: [libusb] Transfer with Darwin backend fails on second control endpoint
From:       Jean-Etienne LAMIAUD <j-etienne () users ! sourceforge ! net>
Date:       2014-05-11 17:14:33
Message-ID: 6A9CEDBB-2F5C-4D9E-AE7A-A29B4C886EDE () users ! sourceforge ! net
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Thanks for looking into this.

To clarify the point, in this code, the "direction" variable comes from a call to \
"GetPipeProperties" : it is a Darwin type providing information on the direction \
associated to the endpoint. It is not the direction flag of the endpoint ; it is \
related to it AND/OR to the transfer type. It can have the following values :
   kUSBOut = 0	Bulk out or interrupt out
   kUSBIn = 1		Bulk in or interrupt in
   kUSBNone = 2	???
   kUSBAnyDirn = 3	Control

The use of this variable to construct the endpoint address therefore sets the \
direction bit for control endpoints.

From my integration issues, it can be seen that this bit, set in the request, causes \
the control transfer request to fail. I can't say what would happen if the device \
would set the direction bit in its descriptor, and the request being sent with it \
cleared. According to the spec, there should not be any difference whether the \
direction bit is set in the descriptor or not.

Regards.
Jean-Etienne

Le 6 mai 2014 à 10:45, Nathan Hjelm <hjelmn@me.com> a écrit :

> I have some concern that some control endpoints may have the direction bit set \
> since the USB spec says the bit should just be ignored. I will push a fix that \
> tries to works with both cases. 
> -Nathan
> 
> On Mar 15, 2014, at 11:09 AM, Jean-Etienne LAMIAUD \
> <j-etienne@users.sourceforge.net> wrote: 
> > Hello.
> > The device I'm using has two association descriptors : a CDC with the first 3 \
> > endpoints, a vendor interface with a control and an interrupt endpoint. The CDC \
> > is managed by the OS as a serial device, and I'm writing the application which \
> > manage the vendor interface. 
> > When performing a transfer on control endpoint 4, it fails with error -5.
> > 
> > Exploring the log, I found the following line :
> > libusb: 0.715508 info [get_endpoints] interface: 2 pipe 1: dir: 3 number: 4
> > 
> > The "dir" parameter has the value 3 = kUSBAnyDirn, and as it is used by \
> > get_endpoints to construct the endpoint address, the endpoint address recorded by \
> > libusb becomes 0x84 instead of 0x04 given by the device configuration during the \
> > enumeration. 
> > Based on this, I tried to apply the following patch, which happened to correct \
> > the problem : 
> > *** darwin_usb.c~      2014-03-15 17:27:20.000000000 +0100
> > --- darwin_usb.c        2014-03-15 17:31:16.000000000 +0100
> > ***************
> > *** 1126,1132 ****
> > 
> > usbi_dbg ("interface: %i pipe %i: dir: %i number: %i", iface, i, direction, \
> > number); 
> > ! cInterface-      >endpoint_addrs[i - 1] = ((direction << 7 & \
> > LIBUSB_ENDPOINT_DIR_MASK) | (number & LIBUSB_ENDPOINT_ADDRESS_MASK)); }
> > 
> > cInterface-  >num_endpoints = numep;
> > --- 1126,1132 ----
> > 
> > usbi_dbg ("interface: %i pipe %i: dir: %i number: %i", iface, i, direction, \
> > number); 
> > ! cInterface-      >endpoint_addrs[i - 1] = (((direction == kUSBIn) << 7 & \
> > LIBUSB_ENDPOINT_DIR_MASK) | (number & LIBUSB_ENDPOINT_ADDRESS_MASK)); }
> > 
> > cInterface-  >num_endpoints = numep;
> > 
> > ------------------------------------------------------------------------------
> > Learn Graph Databases - Download FREE O'Reilly Book
> > "Graph Databases" is the definitive new guide to graph databases and their
> > applications. Written by three acclaimed leaders in the field,
> > this first edition is now available. Download your free book today!
> > http://p.sf.net/sfu/13534_NeoTech
> > _______________________________________________
> > libusb-devel mailing list
> > libusb-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/libusb-devel


[Attachment #5 (unknown)]

<html><head><meta http-equiv="Content-Type" content="text/html \
charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: \
space; -webkit-line-break: after-white-space;"><div><font face="Arial">Thanks for \
looking into this.</font></div><div><font face="Arial"><br></font></div><font \
face="Arial">To clarify the point, in this code, the "direction" variable comes from \
a call to "GetPipeProperties" : it is a Darwin type providing information on the \
direction associated to the endpoint. It is not the direction flag of the endpoint ; \
it is related to it AND/OR to the&nbsp;transfer&nbsp;type.</font><div><font \
face="Arial">It&nbsp;can have the following values :</font><div><div><font \
face="Arial">&nbsp; &nbsp;kUSBOut = 0<span class="Apple-tab-span" \
style="white-space:pre">	</span>Bulk out or interrupt out</font></div><div><font \
face="Arial">&nbsp; &nbsp;kUSBIn = 1<span class="Apple-tab-span" \
style="white-space:pre">		</span>Bulk in or interrupt in</font></div><div><font \
face="Arial">&nbsp; &nbsp;kUSBNone = 2<span class="Apple-tab-span" \
style="white-space:pre">	</span>???</font></div><div><font face="Arial">&nbsp; \
&nbsp;kUSBAnyDirn = 3<span class="Apple-tab-span" \
style="white-space:pre">	</span>Control</font></div><font \
face="Arial"><div><br></div>The use of this variable to construct the endpoint \
address therefore sets the direction bit for control \
endpoints.</font></div><div><font face="Arial"><br></font></div><div><font \
face="Arial">From my integration issues, it can be seen that this bit, set in the \
request, causes the control transfer request to fail. I can't say what would happen \
if the device would set the direction bit in its descriptor, and the request being \
sent with it cleared. According to the spec, there should not be any difference \
whether the direction bit is set in the descriptor or not.</font></div><div><font \
face="Arial"><br></font></div><div><font face="Arial">Regards.</font></div><div><font \
face="Arial">Jean-Etienne</font><br \
class="Apple-interchange-newline"><br></div><div><div><div>Le 6 mai 2014 à 10:45, \
Nathan Hjelm &lt;<a href="mailto:hjelmn@me.com">hjelmn@me.com</a>&gt; a écrit \
:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>I have some \
concern that some control endpoints may have the direction bit set since the USB spec \
says the bit should just be ignored. I will push a fix that tries to works with both \
cases.</div><div><br></div><div>-Nathan<br><br>On Mar 15, 2014, at 11:09 AM, \
Jean-Etienne LAMIAUD &lt;<a \
href="mailto:j-etienne@users.sourceforge.net">j-etienne@users.sourceforge.net</a>&gt; \
wrote:<br><br></div><div><blockquote type="cite"><div class="msg-quote"><div \
class="_stretch"><span style="white-space:pre;" data-mce-style="white-space: \
pre;">Hello.<br>The device I'm using has two association descriptors : a CDC with the \
first 3 endpoints, a vendor interface with a control and an interrupt endpoint. The \
CDC is managed by the OS as a serial device, and I'm writing the application which \
manage the vendor interface.<br><br>When performing a transfer on control endpoint 4, \
it fails with error -5.<br><br>Exploring the log, I found the following line :<br> \
libusb: 0.715508 info [get_endpoints] interface: 2 pipe 1: dir: 3 number: \
4<br><br>The "dir" parameter has the value 3 = kUSBAnyDirn, and as it is used by \
get_endpoints to construct the endpoint address, the endpoint address recorded by \
libusb becomes 0x84 instead of 0x04 given by the device configuration during the \
enumeration.<br><br>Based on this, I tried to apply the following patch, which \
happened to correct the problem :<br><br>*** darwin_usb.c~ &nbsp; &nbsp; \
&nbsp;2014-03-15 17:27:20.000000000 +0100<br>--- darwin_usb.c &nbsp; &nbsp; &nbsp; \
&nbsp;2014-03-15 17:31:16.000000000 +0100<br>***************<br>*** 1126,1132 \
****<br> <br> usbi_dbg ("interface: %i pipe %i: dir: %i number: %i", iface, i, \
direction, number);<br> <br>! cInterface- &nbsp; &nbsp; &nbsp;&gt;endpoint_addrs[i - \
1] = ((direction &lt;&lt; 7 &amp; LIBUSB_ENDPOINT_DIR_MASK) | (number &amp; \
LIBUSB_ENDPOINT_ADDRESS_MASK));<br> }<br> <br> cInterface- &nbsp;&gt;num_endpoints = \
numep;<br>--- 1126,1132 ----<br> <br> usbi_dbg ("interface: %i pipe %i: dir: %i \
number: %i", iface, i, direction, number);<br> <br>! cInterface- &nbsp; &nbsp; \
&nbsp;&gt;endpoint_addrs[i - 1] = (((direction == kUSBIn) &lt;&lt; 7 &amp; \
LIBUSB_ENDPOINT_DIR_MASK) | (number &amp; LIBUSB_ENDPOINT_ADDRESS_MASK));<br> }<br> \
<br> cInterface- &nbsp;&gt;num_endpoints = \
numep;<br><br>------------------------------------------------------------------------------<br>Learn \
Graph Databases - Download FREE O'Reilly Book<br>"Graph Databases" is the definitive \
new guide to graph databases and their<br>applications. Written by three acclaimed \
leaders in the field,<br>this first edition is now available. Download your free book \
today!<br><a href="http://p.sf.net/sfu/13534_NeoTech" \
data-mce-href="http://p.sf.net/sfu/13534_NeoTech">http://p.sf.net/sfu/13534_NeoTech</a><br>_______________________________________________<br>libusb-devel \
mailing list<br><a href="mailto:libusb-devel@lists.sourceforge.net" \
data-mce-href="mailto:libusb-devel@lists.sourceforge.net">libusb-devel@lists.sourceforge.net</a><br><a \
href="https://lists.sourceforge.net/lists/listinfo/libusb-devel" \
data-mce-href="https://lists.sourceforge.net/lists/listinfo/libusb-devel">https://list \
s.sourceforge.net/lists/listinfo/libusb-devel</a><br></span></div></div></blockquote></div></blockquote></div><br></div></div></body></html>




------------------------------------------------------------------------------
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
&#149; 3 signs your SCM is hindering your productivity
&#149; Requirements for releasing software faster
&#149; Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce

_______________________________________________
libusb-devel mailing list
libusb-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusb-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic