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>
46 if( (s=getenv("COMEDILIB_LOGLEVEL")) ){
47 __comedi_loglevel=strtol(s,NULL,10);
48 fprintf(stderr,"setting loglevel to %d\n",__comedi_loglevel);
52 comedi_t *comedi_open(const char *fn)
59 if(!(it=malloc(sizeof(comedi_t))))
61 memset(it,0,sizeof(comedi_t));
63 if((it->fd=open(fn,O_RDWR))<0){
68 if(ioctl_devinfo(it->fd,&it->devinfo)<0)
71 it->n_subdevices=it->devinfo.n_subdevs;
75 it->magic=COMEDILIB_MAGIC;
86 /* this is an example of how we do versioned symbols */
87 __asm__(".symver comedi_open_0,comedi_open@");
90 void comedi_close(comedi_t *it)
94 /* XXX should free all memory */
99 int comedi_cancel(comedi_t *it,unsigned int subdevice)
101 return ioctl(it->fd,COMEDI_CANCEL,subdevice);
104 int comedi_poll(comedi_t *it,unsigned int subdevice)
106 #ifdef HAVE_COMEDI_POLL
107 return ioctl(it->fd,COMEDI_POLL,subdevice);
113 int comedi_fileno(comedi_t *it)
121 int comedi_trigger(comedi_t *it,comedi_trig *t)
126 return ioctl_trigger(it->fd,t);
129 int comedi_command(comedi_t *it,comedi_cmd *t)
131 return ioctl(it->fd,COMEDI_CMD,t);
134 int comedi_command_test(comedi_t *it,comedi_cmd *t)
136 return ioctl(it->fd,COMEDI_CMDTEST,t);
139 int comedi_do_insnlist(comedi_t *it,comedi_insnlist *il)
141 return ioctl(it->fd,COMEDI_INSNLIST,il);
144 int comedi_do_insn(comedi_t *it,comedi_insn *insn)
151 return ioctl(it->fd,COMEDI_INSNLIST,&il);
154 int comedi_lock(comedi_t *it,unsigned int subdevice)
156 return ioctl(it->fd,COMEDI_LOCK,subdevice);
159 int comedi_unlock(comedi_t *it,unsigned int subdevice)
161 return ioctl(it->fd,COMEDI_UNLOCK,subdevice);