From 04ccb770fd4527f3b0fa5a7c9404143bb9c9bbd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Redon?= Date: Thu, 2 Aug 2018 17:48:58 +0200 Subject: remsim: fix USB hanging USB transfer After a couple of seconds of USB data exchange between remsim and cardem, the USB transfer hangs. On host side (remsim) I can see the USB BULK IN request. On device side (cardem) I see that data has been submitted and "sent" over USB, but on wireshark with USBmon I don't see the corresponding USB BULK IN response. When exiting remsim or just after powering of qmod (causing an error in remsim) the USB BULK IN is show in wireshark. Thus it must have been in a buffer, but not read by libusb_bulk_transfer. By shortening the timeout a new libusb_bulk_transfer is made more frequently, and the data gets read successfully. T;his change also fixes the URB data display. Change-Id: I1d124a41cc90893506933f6d76dc7331e52a74f9 --- host/simtrace2-remsim.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/host/simtrace2-remsim.c b/host/simtrace2-remsim.c index 52c5051..9a681b4 100644 --- a/host/simtrace2-remsim.c +++ b/host/simtrace2-remsim.c @@ -536,7 +536,7 @@ static void run_mainloop(struct cardem_inst *ci) /* read data from SIMtrace2 device (local or via USB) */ if (transp->udp_fd < 0) { rc = libusb_bulk_transfer(transp->usb_devh, transp->usb_ep.in, - buf, sizeof(buf), &xfer_len, 100000); + buf, sizeof(buf), &xfer_len, 100); if (rc < 0 && rc != LIBUSB_ERROR_TIMEOUT && rc != LIBUSB_ERROR_INTERRUPTED && rc != LIBUSB_ERROR_IO) { @@ -553,7 +553,7 @@ static void run_mainloop(struct cardem_inst *ci) } /* dispatch any incoming data */ if (xfer_len > 0) { - printf("URB: %s\n", osmo_hexdump(buf, rc)); + printf("URB: %s\n", osmo_hexdump(buf, xfer_len)); process_usb_msg(ci, buf, xfer_len); msg_count++; byte_count += xfer_len; -- cgit v1.2.3