Hi,
I'm wondering what files I need to include in a user application to
access a char device using the open(), ioctl(), write(), etc.
Searching the web, it seems like I need some combination of these files:
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include <sys/ioctl.h>
The driver in question is the i2c-dev driver, and the documentation
instructs you to include the i2c-dev.h included with the lm_sensors
package, so I'm including /user/lm_sensors/kernel/include/i2c-dev.h,
which itself takes care of
#include <linux/types.h>
#include <sys/ioctl.h>
However, using file = open("/dev/i2c",O_RDWR) gives a O_RDWR undefined
error. To solve this problem, I tried adding #include<fcntl.h>, but
this gives a long list of errors.
I'm using CodeSourcery G++ for uClinux, here's a portion of the build output:
Invoking: GCC C Compiler
m68k-uclinux-gcc -O0 -g3 -Wall -c -fmessage-length=0 -mcpu=5275 -MMD
-MP -MF"i2cTest.d" -MT"i2cTest.d" -o"i2cTest.o" "../i2cTest.c"
In file included from
/home/rr/CodeSourcery/Sourcery_G++/bin/../m68k-uclinux/libc/usr/include/pthread.h:21,
from
/home/rr/CodeSourcery/Sourcery_G++/bin/../m68k-uclinux/libc/usr/include/bits/uClibc_mutex.h:15,
from
/home/rr/CodeSourcery/Sourcery_G++/bin/../m68k-uclinux/libc/usr/include/bits/uClibc_stdio.h:119,
from
/home/rr/CodeSourcery/Sourcery_G++/bin/../m68k-uclinux/libc/usr/include/stdio.h:72,
from ../i2cTest.c:2:
/home/rr/CodeSourcery/Sourcery_G++/bin/../m68k-uclinux/libc/usr/include/time.h:105:
error: conflicting types for 'timer_t'
/home/rr/CodeSourcery/Sourcery_G++/bin/../m68k-uclinux/libc/usr/include/linux/types.h:22:
error: previous declaration of 'timer_t' was here
/home/rr/CodeSourcery/Sourcery_G++/bin/../m68k-uclinux/libc/usr/include/sys/types.h:62:
error: conflicting types for 'dev_t'
/home/rr/CodeSourcery/Sourcery_G++/bin/../m68k-uclinux/libc/usr/include/linux/types.h:13:
error: previous declaration of 'dev_t' was here
....
That goes on for a while, with lots more conflicting types. It also
gives an implicit declaration warning, which I'm not sure is a problem
or not:
../i2cTest.c:43: warning: implicit declaration of function 'write'
Can anyone help me out with this? I'm really new with using linux drivers.
Thanks
-David
_______________________________________________
uClinux-dev mailing list
[email protected]
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by [email protected]
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev