Page 1 of 1

Another USB question

Posted: Fri Apr 13, 2012 5:10 pm
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

Re: Another USB question

Posted: Wed Apr 18, 2012 2:48 pm
by Ross
Sounds a bit odd..

What happens if you removed the reset checking code?