#include #include #include #include #define DEV "/dev/i2c/0" int main() { int fd; fd = open(DEV, O_RDWR); if (fd < 0) perror("open"); int address=0x20; unsigned char buf[]="plaa"; while (1) { // for (address=0; address<0x7F; address++) { if (ioctl(fd, I2C_SLAVE, address) < 0) perror("ioctl"); if (read(fd, buf, 1) != 1) { perror("read"); printf("%02x-", address); } else printf("%02x+ %02x ", address, buf[0]); //if ((address & 0x0F) == 0x0F) printf("\n"); // } usleep(200000); } return 0; }