Hi, Zaimin, David and all,

I modified your codes and they are ok for my DIO and Analog Output. However,
after modifying it to fit my Analog Input,  though the codes could be compiled,
when I "insmod" it into kernel, the computer crashed every time.  I was even
driven crazy about this. I checked the codes line by line, and could not find
error based on my understanding.  Attached please find this very simple
program, its purpose is to collect data from the NI PCI6035E's Analog Input,
channel 0.  (I wish to say that this DAQ card's Analog Input is ok because I
could read out data if I use the function of "comedi_data_read" in the kernel
space.) Could you please kindly point out where I was wrong??

Moreover, may I ask you some questions as follows:
1) I could use "comedi_data_read" to collect real time data from the DAQ, then
may I just use it to take the place of the funciton of "comedi_ trig_ioctl"?

2) I wonder if the NI PCI6035E card could be used in the mode1,2,3, or 4? I
tried it in mode1&2, but no response.

3)If I read data from DAQ, shall I set the trig flag to "TRIG_READ" or etc? but
I could not find this setting. And shall I set "TRIG_CONFIG"  firstly?

4) NI PCI6035E's each AI channel may be programmed with a unique gain of
0.5(+/-10V input range),1.0(+/-5V), 10(+/-500mV) or 100(+/-50mV), but I am not
so sure how to relate these settings with the trig data structure?

Thanks a lot  for your precious time on my questions, and your any kind
suggestion are greatly appreciated!!

Yuhong





Zaimin Zhong wrote:

> Yuhong,
>
> >
> >I tried the example of /comedilib/demo/rt/it.c, and  modified it to my
> hardware
> >
> >configuration(NI PCI6035E).  However, I met with some errors during "make",
> >attached please find my "it.c" and the error information. I wonder if this
> >example is only for the previous RTL version?
>
> Completely right. They were written for V1 of RTLinux. I changed the lines
> of V1 RTLinux into V2, and it was now able to be compiled on my computer. I
> have not test it for functionality for lacking of board.
>
> >Also, I could not find the reference about "CR_PACK",
> >
> in <comedi.h>
>
> Bye!
>
> James...
> =================================
> Zaimin Zhong
> Department of Vehicle Engineering
> Tongji University
> Shanghai, PR China
> [EMAIL PROTECTED]
> =================================
>
>   ------------------------------------------------------------------------
>              Name: rt.tgz
>    rt.tgz    Type: application/x-compressed
>          Encoding: base64

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/version.h>
#include <rtl_sched.h>
#include <rtl_compat.h>
#include <rtl_printf.h>
#include <asm/rt_time.h>
#include <comedi.h>


/* this is the dev,subdev for analog input on my NI PCI6035E board */
unsigned int dev=0;
unsigned int subdev=0;

pthread_t mythread;
sampl_t data;
comedi_trig trig;
int ioctl_check;
unsigned int channel;


void *do_comedi_toggle(void *arg)
{
        while(1){
                ioctl_check=comedi_trig_ioctl(dev,subdev,&trig);
                rtl_printf("analog intput: ioctl_check=%d, scan= %d\n",ioctl_check, 
data);
                pthread_wait_np ();
        }
}


int init_module(void)
{
        int ret;
        channel=CR_PACK(0,0,0);
        
        /* set up trigger structure */
        trig.subdev=subdev;
        trig.mode=0;
        trig.flags=0;
        trig.n_chan=1;
        trig.chanlist=&channel;
        trig.data=&data;
        trig.data_len=sizeof(sampl_t);
        trig.n=1;
        trig.trigsrc=0;
        trig.trigvar=0;
        trig.trigvar1=0;

        

        /* IMPORTANT: next step: lock the subdevice */
        ret=comedi_lock_ioctl(dev,subdev);

        pthread_create(&mythread, NULL, do_comedi_toggle, 0);
        pthread_make_periodic_np(mythread, gethrtime(), 500000000); //0.5s
        return 0;
}

void cleanup_module(void)
{
        int ret;
        
        ret=comedi_cancel_ioctl(dev,subdev);
        ret=comedi_unlock_ioctl(dev,subdev);
        
        ret=pthread_delete_np(mythread);

        
}


Makefile.ai

Reply via email to