title: I2C reading in userland application
body: <p>I2c device is attached with OMAP L138 and made application to read i2c data. where OMAP L138 is master device and i2c device as slave device, i2c device is sending 2 bytes of data. I am able to read two i2c data bytes by using ioctl() and read function. In first attempt, i am able to read first two bytes but on second attempt, one byte is dropped and next two bytes are read. This result repeats on every consecutive reading of i2c device. How can i ensure that every consecutive reading should read every bytes without dropping any one byte?   </p>
  
  <p>code:  </p>
  
  <pre><code>void i2cread()
  {  
     int i2c_fd;  
     ssize_t byte;  
     char buffer[32];  
  
     i2c_fd=open("/dev/i2c-1",O_RDWR);  
     if(i2c_fd&lt;0) {  
        printf("File I2C Device Can't be Opened\n");  
        return -1;  
     }  
     else {  
        printf("File I2C Device is Opened\n");  
     }  
     if(ioctl(i2c_fd,I2C_SLAVE,0x48)&lt;0) {    
        printf("I2C Device Can't be Opened\n");    
        close(i2c_fd);    
        return -1;   
     }
     else {
        printf("I2C Device is Opened\n");
     }  
     byte=read(i2c_fd,buffer,2);  
     printf("%d. ",byte);  
     if(byte&lt;0){  
        printf("\n");  
     }  
     else  {  
       for(byte=0;byte&lt;2;byte++)  
          printf("%d ",buffer[byte]);  
       printf("\n");  
     }
  }  
  </code></pre>
  
  <p>Regards<br>
  Learner.  </p>