- From: ÁõÏþ÷ <liuxiaomei_521_at_163.com>
- Date: Thu, 17 Jun 2004 15:32:04 +0800
Hi:
My OS is redhat8.0,and patched with rtlinux3.2.
I have installed comedi0.7.60 in rtlinux successful,and try the code in comeidtest without any
wrong message.
Now I want to use comedi with rtlinux together.
//pci1756.c
#include <linux/module.h>
#include <linux/kernel.h>
#include <rtl.h>
#include <rtl_sched.h>
#include <comedilib.h>
#define N_SAMPLE 2
char *filename="/dev/comedi0";
int verbose_flag;
comedi_t *device;
int channel =1;
int range = 0;
int subdev = 3;
int period=1000000;
int periodic_mode=0;
unsigned int bit;
pthread_t thread;
void *bit_toggle(void *t)
{
pthread_make_periodic_np(thread, gethrtime(), period);
while (1)
{
comedi_dio_write(device,subdev,0,bit);
bit= ~bit;
pthread_wait_np();
}
}
int init_module(void)
{
device = comedi_open(filename);
if(!device)
{
printf("wrong with comedi_open \n");
return 1;
}
pthread_attr_t attr;
struct sched_param sched_param;
pthread_attr_init (&attr);
sched_param.sched_priority = 1;
pthread_attr_setschedparam (&attr, &sched_param);
pthread_create (&thread, &attr, bit_toggle, (void *)0);
return 0;
}
void cleanup_module(void)
{
comedi_close(device);
pthread_delete_np (thread);
}
//Makefile
all: 1756.o
include ../../rtl.mk
1756: 1756.c
$(CC) ${INCLUDE} -Wall -O2 -o 1756 1756.c -lcomedi
wrong message :
cc -D__KERNEL__ -Wall -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2 -march=i386 -DMODULE -DMODVERSIONS -include /usr/src/linux/include/linux/modversions.h -g -D__RTL__ -D_LOOSE_KERNEL_NAMES -O2 -I/usr/src/rtlinux-3.2-pre2/linux/include -I/usr/src/rtlinux-3.2-pre2/include -I/usr/src/rtlinux-3.2-pre2/include/compat -I/usr/src/rtlinux-3.2-pre2/include/posix -c -o 1756.o 1756.c
In file included from /usr/include/sys/ioctl.h:30,
from /usr/include/comedilib.h:29,
from 1756.c:14:
/usr/include/bits/ioctl-types.h:29: redefinition of `struct winsize'
/usr/include/bits/ioctl-types.h:38: redefinition of `struct termio'
In file included from /usr/include/bits/types.h:143,
from /usr/include/stdio.h:36,
from /usr/include/comedilib.h:31,
from 1756.c:14:
/usr/include/bits/pthreadtypes.h:52: conflicting types for `pthread_attr_t'
/usr/src/rtlinux-3.2-pre2/include/rtl_sched.h:251: previous declaration of `pthread_attr_t'
/usr/include/bits/pthreadtypes.h:70: conflicting types for `pthread_key_t'
/usr/src/rtlinux-3.2-pre2/include/rtl_sched.h:216: previous declaration of `pthread_key_t'
/usr/include/bits/pthreadtypes.h:140: conflicting types for `pthread_t'
/usr/src/rtlinux-3.2-pre2/include/rtl_sched.h:59: previous declaration of `pthread_t'
1756.c: In function `bit_toggle':
1756.c:44: warning: passing arg 1 of `pthread_make_periodic_np' makes pointer from integer without a cast
1756.c: In function `init_module':
1756.c:68: warning: passing arg 1 of `pthread_attr_init' from incompatible pointer type
1756.c:70: warning: passing arg 1 of `pthread_attr_setschedparam' from incompatible pointer type
1756.c:71: warning: passing arg 1 of `__pthread_create' from incompatible pointer type
1756.c:71: warning: passing arg 2 of `__pthread_create' from incompatible pointer type
1756.c: In function `cleanup_module':
1756.c:79: warning: passing arg 1 of `pthread_delete_np' makes pointer from integer without a cast
make: *** [1756.o] Error 1
when I deleted "#include <comedilib.h>",all wrong message disappered.Maybe the head file
comedilib.h is conflict with certain head file ?
Thank you for your help!
Received on 2004-06-17Z06:32:04