Another USB question

Technical questions regarding the XTC tools and programming with XMOS.
Post Reply
mkassner
Member
Posts: 12
Joined: Mon Feb 13, 2012 10:54 pm

Another USB question

Post by mkassner »

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);
            }


	    }
	return;
}
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!

best,

moritz


User avatar
Ross
XCore Expert
Posts: 962
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

Sounds a bit odd..

What happens if you removed the reset checking code?
Post Reply