LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 10-13-2014, 01:15 AM   #1
ylmzekrm
LQ Newbie
 
Registered: Oct 2014
Posts: 4

Rep: Reputation: Disabled
i2c-1 device exist but cant open\ no such file or directory


I have a little problem about my app.

Firstly I install package i2c-tools,
I give all permission to all user for dev/i2c* files.
After, add the line i2c-dev in etc/modules file
i2c devices are exist in /dev/ directory.

I guess problem is in my C code:
Code:
int fd = open("/dev/i2c-1", O_RDWR);
returns -1 value and it give errno:2 No such file or directory.

Anyone has a suggestions, whats the problem I couldnt found?
Below i2cdetect, device and permission output.

Code:
root@arge16-HP-600B:/home/arge1-6# i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- 37 -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- 49 -- -- -- -- -- -- 
50: 50 -- -- -- -- -- -- -- -- 59 -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --
Code:
root@arge16-HP-600B:/home/arge1-6# i2cdetect -l
i2c-0   i2c         i915 gmbus ssc                      I2C adapter
i2c-1   i2c         i915 gmbus vga                      I2C adapter
i2c-2   i2c         i915 gmbus panel                    I2C adapter
i2c-3   i2c         i915 gmbus dpc                      I2C adapter
i2c-4   i2c         i915 gmbus dpb                      I2C adapter
i2c-5   i2c         i915 gmbus dpd                      I2C adapter
i2c-6   i2c         DPDDC-B
I2C adapter

Code:
root@arge16-HP-600B:/home/arge1-6# ls -l /dev/i2c*
crw-rw-rw- 1 root i2c 89, 0 Oct  2 14:36 /dev/i2c-0
crw-rw-rw- 1 root i2c 89, 1 Oct  2 14:36 /dev/i2c-1
crw-rw-rw- 1 root i2c 89, 2 Oct  2 14:36 /dev/i2c-2
crw-rw-rw- 1 root i2c 89, 3 Oct  2 14:36 /dev/i2c-3
crw-rw-rw- 1 root i2c 89, 4 Oct  2 14:36 /dev/i2c-4
crw-rw-rw- 1 root i2c 89, 5 Oct  2 14:36 /dev/i2c-5
crw-rw-rw- 1 root i2c 89, 6 Oct  2 14:36 /dev/i2c-6

Last edited by ylmzekrm; 10-13-2014 at 01:17 AM.
 
Old 10-13-2014, 02:45 AM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,259

Rep: Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321
You seem to have a module picking up the hardware. This may be an ignorant question, but have you one for a protocol to talk down that hardware. Do the other ones work?
 
Old 10-13-2014, 03:21 AM   #3
ylmzekrm
LQ Newbie
 
Registered: Oct 2014
Posts: 4

Original Poster
Rep: Reputation: Disabled
business_kid I try other no changes there/ No such file or directory.
I asked for this issue in many forums I couldnt get any solution

I try other
Code:
int fd = open("/dev/i2c-1", O_RDWR);
int fd = open("/dev/i2c-2", O_RDWR);
int fd = open("/dev/i2c-3", O_RDWR);
I get
Code:
errno:2 No such file or directory
but I have this device.

Last edited by ylmzekrm; 10-13-2014 at 10:16 AM. Reason: edit
 
Old 10-14-2014, 02:51 AM   #4
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,259

Rep: Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321
What protocol are you talking? If you take a look in your kernel's Documentation/i2c, you will see documents on protocols and clients. Have a look there. The protocol is the file format or language that the cl;ient speaks.

As we are on i2c, some obvious questions: Is port 1 on the same bank as the others. What about i2c-0? Does it need initialization. What makes it different from the others?
 
1 members found this post helpful.
Old 10-20-2014, 01:27 PM   #5
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Quote:
Originally Posted by ylmzekrm View Post
business_kid I try other no changes there/ No such file or directory.
I asked for this issue in many forums I couldnt get any solution

I try other
Code:
int fd = open("/dev/i2c-1", O_RDWR);
int fd = open("/dev/i2c-2", O_RDWR);
int fd = open("/dev/i2c-3", O_RDWR);
I get
Code:
errno:2 No such file or directory
but I have this device.
That's exactly how to do it. I'm sure you've looked after recommendations for I2C Linux source examples. Running this as root? If those devices exist in the system, those open calls should work. I guess also make sure that no other resources are using them, but honestly I'd expect you to get an EACCESS error. I sort of wish that strerror() would also give you the name of the type define symbol versus the string, because I always have to look and find errno.h to validate that it maps to E{whatever}, so my added suggestion is to make sure that 2 does in your system and compile case correspond to the "no such file or directory". That would seem to be ENOENT as called out by the manpage for open(2), but if you look at possible errors from that function, it is highly varied.

I also would say that many, many times with such a varied utility function as open(2) I see general complaints like this and they're not general complaints. For what it's worth, you seem to be doing things correctly. See also if you can download some I2C application, even the source for i2cdetect and see if it's doing an open() and how that works, if not that you have to do it all as root.
 
1 members found this post helpful.
Old 10-30-2014, 02:30 AM   #6
ylmzekrm
LQ Newbie
 
Registered: Oct 2014
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thansk for assist friends, i2c-1 device opened, it was about permission and I solved it with your suggestions.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
fatal error: goo/gmem.h: No such file or directory; but file does exist!! lgoldma Linux - General 3 03-07-2013 04:00 PM
i2c character device file not created in linux 2.6.24 on at91sam9263ek john_schimandle Linux - Kernel 5 05-27-2010 11:03 AM
Unable to open the device /dev/i2c-0 avyadavnitw Linux - Embedded & Single-board computer 3 06-29-2009 03:31 AM
Cannot open master raw device '/dev/rawctl' (No such file or directory) ayyappa1 Linux - Hardware 1 03-27-2009 08:19 AM
torsmo error scandir for /sys/bus/i2c/devices/: No such file or directory KaZiber Linux - General 2 04-17-2005 02:41 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 10:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration