From 7840ec21d3c9a4a39ca6bbb3567e14caeccdb9f5 Mon Sep 17 00:00:00 2001 From: Steve Markgraf Date: Fri, 4 Jan 2013 21:26:43 +0100 Subject: [PATCH] lib: reset device if needed This improves the situation on hosts with flaky host controllers like the Raspberry Pi and the WR703N. Signed-off-by: Steve Markgraf --- src/librtlsdr.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/librtlsdr.c b/src/librtlsdr.c index cb1f3bc..50c536a 100644 --- a/src/librtlsdr.c +++ b/src/librtlsdr.c @@ -1344,6 +1344,12 @@ int rtlsdr_open(rtlsdr_dev_t **out_dev, uint32_t index) dev->rtl_xtal = DEF_RTL_XTAL_FREQ; + /* perform a dummy write, if it fails, reset the device */ + if (rtlsdr_write_reg(dev, USBB, USB_SYSCTL, 0x09, 1) < 0) { + fprintf(stderr, "Resetting device...\n"); + libusb_reset_device(dev->devh); + } + rtlsdr_init_baseband(dev); /* Probe tuners */