From 66d94323f88c30bdff1675c01d97c048ea3e750b Mon Sep 17 00:00:00 2001 From: Roboschmied Date: Thu, 7 Mar 2024 14:37:36 +0100 Subject: [PATCH 1/2] include last byte in i2cdetect output closes #115 --- src/i2cspi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/i2cspi.c b/src/i2cspi.c index 0821539..a78a1cf 100644 --- a/src/i2cspi.c +++ b/src/i2cspi.c @@ -200,7 +200,9 @@ static int i2cdetect(int argc, char **argv, bool script_mode) { unsigned char i2c_addr; printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f\n"); - for (i2c_addr = 0x0; i2c_addr < 0xff; ++i2c_addr) { + i2c_addr = 0xff; # will be 0x00 after first increment + do { + ++i2c_addr; int fd = prepare_i2c_sensor(i2c_addr); int res = i2c_read_register(fd, i2c_addr, 0, SELECT_WIDE(0), 1); @@ -221,7 +223,8 @@ static int i2cdetect(int argc, char **argv, bool script_mode) { close_sensor_fd(fd); hal_cleanup(); - } + } while (i2c_addr != 0xff); + printf("\n"); return EXIT_SUCCESS; From a006247cdf2e1128f832472313876b2cead74861 Mon Sep 17 00:00:00 2001 From: Roboschmied Date: Thu, 7 Mar 2024 15:05:56 +0100 Subject: [PATCH 2/2] fix comment sign to c --- src/i2cspi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i2cspi.c b/src/i2cspi.c index a78a1cf..d783d5f 100644 --- a/src/i2cspi.c +++ b/src/i2cspi.c @@ -200,7 +200,7 @@ static int i2cdetect(int argc, char **argv, bool script_mode) { unsigned char i2c_addr; printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f\n"); - i2c_addr = 0xff; # will be 0x00 after first increment + i2c_addr = 0xff; // will be 0x00 after first increment do { ++i2c_addr; int fd = prepare_i2c_sensor(i2c_addr);