From ecc1a18331663f672751a160ea7c50d1fc56763c Mon Sep 17 00:00:00 2001 From: "Mark D. Studebaker" Date: Sat, 9 Feb 2002 16:34:13 +0000 Subject: [PATCH] add text printout; patch from Jean Delvare git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@1311 7894878c-1315-0410-8ee3-d5d059ff63e0 --- prog/dump/i2cdump.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/prog/dump/i2cdump.c b/prog/dump/i2cdump.c index 00823992..2c613a72 100644 --- a/prog/dump/i2cdump.c +++ b/prog/dump/i2cdump.c @@ -277,7 +277,7 @@ int main(int argc, char *argv[]) res += res2; } #else - fprintf(stderr, "Error: I2C block read unimplemented\n"); + fprintf(stderr, "Error: I2C block read unsupported in i2c-core\n"); exit(1); #endif } @@ -293,19 +293,32 @@ int main(int argc, char *argv[]) block[i] = -1; } - printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f\n"); + printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef\n"); for (i = 0; i < 256; i+=16) { printf("%02x: ",i); for(j = 0; j < 16; j++) { - if(size == I2C_SMBUS_BYTE_DATA) + if(size == I2C_SMBUS_BYTE_DATA) { res = i2c_smbus_read_byte_data(file,i+j); - else + block[i+j] = res; + } else res = block[i+j]; if (res < 0) printf("XX "); else printf("%02x ",res & 0xff); } + printf(" "); + for(j = 0; j < 16; j++) { + res = block[i+j]; + if (res < 0) + printf("X"); + else if (((res & 0xff) == 0x00) || ((res & 0xff) == 0xff)) + printf("."); + else if (((res & 0xff) < 32) || ((res & 0xff) >= 127)) + printf("?"); + else + printf("%c",res & 0xff); + } printf("\n"); } } else {