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 Wed 26 Nov 2014, 16:27
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 Posts_count  
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
Sub_title: 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: 523
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_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:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


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