3 comedi library routines
5 COMEDI - Linux Control and Measurement Device Interface
6 Copyright (C) 1997-8 David A. Schleef <ds@stm.lbl.gov>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include <sys/types.h>
31 #include <sys/ioctl.h>
36 #include <libinternal.h>
40 int comedi_data_write(comedi_t *it,unsigned int subdev,unsigned int chan,unsigned int range,
41 unsigned int aref,lsampl_t data)
45 if(!valid_chan(it,subdev,chan))
48 s=it->subdevices+subdev;
50 if(it->has_insnlist_ioctl){
53 memset(&insn,0,sizeof(insn));
55 insn.insn = INSN_WRITE;
59 insn.chanspec = CR_PACK(chan,range,aref);
61 return comedi_do_insn(it,&insn);
74 chan=CR_PACK(chan,range,aref);
77 if(it->subdevices[subdev].subd_flags & SDF_LSAMPL){
78 cmd.data=(sampl_t *)(&data);
84 return ioctl_trigger(it->fd,&cmd);
89 int comedi_data_read_n(comedi_t *it,unsigned int subdev,unsigned int chan,
90 unsigned int range, unsigned int aref,lsampl_t *data,
96 if(!valid_chan(it,subdev,chan))
99 s=it->subdevices+subdev;
101 if(it->has_insnlist_ioctl){
103 memset(&insn,0,sizeof(insn));
105 insn.insn = INSN_READ;
108 insn.subdev = subdev;
109 insn.chanspec = CR_PACK(chan,range,aref);
111 return comedi_do_insn(it,&insn);
113 /* There's no need to be fast for a case that is
115 return comedi_data_read(it,subdev,chan,range,aref,data);
119 int comedi_data_read(comedi_t *it,unsigned int subdev,unsigned int chan,unsigned int range,
120 unsigned int aref,lsampl_t *data)
124 if(!valid_chan(it,subdev,chan))
127 s=it->subdevices+subdev;
129 if(it->has_insnlist_ioctl){
132 memset(&insn,0,sizeof(insn));
134 insn.insn = INSN_READ;
137 insn.subdev = subdev;
138 insn.chanspec = CR_PACK(chan,range,aref);
140 return comedi_do_insn(it,&insn);
154 chan=CR_PACK(chan,range,aref);
158 if(s->subd_flags & SDF_LSAMPL){
159 cmd.data=(sampl_t *)data;
164 ret=ioctl_trigger(it->fd,&cmd);
168 if(!(s->subd_flags & SDF_LSAMPL)){