Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 23 Oct 2014, 17:30
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
i2c reading using command line and using coding
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [4 Posts]  
Author Message
learner

Joined: 23 May 2013
Posts: 5

PostPosted: Thu 06 Jun 2013, 02:56    Post subject:  i2c reading using command line and using coding
Subject description: i2c reading using command line and using c coding
 

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
Back to top
View user's profile Send private message 
Ibidem

Joined: 25 May 2010
Posts: 501
Location: State of Jefferson

PostPosted: Sat 08 Jun 2013, 09:45    Post subject:  

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.
Back to top
View user's profile Send private message 
Karl Godt


Joined: 20 Jun 2010
Posts: 3972
Location: Kiel,Germany

PostPosted: Sat 08 Jun 2013, 10:57    Post subject:  

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
Code:
modprobe -l |grep i2c | while read f ; do modprobe -v `basename $f .ko.gz` ; done


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 .
Back to top
View user's profile Send private message Visit poster's website 
learner

Joined: 23 May 2013
Posts: 5

PostPosted: Mon 17 Jun 2013, 21:20    Post subject:  

Hi,
I clearly mentioned that i am able to open i2c device file and again able to get control using ioctl. how am i able to get control of i2c? why is not showing any error for devices, which are not connected i2c bus?
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [4 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0584s ][ Queries: 11 (0.0174s) ][ GZIP on ]