[i2c] i2c I/O remote error
Arnold
abo_gwapo at yahoo.com
Wed Aug 30 09:37:23 CEST 2006
Hi Guys,
I'm using an omap5912 and would like to write and
read
thru i2c. I also can not see any sensor in
/proc/sys/dev/ and there is no /proc/bus/. Could there
be something wrong with my addressing on I2C? I hope
there is someone who knows my problem? Thanks in
advance.
Below are the debug msg aswell as the
code.
Debug msg:
#./i2c_test
adapter number = OMAP I2C adapter
Error: Remote I/O error
written -1 bytes
Code:
#define I2C_SLAVE 0x0703
#define BUFFER_SIZE 32
int adapter_nr = 0;
int addr = 0x40; /* The I2C address */
sprintf(filename,"/dev/i2c-%d",adapter_nr);
if ((file = open(filename,O_RDWR)) < 0) {
printf("Error Opening File\n");
exit(1);
}
if (ioctl(file,I2C_SLAVE,addr) < 0) {
exit(1);
}
if (write(file,buffer,sizeof(char) * BUFFER_SIZE) <
0)
{
perror("Error Writing:");
exit(1);
}
printf("written %d bytes\n",i);
memset(buffer,0,BUFFER_SIZE);
if(read(file,buffer,sizeof(char) * BUFFER_SIZE) <
0
) {
perror("Error Reading:");
exit(1);
}
printf("read %d bytes\n",i);
for(i=0;i<BUFFER_SIZE;i++)
{
printf("%c",buffer[i]);
}
printf("\n");
close(file);
Thanks,
OJ
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the i2c
mailing list