NI PCI-DIO-32HS and external triggering

I have installed comedi and comedilib and can do
basic I/O with my NI PCI-DIO-32HS digital IO card
(starting with the dio.c example program).

Now I would like to use a TTL pulse applied to
channel 0 to trigger some events in my main software
program - I'm not actually interested in acquiring data
from the IO card at this point...

I started with the cmd.c example program and set up a
command by hand as follows:

int prepare_cmd(comedi_t *dev,int subdevice,comedi_cmd *cmd)
{
        memset(cmd,0,sizeof(*cmd));
        cmd->flags = 0;
        cmd->start_src =        TRIG_NOW;
        cmd->start_arg =        0;
        cmd->scan_begin_src =   TRIG_EXT;
        cmd->scan_begin_arg =   0;
        cmd->convert_src =      TRIG_NOW;
        cmd->convert_arg =      0;              /* in ns */
        cmd->scan_end_src =     TRIG_COUNT;
        cmd->scan_end_arg =     n_chan;         /* number of channels */
        cmd->stop_src =         TRIG_COUNT;
        cmd->stop_arg =         n_scan;
        cmd->chanlist =         chanlist;
        cmd->chanlist_len =     n_chan;
        return 0;
}

comedi_cmd_test() is happy with this. However, it does not approve
of TRIG_EXT being used for start_src. Anyways, I tried using the
above with comedi_cmd(), but it does not appear to work - comedi_cmd
returns immediately, regardless of whether I apply a TTL pulse to 
channel 0 or not. I was expecting that comedi_cmd() would not return until
I applied a single TTL pulse to the channel 0 input.

Also, when I try reading the buffer (ala the cmd.c example), the read()
hangs up.

Also, I get "comedi_command: Device or resource busy" if I comment out
the buffer read and try invoking comedi_command() a second time _ I'd
like my program to respond to multiple triggers...

Any ideas as to where I'm going wrong? I have not yet tried RT_LINUX,
and I'd like to understand this problem before wading in...

Thanks,
Andrew

Received on 2003-01-07Z05:50:15