Thank you all for your kind suggestion. Since I am still not clear about the usage of "comedi_trig_ioctl", I tried to program my own analog input/output test program based on the NI PCI6035E card, which has been setup well in my machine. Attached please find the "my_test2.c" and my Makefile, I just tried to read from a DIO channel and write data into an AO channel.
Before "make", all related modules including rtl_*, comedi, and ni_pcimio have been inserted successfully. And I have added "-lcomedi" in the linking.
However, though I have included "comedilib.h", the result of my
"make" warned me that:
in the line of "comedi_t *cf"-----parse error
before '*', and 'cf' undeclared.
I checked this "comedilib.h", it includes "comedi.h". I am puzzled with this problem, could you please point out where I was wrong?
BTW, I wonder if there is a simple Comedi+RTLinux program which could be utilized to test my DAQ card running in RTL mode? Thanks a lot in advance.
Regards,
Yuhong
include /usr/src/linux/.config
##### Compiler, Flags, Paths, etc. #####
RTL_CFLAGS = -Wall -Wstrict-prototypes -O2 \
-fomit-frame-pointer -fno-strength-reduce
RTL_CFLAGS += -I/usr/src/ComediLib/include
RTL_DEFS = -D__RTL__ -D__KERNEL__ \
-DMODULE -c
ifeq ($(CONFIG_MODVERSIONS),y)
RTL_DEFS += -DMODVERSIONS -include \
/usr/src/rtlinux-2.3/linux/include/linux/modversions.h
endif
RTL_INCLUDE = -I . -I /usr/include/rtlinux \
-I /usr/src/rtlinux-2.3/linux/include/asm-i386
LFLAGS = -L/usr/lib
LFLAGS += -L/usr/src/ComediLib/lib -lcomedi
GCC = gcc
##### File Names #####
RTL_SOURCE = my_test2.c
RTL_TARGET = my_test2.o
##### Build Rules #####
all: $(RTL_TARGET)
$(RTL_TARGET): $(RTL_SOURCE)
$(GCC) $(RTL_INCLUDE) $(RTL_CFLAGS) $(RTL_DEFS) \
-c $(RTL_SOURCE) -o $(RTL_TARGET)
clean:
-rm -f *.o
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/version.h>
#include <linux/errno.h>
#include <rtl.h>
#include <rtl_fifo.h>
#include <rtl_sched.h>
#include <rtl_sync.h>
#include <rtl_debug.h>
//#include <comedi.h> //main comedi header file
#include <comedilib.h> // Includes "comedi.h" already
// Using NI PCI6035E, which has been setup well
int AI_device = 0; //AI subdevice
int AO_device =1 ; //AO subdevice
int DIO_device = 2; //DIO subdevice
int DIO_chan = 0; //DIO channel
int AI_chan = 0; //AI channel
int AO_chan = 0; //AO channel
int range = 0;
int aref = 0;
int init_module(void);
void cleanup_module(void);
pthread_t thread;
void *start_routine(void *arg)
{
int data,ret;
struct sched_param p;
p.sched_priority = 1;
pthread_setschedparam(pthread_self(), SCHED_FIFO, &p);
pthread_make_periodic_np(pthread_self(), gethrtime(), 500000000);
comedi_t *cf;
cf=comedi_open("/dev/comedi0");
while (1) {
comedi_data_read(cf,DIO_device,DIO_chan,range,aref,&data);
ret=comedi_data_write(cf,AO_device,AO_chan,range,aref,10.0);
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);
}
