示例#1
0
文件: sigio.c 项目: jbetten/rtxi
/*
 * This part of the demo measures channels 1, 2, 3, 4 at a rate of
 * 10 khz, with the inter-sample time at 10 us (100 khz).  The number
 * of scans measured is 10.  This is analogous to the old mode2
 * acquisition.
 */
void do_cmd_1(comedi_t *dev, int subdevice)
{
	comedi_cmd cmd;

	memset(&cmd,0,sizeof(cmd));

	/* the subdevice that the command is sent to */
	cmd.subdev = subdevice;

	/* flags */
	cmd.flags =	TRIG_WAKE_EOS;

	cmd.start_src =		TRIG_NOW;
	cmd.start_arg =		0;

	cmd.scan_begin_src =	TRIG_TIMER;
	cmd.scan_begin_arg =	msec_to_nsec(100);

#if 1
	cmd.convert_src =	TRIG_TIMER;
	cmd.convert_arg =	1;
#else
	cmd.convert_src =	TRIG_ANY;
	cmd.convert_arg =	0;
#endif

	cmd.scan_end_src =	TRIG_COUNT;
	cmd.scan_end_arg =	1;

	cmd.stop_src =		TRIG_NONE;
	cmd.stop_arg =		0;

	cmd.chanlist =		chanlist;
	cmd.chanlist_len =	1;

	chanlist[0]=CR_PACK(0,0,0);

	do_cmd(dev,&cmd);
}
示例#2
0
文件: poll.c 项目: olsonse/comedilib
/*
 * This part of the demo measures channels 1, 2, 3, 4 at a rate of
 * 10 khz, with the inter-sample time at 10 us (100 khz).  The number
 * of scans measured is 10.  This is analogous to the old mode2
 * acquisition.
 */
void prepare_cmd(comedi_t *dev, comedi_cmd *cmd, int subdevice)
{
	memset(cmd,0,sizeof(*cmd));

	/* the subdevice that the command is sent to */
	cmd->subdev =	subdevice;

	/* flags */
	cmd->flags =	0;

	/* each event requires a trigger, which is specified
	   by a source and an argument.  For example, to specify
	   an external digital line 3 as a source, you would use
	   src=TRIG_EXT and arg=3. */

	/* In this case, we specify using TRIG_NOW to start
	 * acquisition immediately when the command is issued.
	 * The argument of TRIG_NOW is "number of nsec after
	 * NOW", but no driver supports it yet.  Also, no driver
	 * currently supports using a start_src other than
	 * TRIG_NOW.  */
	cmd->start_src =		TRIG_NOW;
	cmd->start_arg =		0;

	/* The timing of the beginning of each scan is controlled
	 * by scan_begin.  TRIG_TIMER specifies that scan_start
	 * events occur periodically at a rate of scan_begin_arg
	 * nanoseconds between scans. */
	cmd->scan_begin_src =	TRIG_TIMER;
	cmd->scan_begin_arg =	msec_to_nsec(100);

	/* The timing between each sample in a scan is controlled
	 * by convert.  Like above, TRIG_TIMER specifies that
	 * convert events occur periodically at a rate of convert_arg
	 * nanoseconds between scans. */
	cmd->convert_src =	TRIG_TIMER;
	cmd->convert_arg =	msec_to_nsec(1);

	/* The end of each scan is almost always specified using
	 * TRIG_COUNT, with the argument being the same as the
	 * number of channels in the chanlist.  You could probably
	 * find a device that allows something else, but it would
	 * be strange. */
	cmd->scan_end_src =	TRIG_COUNT;
	cmd->scan_end_arg =	n_chans;	/* number of channels */

	/* The end of acquisition is controlled by stop_src and
	 * stop_arg.  The src will typically be TRIG_COUNT or
	 * TRIG_NONE.  Specifying TRIG_COUNT will stop acquisition
	 * after stop_arg number of scans, or TRIG_NONE will
	 * cause acquisition to continue until stopped using
	 * comedi_cancel(). */
	cmd->stop_src =		TRIG_COUNT;
	cmd->stop_arg =		n_scans;

	/* the channel list determined which channels are sampled.
	   In general, chanlist_len is the same as scan_end_arg.  Most
	   boards require this.  */
	cmd->chanlist =		chanlist;
	cmd->chanlist_len =	n_chans;
}