Another USB question

Technical questions regarding the xTIMEcomposer, xSOFTip Explorer and Programming with XMOS.
Posts: 12
Joined: Mon Feb 13, 2012 10:54 pm

Another USB question

Postby mkassner » Fri Apr 13, 2012 5:10 pm

Dear Forum,

actually, two questions:

1: using the non-interrupt usb lib, can I probe a xud_ep if new data is available before calling XUS_Get_Buffer?
- Im guessing not... thats why there is the interrupt based lib.

2. I wrote this small echo thread:

Code: Select all

void usb_echo(chanend chan_ep1_out,chanend chan_ep1_in){
     XUD_ep c_ep_out = XUD_Init_Ep(chan_ep1_out);
     XUD_ep c_ep_in  = XUD_Init_Ep(chan_ep1_in);
       char mybuffer[518];
       int len;
       while(1) {
           len = XUD_GetBuffer(c_ep_out, mybuffer);
           if (len < 0) {
               XUD_ResetEndpoint(c_ep_out, null);
           len = XUD_SetBuffer(c_ep_in, mybuffer,32);
           if (len < 0) {
                 XUD_ResetEndpoint(c_ep_in, null);


Using libusb:
- I open the device, set the configuration, claim the interface
for x times:
- I write 32 byte
- I read 32 byte
finally I release the interface and close the device.

If x is even I can do this repeatedly.
If x is odd the first write fails (timeout) every second time I run the program.

I don't quite understand why this is. I f I just sink data without echo on the xmos, the number of transfers can be even or odd.

I know that this could have nothing to do this the xmos usb lib and just be me failing to understand a subtlety of usb in general...

help is greatly appreciated!


User avatar
XCore Expert
Posts: 738
Joined: Thu Dec 10, 2009 9:20 pm

Postby Ross » Wed Apr 18, 2012 2:48 pm

Sounds a bit odd..

What happens if you removed the reset checking code?

Return to “Development Tools and Programming”

Who is online

Users browsing this forum: No registered users and 14 guests