- From: <HanMic_at_aol.com>
- Date: Tue, 24 Jun 2003 10:57:07 -0400
Hello!
I am using Comedi-0.7.66 and comedilib-0.7.19.
I would very much like to call COMEDI functions in RTLinux. While reading the mailing list, I found out, that there should be real-time examples in comedilib/demo. But there are none :(
So I tried to figure out the usage of comedi functions amoung rtlinux by "trial and error". I know, that one cannot use comedi.h and comedilib.h in realtime code, as they are userspace files. Instead one mus call kcomedilib. I searched and found a file /comedi/include/linux/comedilib.h which seems to be the real-time library. Is that correct?
What I did was to include this file in my realtime code and got an error message, that <linux/comedi.h> did not exist. Changing paths to an existing comedi.h worked for compilation but when I tried to insert my realtime/comedi module I got unresolved symbols comedi_open and comedi_writedata.
I would be very thankful, if one of you would be so kind to tell me, how I can actually use comedi fuctions in rtlinux. I would very muchg appreciate your help! Maybe you could tell me what I have to change in my rtlinux code and my makefile (attached to this mail).
Thanks a lot!
Michael
+++++++++++++++++++++++++++++++++++++++++++++++++
RTLinux Code
+++++++++++++++++++++++++++++++++++++++++++++++++
#include <rtl.h>
#include <time.h>
#include <rtl_sched.h>
#include <rtl_fifo.h>
#include <pthread.h>
#include <rtl_time.h>
#include "/usr/src/comedi-0.7.66/include/linux/comedilib.h"
int subdev = 0;
int chan = 0;
int range = 0;
int aref = AREF_GROUND;
comedi_t *it;
pthread_t thread;
void * start_routine(void *arg)
{
struct sched_param p;
p.sched_priority = 1;
pthread_setschedparam (pthread_self(), SCHED_FIFO, &p);
pthread_make_periodic_np (pthread_self(), gethrtime(), 100000000);
while (1)
{
lsampl_t data;
it=comedi_open("/dev/comedi0");
comedi_data_read(it,subdev,chan,range,aref,&data);
rtl_printf("%d\n",data);
pthread_wait_np();
}
return 0;
}
int init_module(void)
{
return pthread_create (&thread, NULL, start_routine, 0);
}
void cleanup_module(void)
{
pthread_delete_np (thread);
}
++++++++++++++++++++++++++++++++++++++++++++++++++++
Makefile
++++++++++++++++++++++++++++++++++++++++++++++++++++
all: rt_module.o
include /usr/src/rtlinux/rtl.mk
rt_module.o: rt_module.c
$(CC) ${INCLUDE} ${CFLAGS} -I /usr/src/comedi-0.7.66/include/linux -c rt_module.c
clean:
-rm -f *.o *~
Received on 2003-06-24Z13:57:07