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

List:       libusb-devel
Subject:    Re: [libusb] using libusb with multiple endpoints
From:       ALAN BALL via libusb-devel <libusb-devel () lists ! sourceforge ! net>
Date:       2019-07-17 15:53:52
Message-ID: 1142542414.3827391.1563378832202 () mail ! yahoo ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


 Dear All,

I've been able to write a c++ program based on winusb that can write/read to either \
of my interfaces and was able to check that everything worked OK on a USB protocol \
analyser (ACK response) and no error messages were returned by the software.

I have been unable to do the same thing with libusb.

How often are new software releases issued?

Regards,

Alan     On Thursday, 11 July 2019, 16:37:40 BST, ALAN BALL via libusb-devel \
<libusb-devel@lists.sourceforge.net> wrote:    
  Dear All,

I've been able to modify Jan Axelson's winusb C# example \
(http://janaxelson.com/winusb.htm ) to write a packet to either of my interfaces. The \
raw data was checked on a USB protocol analyser.

I have been unable to do the same thing using libusb.

Any suggestions?

Regards,

Alan
     On Thursday, 11 July 2019, 08:49:02 BST, ALAN BALL <adball24@btinternet.com> \
wrote:    
  Dear All,

I'm currently working on an embedded device with high speed USB. My microcontroller \
should ennumerate as a composite device with 4 interfaces: a virtual COM port \
(interface 0 and 1 using CDC) and 2 libusb interfaces (interfaces 2 and 3). I've \
attached the C file containing my USB descriptors as well as USB device tree viewer's \
output.

On the PC side (Windows), I set the debug level to 4 with libusb_set_debug.

When I search for the list of connected devices with libusb_get_device_list, my \
interfaces 2 and 3 are mentionned in the debug output, see attached Word document. If \
I run the print_dev function (found here: \
https://www.dreamincode.net/forums/topic/148707-introduction-to-using-libusb-10 ) \
which is based around libusb_get_device_descriptor and libusb_get_config_descriptor, \
libusb can fine my 4 interfaces:

Vendor: 1fc9 Product Id: 8a[ 0.374771] [00003ec4] libusb: debug \
[libusb_get_config_descriptor] index 0 [ 0.374771] [00003ec4] libusb: debug \
[parse_endpoint] skipping descriptor b  interfaces: 4
[ 0.381787] [00003ec4] libusb: debug [libusb_get_device_descriptor]
Number of possible configurations: 1 Device Class: ef VendorID: 1fc9 ProductID: 8a
[ 0.387803] [00003ec4] libusb: debug [libusb_get_config_descriptor] index 0
[ 0.388806] [00003ec4] libusb: debug [parse_endpoint] skipping descriptor b
Interfaces: 4 | Number of alternate settings: 1
Interface Number: 2 | Number of endpoints: 2 | Descriptor Type: 5 | EP Address: 2 | \
Descriptor Type: 5 | EP Address: 82 | Number of alternate settings: 1 Interface \
Number: 3 | Number of endpoints: 2 | Descriptor Type: 5 | EP Address: 4 | Descriptor \
Type: 5 | EP Address: 84 | Number of alternate settings: 1 Interface Number: 0 | \
Number of endpoints: 1 | Descriptor Type: 5 | EP Address: 83 | Number of alternate \
settings: 1 Interface Number: 1 | Number of endpoints: 2 | Descriptor Type: 5 | EP \
Address: 1 | Descriptor Type: 5 | EP Address: 81 |

I then try to communicate with my device:
1) libusb_get_device_list, to get list of connected devices
2) iterate through list to find my device's Vendor ID using \
libusb_get_device_descriptor 3) open device handle with libusb_open
4) claim interface 2 with libusb_claim_interface
5) try to do a bulk transfer to endpoint 2 with libusb_bulk_transfer
6) close device handle with libusb_close

Here is the debug output for the above:

Vendor: 1fc9 Product Id: 8a[ 0.329985] [000050c4] libusb: debug \
[libusb_get_config_descriptor] index 0 [ 0.330486] [000050c4] libusb: debug \
[parse_endpoint] skipping descriptor b  interfaces: 4
[ 0.333997] [000050c4] libusb: debug [libusb_open] open 2.18
[ 0.334497] [000050c4] libusb: debug [libusb_claim_interface] interface 2
[ 0.334497] [000050c4] libusb: debug [winusbx_claim_interface] claimed interface 2
[ 0.334999] [000050c4] libusb: debug [parse_endpoint] skipping descriptor b
[ 0.335500] [000050c4] libusb: debug [windows_assign_endpoints] (re)assigned endpoint \
83 to interface 2 [ 0.336001] [000050c4] libusb: debug [libusb_alloc_transfer] \
transfer 03A09D54 [ 0.336001] [000050c4] libusb: debug [libusb_submit_transfer] \
transfer 03A09D54 [ 0.336503] [000050c4] libusb: error \
[composite_submit_bulk_transfer] unable to match endpoint to an open interface - \
cancelling transfer [ 0.337505] [000050c4] libusb: debug [libusb_free_transfer] \
transfer 03A09D54 Endpoint 2: Write Error
[ 0.340013] [000050c4] libusb: debug [libusb_close]

As you can see, for some strange reason endpoint 83 has been reassigned to interface \
2 and libusb has been unable to do a bulk transfer.

Any advice on this? Thanks in advance for any suggestions.

Regards,

Alan    ----- Forwarded message ----- From: ALAN BALL <adball24@btinternet.com>To: \
Tim Roberts <timr@probo.com>Sent: Thursday, 11 July 2019, 07:57:45 BSTSubject: Re: \
[libusb] using libusb with multiple endpoints  

Hi Tim,

Thank you once again for your email.

I haven't changed my descriptors, see C file attached. I've attached my USBtree \
output at well as the debug output of my program.

Regards,

Alan     On Thursday, 11 July 2019, 01:28:48 BST, Tim Roberts <timr@probo.com> wrote: \
  
 ALAN BALL wrote:
> 
> I was able to output the following:
> 
> Vendor: 1fc9 Product Id: 8a interfaces: 4
> Number of possible configurations: 1 Device Class: ef VendorID: 1fc9 
> ProductID: 8a
> Interfaces: 4 | Number of alternate settings: 1
> Interface Number: 2 | Number of endpoints: 2 | Descriptor Type: 5 | EP 
> Address: 2 | Descriptor Type: 5 | EP Address: 82 | Number of alternate 
> settings: 1
> Interface Number: 3 | Number of endpoints: 2 | Descriptor Type: 5 | EP 
> Address: 4 | Descriptor Type: 5 | EP Address: 84 | Number of alternate 
> settings: 1
> Interface Number: 0 | Number of endpoints: 1 | Descriptor Type: 5 | EP 
> Address: 83 | Number of alternate settings: 1
> Interface Number: 1 | Number of endpoints: 2 | Descriptor Type: 5 | EP 
> Address: 1 | Descriptor Type: 5 | EP Address: 81 |
> 
> Based on this, it would appear that libusb is able to pickup my 4 
> interfaces correctly and I need to get a better understanding of the 
> libusb structs...

I'm confused.   There's no reason why we should see the "(re)assigned 
endpoint 0x83 to interface 2".   I notice that the interfaces above are 
in a different order than the descriptors you sent me.   Have you 
rearranged things?   It's not supposed to make a difference with WinUSB, 
although the Windows driver APIs do refer to interfaces by their 
"ordinal" within the list rather than interface number.

Perhaps you should post your current usbtreeview output and your 
annotated/highlighted debug output to the mailing list.   It certainly 
looks like a libusb bug, although in 15 minutes with the source code, I 
couldn't find anything.

-- 
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

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


[Attachment #5 (text/html)]

<div>                Dear All,<br><br>I&#39;ve been able to write a c++ program based \
on winusb that can write/read to either of my interfaces and was able to check that \
everything worked OK on a USB protocol analyser (ACK response) and no error messages \
were returned by the software.<br><br>I have been unable to do the same thing with \
libusb.<br><br>How often are new software releases \
issued?<br><br>Regards,<br><br>Alan            </div>            <div \
class="yahoo_quoted" style="margin: 10px 0px 0px 0.8ex; padding-left: 1ex; \
border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: \
solid;">                        <div style='color: rgb(38, 40, 42); font-family: \
"Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;'>                    \
<div>                    On Thursday, 11 July 2019, 16:37:40 BST, ALAN BALL via \
libusb-devel &lt;libusb-devel@lists.sourceforge.net&gt; wrote:                </div>  \
<div><br></div>                <div><br></div>                <div><div \
id="yiv5938279566"><div><div>                Dear All,<br clear="none"><br \
clear="none">I've been able to modify Jan Axelson's winusb C# example \
(http://janaxelson.com/winusb.htm ) to write a packet to either of my interfaces. The \
raw data was checked on a USB protocol analyser.<br clear="none"><br clear="none">I \
have been unable to do the same thing using libusb.<br clear="none"><br \
clear="none">Any suggestions?<br clear="none"><br clear="none">Regards,<br \
clear="none"><br clear="none">Alan<br clear="none">            </div>            <div \
class="yiv5938279566yqt1821157216" id="yiv5938279566yqt22391"><div \
class="yiv5938279566yahoo_quoted" style="margin: 10px 0px 0px 0.8ex; padding-left: \
1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; \
border-left-style: solid;">                        <div style="color: rgb(38, 40, \
42);">                                <div>                    On Thursday, 11 July \
2019, 08:49:02 BST, ALAN BALL &lt;adball24@btinternet.com&gt; wrote:                \
</div>                <div><br clear="none"></div>                <div><br \
clear="none"></div>                <div><div id="yiv5938279566"><div><div>            \
Dear All,<br clear="none"><br clear="none">I'm currently working on an embedded \
device with high speed USB. My microcontroller should ennumerate as a composite \
device with 4 interfaces: a virtual COM port (interface 0 and 1 using CDC) and 2 \
libusb interfaces (interfaces 2 and 3). I've attached the C file containing my USB \
descriptors as well as USB device tree viewer's output.<br clear="none"><br \
clear="none">On the PC side (Windows), I set the debug level to 4 with \
libusb_set_debug.<br clear="none"><br clear="none">When I search for the list of \
connected devices with libusb_get_device_list, my interfaces 2 and 3 are mentionned \
in the debug output, see attached Word document. If I run the print_dev function \
(found here: https://www.dreamincode.net/forums/topic/148707-introduction-to-using-libusb-10 \
) which is based around libusb_get_device_descriptor and \
libusb_get_config_descriptor, libusb can fine my 4 interfaces:<br clear="none"><br \
clear="none">Vendor: 1fc9 Product Id: 8a[ 0.374771] [00003ec4] libusb: debug \
[libusb_get_config_descriptor] index 0<br clear="none">[ 0.374771] [00003ec4] libusb: \
debug [parse_endpoint] skipping descriptor b<br clear="none"> interfaces: 4<br \
clear="none">[ 0.381787] [00003ec4] libusb: debug [libusb_get_device_descriptor]<br \
clear="none">Number of possible configurations: 1  Device Class: ef  VendorID: 1fc9  \
ProductID: 8a<br clear="none">[ 0.387803] [00003ec4] libusb: debug \
[libusb_get_config_descriptor] index 0<br clear="none">[ 0.388806] [00003ec4] libusb: \
debug [parse_endpoint] skipping descriptor b<br clear="none">Interfaces: 4 | Number \
of alternate settings: 1<br clear="none">Interface Number: 2 | Number of endpoints: 2 \
| Descriptor Type: 5 | EP Address: 2 | Descriptor Type: 5 | EP Address: 82 | Number \
of alternate settings: 1<br clear="none">Interface Number: 3 | Number of endpoints: 2 \
| Descriptor Type: 5 | EP Address: 4 | Descriptor Type: 5 | EP Address: 84 | Number \
of alternate settings: 1<br clear="none">Interface Number: 0 | Number of endpoints: 1 \
| Descriptor Type: 5 | EP Address: 83 | Number of alternate settings: 1<br \
clear="none">Interface Number: 1 | Number of endpoints: 2 | Descriptor Type: 5 | EP \
Address: 1 | Descriptor Type: 5 | EP Address: 81 |<br clear="none"><br clear="none">I \
then try to communicate with my device:<br clear="none">1) libusb_get_device_list, to \
get list of connected devices<br clear="none">2) iterate through list to find my \
device's Vendor ID using libusb_get_device_descriptor<br clear="none">3) open device \
handle with libusb_open<br clear="none">4) claim interface 2 with \
libusb_claim_interface<br clear="none">5) try to do a bulk transfer to endpoint 2 \
with libusb_bulk_transfer<br clear="none">6) close device handle with libusb_close<br \
clear="none"><br clear="none">Here is the debug output for the above:<br \
clear="none"><br clear="none">Vendor: 1fc9 Product Id: 8a[ 0.329985] [000050c4] \
libusb: debug [libusb_get_config_descriptor] index 0<br clear="none">[ 0.330486] \
[000050c4] libusb: debug [parse_endpoint] skipping descriptor b<br clear="none"> \
interfaces: 4<br clear="none">[ 0.333997] [000050c4] libusb: debug [libusb_open] open \
2.18<br clear="none">[ 0.334497] [000050c4] libusb: debug [libusb_claim_interface] \
interface 2<br clear="none">[ 0.334497] [000050c4] libusb: debug \
[winusbx_claim_interface] claimed interface 2<br clear="none">[ 0.334999] [000050c4] \
libusb: debug [parse_endpoint] skipping descriptor b<br clear="none">[ 0.335500] \
[000050c4] libusb: debug [windows_assign_endpoints] (re)assigned endpoint 83 to \
interface 2<br clear="none">[ 0.336001] [000050c4] libusb: debug \
[libusb_alloc_transfer] transfer 03A09D54<br clear="none">[ 0.336001] [000050c4] \
libusb: debug [libusb_submit_transfer] transfer 03A09D54<br clear="none">[ 0.336503] \
[000050c4] libusb: error [composite_submit_bulk_transfer] unable to match endpoint to \
an open interface - cancelling transfer<br clear="none">[ 0.337505] [000050c4] \
libusb: debug [libusb_free_transfer] transfer 03A09D54<br clear="none">Endpoint 2: \
Write Error<br clear="none">[ 0.340013] [000050c4] libusb: debug [libusb_close]<br \
clear="none"><br clear="none">As you can see, for some strange reason endpoint 83 has \
been reassigned to interface 2 and libusb has been unable to do a bulk transfer.<br \
clear="none"><br clear="none">Any advice on this? Thanks in advance for any \
suggestions.<br clear="none"><br clear="none">Regards,<br clear="none"><br \
clear="none">Alan            </div>            <div \
class="yiv5938279566yqt4986812339" id="yiv5938279566yqt90776"><div \
class="yiv5938279566yahoo_quoted" style="margin: 10px 0px 0px 0.8ex; padding-left: \
1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; \
border-left-style: solid;">                        <div style="color: rgb(38, 40, \
42);">                <div>----- Forwarded message -----</div>                \
<div><b>From:</b> ALAN BALL &lt;adball24@btinternet.com&gt;</div><div><b>To:</b> Tim \
Roberts &lt;timr@probo.com&gt;</div><div><b>Sent:</b> Thursday, 11 July 2019, \
07:57:45 BST</div><div><b>Subject:</b> Re: [libusb] using libusb with multiple \
endpoints</div><div><br clear="none"></div>                <div><div \
id="yiv5938279566"><div><div>                <br clear="none"><br clear="none">Hi \
Tim,<br clear="none"><br clear="none">Thank you once again for your email.<br \
clear="none"><br clear="none">I haven't changed my descriptors, see C file attached. \
I've attached my USBtree output at well as the debug output of my program.<br \
clear="none"><br clear="none">Regards,<br clear="none"><br clear="none">Alan          \
</div>            <div class="yiv5938279566yqt3648089805" \
id="yiv5938279566yqt70547"><div class="yiv5938279566yahoo_quoted" style="margin: 10px \
0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); \
border-left-width: 1px; border-left-style: solid;">                                   \
<div style="color: rgb(38, 40, 42);">                                <div>            \
On Thursday, 11 July 2019, 01:28:48 BST, Tim Roberts &lt;timr@probo.com&gt; wrote:    \
</div>                <div><br clear="none"></div>                <div><br \
clear="none"></div>                <div><div dir="ltr">ALAN BALL wrote:<br \
clear="none">&gt;<br clear="none">&gt; I was able to output the following:<br \
clear="none">&gt;<br clear="none">&gt; Vendor: 1fc9 Product Id: 8a interfaces: 4<br \
clear="none">&gt; Number of possible configurations: 1 Device Class: ef VendorID: \
1fc9 <br clear="none">&gt; ProductID: 8a<br clear="none">&gt; Interfaces: 4 | Number \
of alternate settings: 1<br clear="none">&gt; Interface Number: 2 | Number of \
endpoints: 2 | Descriptor Type: 5 | EP <br clear="none">&gt; Address: 2 | Descriptor \
Type: 5 | EP Address: 82 | Number of alternate <br clear="none">&gt; settings: 1<br \
clear="none">&gt; Interface Number: 3 | Number of endpoints: 2 | Descriptor Type: 5 | \
EP <br clear="none">&gt; Address: 4 | Descriptor Type: 5 | EP Address: 84 | Number of \
alternate <br clear="none">&gt; settings: 1<br clear="none">&gt; Interface Number: 0 \
| Number of endpoints: 1 | Descriptor Type: 5 | EP <br clear="none">&gt; Address: 83 \
| Number of alternate settings: 1<br clear="none">&gt; Interface Number: 1 | Number \
of endpoints: 2 | Descriptor Type: 5 | EP <br clear="none">&gt; Address: 1 | \
Descriptor Type: 5 | EP Address: 81 |<br clear="none">&gt;<br clear="none">&gt; Based \
on this, it would appear that libusb is able to pickup my 4 <br clear="none">&gt; \
interfaces correctly and I need to get a better understanding of the <br \
clear="none">&gt; libusb structs...<br clear="none"><br clear="none">I'm \
confused.&nbsp; There's no reason why we should see the "(re)assigned <br \
clear="none">endpoint 0x83 to interface 2".&nbsp; I notice that the interfaces above \
are <br clear="none">in a different order than the descriptors you sent me.&nbsp; \
Have you <br clear="none">rearranged things?&nbsp; It's not supposed to make a \
difference with WinUSB, <br clear="none">although the Windows driver APIs do refer to \
interfaces by their <br clear="none">"ordinal" within the list rather than interface \
number.<br clear="none"><br clear="none">Perhaps you should post your current \
usbtreeview output and your <br clear="none">annotated/highlighted debug output to \
the mailing list.&nbsp; It certainly <br clear="none">looks like a libusb bug, \
although in 15 minutes with the source code, I <br clear="none">couldn't find \
anything.<div class="yiv5938279566yqt2516472012" id="yiv5938279566yqtfd12633"><br \
clear="none"><br clear="none">-- <br clear="none">Tim Roberts, <a \
href="mailto:timr@probo.com" target="_blank" rel="nofollow" shape="rect" \
ymailto="mailto:timr@probo.com">timr@probo.com</a><br clear="none">Providenza &amp; \
Boekelheide, Inc.<br clear="none"><br clear="none"></div></div></div>            \
</div>                        </div></div></div></div></div>            </div>        \
</div></div></div></div></div>            </div>                \
</div></div></div></div><div class="yqt1821157216" \
id="yqt28984">_______________________________________________<br \
clear="none">libusb-devel mailing list<br clear="none"><a \
href="mailto:libusb-devel@lists.sourceforge.net" shape="rect" \
ymailto="mailto:libusb-devel@lists.sourceforge.net">libusb-devel@lists.sourceforge.net</a><br \
clear="none"><a href="https://lists.sourceforge.net/lists/listinfo/libusb-devel" \
target="_blank" shape="rect">https://lists.sourceforge.net/lists/listinfo/libusb-devel</a><br \
clear="none"></div></div>            </div>                </div>





_______________________________________________
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