[PATCH] debug: scan I2C bus on startup

Steve Markgraf steve at steve-m.de
Sat Dec 7 15:26:38 UTC 2013


Signed-off-by: Steve Markgraf <steve at steve-m.de>
---
 src/librtlsdr.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/librtlsdr.c b/src/librtlsdr.c
index f08efd4..ee90817 100644
--- a/src/librtlsdr.c
+++ b/src/librtlsdr.c
@@ -1382,6 +1382,7 @@ int rtlsdr_open(rtlsdr_dev_t **out_dev, uint32_t index)
 	uint32_t device_count = 0;
 	struct libusb_device_descriptor dd;
 	uint8_t reg;
+	uint16_t addr;
 	ssize_t cnt;
 
 	dev = malloc(sizeof(rtlsdr_dev_t));
@@ -1469,6 +1470,17 @@ int rtlsdr_open(rtlsdr_dev_t **out_dev, uint32_t index)
 	/* Probe tuners */
 	rtlsdr_set_i2c_repeater(dev, 1);
 
+	fprintf(stderr, "I2C devices found:\n");
+
+	for (addr = 0; addr < 255; addr += 2) {
+		reg = 0;
+		r = rtlsdr_write_array(dev, IICB, addr, &reg, 1);
+		r = rtlsdr_read_array(dev, IICB, addr, &reg, 1);
+		if (r >= 0)
+			fprintf(stderr, "%02x ", addr);
+	}
+	fprintf(stderr, "\n");
+
 	reg = rtlsdr_i2c_read_reg(dev, E4K_I2C_ADDR, E4K_CHECK_ADDR);
 	if (reg == E4K_CHECK_VAL) {
 		fprintf(stderr, "Found Elonics E4000 tuner\n");
-- 
1.8.3.2


--------------000609080207050500040905--




More information about the osmocom-sdr mailing list