Hello,
I'd like to get some hint for USB debugging.
I made an USB app based on the lib_usb doc and xud_cdc.xc.
It's a vendor specific device and has 1 bulk out and 2 bulk in endpoints.
I have tried to send and receive packets with pyusb and libusb (Linux).
Sending packets to the out endpoint works, but receiving one from the input endpoint fails immediately with I/O error.
In xC side the "result = XUD_SetReady_In(inEp, curTxPacket->data, curTxPacket->len);" call returns with 0, but "case XUD_SetData_Select(inCh, inEp, result)" is never unblocked.
In wireshark I see that for the "host->XMOS URB_BULK in" request there is a "XMOS->host URB_BULK in" response with "usb.urb_status = (-EPROTO) (-71)".
I'd like to figure out why XMOS replies with -71.
I made text searches on lib_usb for 71 in various forms (decimal, hexadecimal, 2's complement), but I found nothing except for a comment in a jump table.
I have also taken a look into the xud main loop, but I couldn't figure out it yet.
Has anyone some idea why the xud code could respond with -71 for "bulk in" request?
Thanks for any help!
lib_usb usb.urb_status = -71
-
- Active Member
- Posts: 38
- Joined: Fri Jan 01, 2016 10:13 am
-
- Active Member
- Posts: 38
- Joined: Fri Jan 01, 2016 10:13 am
I have recently found AN00136 (USB Vendor Specific Device). That could help.
-
- Active Member
- Posts: 38
- Joined: Fri Jan 01, 2016 10:13 am
I didn't go far with the tutorial yet. That uses the sync API while I try to use the async.
Meanwhile I have uploaded my source to here.
I have over-complicated it a little bit by adding XUD_STATUS_ENABLE to the endpoints and trying to hanlde XUD_RES_RST (it solved nothing).
Meanwhile I have uploaded my source to here.
I have over-complicated it a little bit by adding XUD_STATUS_ENABLE to the endpoints and trying to hanlde XUD_RES_RST (it solved nothing).
-
- Active Member
- Posts: 38
- Joined: Fri Jan 01, 2016 10:13 am
This simple task works, but works only when there is no debug_printf() in the loop:
So the debug_printf() could cause some USB timing issue. But removing debug_printf() from rxHandler() and txHandler() didn't help.
Code: Select all
void echoHandler(chanend outCh, chanend inCh) {
XUD_Result_t result;
uint8 buf[512];
unsigned len;
XUD_ep outEp = XUD_InitEp(outCh, XUD_EPTYPE_BUL);
XUD_ep inEp = XUD_InitEp(inCh, XUD_EPTYPE_BUL);
XUD_SetReady_Out(outEp, buf);
while (1) {
select {
case XUD_GetData_Select(outCh, outEp, len, result):
if (result == XUD_RES_OKAY) {
// debug_printf("%d bytes received.\n", len);
// send data back
XUD_SetReady_In(inEp,buf, len);
}
break;
case XUD_SetData_Select(inCh, inEp, result):
// debug_printf("packet sent.\n");
XUD_SetReady_Out(outEp, buf);
break;
}
}
}
-
- Active Member
- Posts: 38
- Joined: Fri Jan 01, 2016 10:13 am
Ahhhhh....
For make it working I had to remove debug_printf() from rxHandler() and txHandler() and also from echoTask() (please don't mix up echoTask() with echoHandler(), echoHandler() only presents in an other variant of the project).
I don't understand why debug_printf() in echoTask() caused problems. echoTask() runs on a different tile (not on the USB tile) and debug_printf() uses XTAG as an output device. So I don't understand how can it cause interference with the USB tasks and endpoints which are running on the USB tile.
My host side test app is even a simple one. It sends a packet than receives a response via a simple blocking API:
Can someone please give an explanation for this anomaly?
For make it working I had to remove debug_printf() from rxHandler() and txHandler() and also from echoTask() (please don't mix up echoTask() with echoHandler(), echoHandler() only presents in an other variant of the project).
I don't understand why debug_printf() in echoTask() caused problems. echoTask() runs on a different tile (not on the USB tile) and debug_printf() uses XTAG as an output device. So I don't understand how can it cause interference with the USB tasks and endpoints which are running on the USB tile.
My host side test app is even a simple one. It sends a packet than receives a response via a simple blocking API:
Code: Select all
import os
import usb.core
devs = usb.core.find(find_all=True, idVendor=0x20b1, idProduct=0x500)
deva = []
for dev in devs:
deva.append(dev)
print str(dev)
assert len(deva)
dev = deva[0]
dev.set_configuration()
for i in range(32):
text = "Hello XMOS! cnt:{}".format(i)
print "Sending: {}".format(text)
dev.write(1, text)
ret = dev.read(0x81, 256, 1000)
sret = ''.join([chr(x) for x in ret])
print "Received: {}".format(sret)