Hi,
When i type i2cdetect -y 1
it shows devices attached with processor.
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
it means -- i2c device does not exist.
but when i try to open using
open("/dev/i2c-1","O_RDWR);
it is showing device is opened.
after that when calling ioctl, it is again showing successfully open device.
Can any one tell me, how to ensure if device is not attached and try to get status by opening that device, it should give error.
second more thing, if device is not existing, then why able to read using read function called for opened file description for such devices as shown -- in i2cdetect command.
Can anyone help me, what is it?
--------
Learner
i2c reading using command line and using coding
I think you misunderstand it. I ran it and it said
"Error: could not open file '/dev/itc-1' or '/dev/itc/1': No such file or directory"
(I haven't enabled I2C devices in my kernel yet.)
So clearly the message you get is not saying "device not present"...
Let's see what the man page says...
Ah, a device in /dev is a bus not a chip. If it can open the bus, i2cdetect lists the chips on that bus.
"Error: could not open file '/dev/itc-1' or '/dev/itc/1': No such file or directory"
(I haven't enabled I2C devices in my kernel yet.)
So clearly the message you get is not saying "device not present"...
Let's see what the man page says...
Ah, a device in /dev is a bus not a chip. If it can open the bus, i2cdetect lists the chips on that bus.
bash-3.00# ./tools/i2cdetect 0
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-0.
I will probe address range 0x03-0x77.
Continue? [Y/n] Y
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- 08 -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: 30 -- 32 -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- 44 -- -- -- -- -- -- -- -- -- -- --
50: 50 -- 52 -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- 69 -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
bash-3.00# ./tools/i2cdetect 1
Error: Could not open file `/dev/i2c-1' or `/dev/i2c/1': No such file or directory
BUT after
Ibidem : maybe you have old linux/*.h ?
Source Package: i2c-tools (3.1.0-2) from packages.debian.org
without the debian patch .
Puppy 4.3 .
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-0.
I will probe address range 0x03-0x77.
Continue? [Y/n] Y
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- 08 -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: 30 -- 32 -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- 44 -- -- -- -- -- -- -- -- -- -- --
50: 50 -- 52 -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- 69 -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
bash-3.00# ./tools/i2cdetect 1
Error: Could not open file `/dev/i2c-1' or `/dev/i2c/1': No such file or directory
BUT after
Code: Select all
modprobe -l |grep i2c | while read f ; do modprobe -v `basename $f .ko.gz` ; done
Source Package: i2c-tools (3.1.0-2) from packages.debian.org
without the debian patch .
Puppy 4.3 .