[SOLVED] i2c-1 device exist but cant open\ no such file or directory
Linux - Embedded & Single-board computerThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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?
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?
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.