There isn't an easy way to do this. One thing you can do is set up a
streaming "read" command on some subdevice using the digital pin as an
external trigger. The basic idea is that some thread in your
application can do a blocking read() to read some data from the
subdevice and then call the routine to read the GPS. You could also use
select() or poll() on the file to wait for it to become readable.
For NI DAQ cards, suitable subdevices for performing streaming read
commands are the AI subdevice (subdevice 0) or either of the GPCT
subdevices (11 or 12). However, because the main /dev/comedi0 (or
/dev/comedi1 etc.) file can only do the read() file operation on its
default "read" subdevice (which is subdevice 0 for NI DAQ), if you want
to set up a "read" command on subdevice 11 or 12, you need to open the
specific comedi subdevice file, for example "/dev/comedi0_subd11" and
set up the "read" command using that specific file descriptor.
For the "read" command itself, you want to set it up as follows:
cmd.subdev = the subdevice you want to read, which should be the "read"
subdevice for the /dev/comediX_subdY file you opened.
cmd.flags = TRIG_WAKE_EOS
cmd.start_src = TRIG_NOW (or TRIG_INT if you want to trigger it later)
cmd.start_arg = 0
cmd.scan_begin_src = TRIG_EXT
cmd.scan_begin_arg = CR_CHAN(ext trigger source) possibly ORed with
CR_INVERT
cmd.convert_src = TRIG_NOW (for GPCT subdevice) or TRIG_TIMER (for AI
subdevice)
cmd.convert_arg = 0
cmd.scan_end_src = TRIG_COUNT
cmd.scan_end_arg = 1
cmd.stop_src = TRIG_NONE
cmd.stop_arg = 0
cmd.chanlist_len = 1
cmd.chanlist = pointer to channel list of length 1 containing a valid
channel
If all is well with the command, it should read one sample of data from
the channel every time an external trigger occurs. The TRIG_WAKE_EOS
flag should result in the driver getting an interrupt after every scan
with one new scan of data in its internal buffer that can be read by the
read() system call, or will wake up any select() or poll() waiting for
the device to become readable.
--
-=( Ian Abbott @ MEV Ltd. E-mail: <abb...@mev.co.uk> )=-
-=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-
They are POSIX functions in your system C library (libc). Use the 'man'
command for a description:
man 2 select
man 2 poll
Note: use the comedi_fileno() function to convert a valid 'comedi_t'
handle (as returned by comedi_open() on success) to a file descriptor
for with select(), poll(), read(), write(), etc.