3
header file for the comedi library routines
5
COMEDI - Linux Control and Measurement Device Interface
6
Copyright (C) 1998-2002 David A. Schleef <ds@schleef.org>
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.
29
#include <sys/ioctl.h>
37
typedef struct comedi_t_struct comedi_t;
45
typedef struct comedi_sv_struct{
47
unsigned int subdevice;
54
/* number of measurements to average (for ai) */
60
enum comedi_oor_behavior {
61
COMEDI_OOR_NUMBER = 0,
68
comedi_t *comedi_open(const char *fn);
69
int comedi_close(comedi_t *it);
72
int comedi_loglevel(int loglevel);
73
void comedi_perror(const char *s);
74
char *comedi_strerror(int errnum);
75
int comedi_errno(void);
76
int comedi_fileno(comedi_t *it);
79
enum comedi_oor_behavior comedi_set_global_oor_behavior(enum comedi_oor_behavior behavior);
82
int comedi_get_n_subdevices(comedi_t *it);
83
#define COMEDI_VERSION_CODE(a,b,c) (((a)<<16) | ((b)<<8) | (c))
84
int comedi_get_version_code(comedi_t *it);
85
char *comedi_get_driver_name(comedi_t *it);
86
char *comedi_get_board_name(comedi_t *it);
87
int comedi_get_read_subdevice(comedi_t *dev);
88
int comedi_get_write_subdevice(comedi_t *dev);
90
/* subdevice queries */
91
int comedi_get_subdevice_type(comedi_t *it,unsigned int subdevice);
92
int comedi_find_subdevice_by_type(comedi_t *it,int type,unsigned int subd);
93
int comedi_get_subdevice_flags(comedi_t *it,unsigned int subdevice);
94
int comedi_get_n_channels(comedi_t *it,unsigned int subdevice);
95
int comedi_range_is_chan_specific(comedi_t *it,unsigned int subdevice);
96
int comedi_maxdata_is_chan_specific(comedi_t *it,unsigned int subdevice);
99
lsampl_t comedi_get_maxdata(comedi_t *it,unsigned int subdevice,
101
int comedi_get_n_ranges(comedi_t *it,unsigned int subdevice,
103
comedi_range * comedi_get_range(comedi_t *it,unsigned int subdevice,
104
unsigned int chan,unsigned int range);
105
int comedi_find_range(comedi_t *it,unsigned int subd,unsigned int chan,
106
unsigned int unit,double min,double max);
109
int comedi_get_buffer_size(comedi_t *it,unsigned int subdevice);
110
int comedi_get_max_buffer_size(comedi_t *it,unsigned int subdevice);
111
int comedi_set_buffer_size(comedi_t *it,unsigned int subdevice,
114
/* low-level stuff */
115
#ifdef _COMEDILIB_DEPRECATED
116
int comedi_trigger(comedi_t *it,comedi_trig *trig); /* deprecated */
118
int comedi_do_insnlist(comedi_t *it,comedi_insnlist *il);
119
int comedi_do_insn(comedi_t *it,comedi_insn *insn);
120
int comedi_lock(comedi_t *it,unsigned int subdevice);
121
int comedi_unlock(comedi_t *it,unsigned int subdevice);
124
double comedi_to_phys(lsampl_t data,comedi_range *rng,lsampl_t maxdata);
125
lsampl_t comedi_from_phys(double data,comedi_range *rng,lsampl_t maxdata);
126
int comedi_sampl_to_phys(double *dest, int dst_stride, sampl_t *src,
127
int src_stride, comedi_range *rng, lsampl_t maxdata, int n);
128
int comedi_sampl_from_phys(sampl_t *dest,int dst_stride,double *src,
129
int src_stride, comedi_range *rng, lsampl_t maxdata, int n);
131
/* syncronous stuff */
132
int comedi_data_read(comedi_t *it,unsigned int subd,unsigned int chan,
133
unsigned int range,unsigned int aref,lsampl_t *data);
134
int comedi_data_read_n(comedi_t *it,unsigned int subd,unsigned int chan,
135
unsigned int range,unsigned int aref,lsampl_t *data, unsigned int n);
136
int comedi_data_read_hint(comedi_t *it,unsigned int subd,unsigned int chan,
137
unsigned int range,unsigned int aref);
138
int comedi_data_read_delayed(comedi_t *it,unsigned int subd,unsigned int chan,
139
unsigned int range,unsigned int aref,lsampl_t *data, unsigned int nano_sec);
140
int comedi_data_write(comedi_t *it,unsigned int subd,unsigned int chan,
141
unsigned int range,unsigned int aref,lsampl_t data);
142
int comedi_dio_config(comedi_t *it,unsigned int subd,unsigned int chan,
144
int comedi_dio_read(comedi_t *it,unsigned int subd,unsigned int chan,
146
int comedi_dio_write(comedi_t *it,unsigned int subd,unsigned int chan,
148
int comedi_dio_bitfield(comedi_t *it,unsigned int subd,
149
unsigned int write_mask, unsigned int *bits);
151
/* slowly varying stuff */
152
int comedi_sv_init(comedi_sv_t *it,comedi_t *dev,unsigned int subd,unsigned int chan);
153
int comedi_sv_update(comedi_sv_t *it);
154
int comedi_sv_measure(comedi_sv_t *it,double *data);
156
/* streaming I/O (commands) */
158
int comedi_get_cmd_src_mask(comedi_t *dev,unsigned int subdevice,
160
int comedi_get_cmd_generic_timed(comedi_t *dev,unsigned int subdevice,
161
comedi_cmd *cmd,unsigned int ns);
162
int comedi_cancel(comedi_t *it,unsigned int subdevice);
163
int comedi_command(comedi_t *it,comedi_cmd *cmd);
164
int comedi_command_test(comedi_t *it,comedi_cmd *cmd);
165
int comedi_poll(comedi_t *dev,unsigned int subdevice);
169
int comedi_set_max_buffer_size(comedi_t *it, unsigned int subdev,
170
unsigned int max_size);
171
int comedi_get_buffer_contents(comedi_t *it, unsigned int subdev);
172
int comedi_mark_buffer_read(comedi_t *it, unsigned int subdev,
174
int comedi_get_buffer_offset(comedi_t *it, unsigned int subdev);
176
#ifdef _COMEDILIB_DEPRECATED
178
* The following functions are deprecated and should not be used.
180
int comedi_get_timer(comedi_t *it,unsigned int subdev,double freq,
181
unsigned int *trigvar,double *actual_freq);
182
int comedi_timed_1chan(comedi_t *it,unsigned int subdev,unsigned int chan,
183
unsigned int range, unsigned int aref,double freq,
184
unsigned int n_samples,double *data);
185
int comedi_get_rangetype(comedi_t *it,unsigned int subdevice,
190
#ifndef _COMEDILIB_STRICT_ABI
192
The following prototypes are _NOT_ part of the Comedilib ABI, and
193
may change in future versions without regard to source or binary
194
compatibility. In practice, this is a holding place for the next
195
library ABI version change.
197
/* structs and functions used for parsing calibration files */
200
unsigned int subdevice;
201
unsigned int channel;
204
#define CS_MAX_AREFS_LENGTH 4
207
unsigned int subdevice;
208
unsigned int *channels;
209
unsigned int num_channels;
210
unsigned int *ranges;
211
unsigned int num_ranges;
212
unsigned int arefs[ CS_MAX_AREFS_LENGTH ];
213
unsigned int num_arefs;
214
comedi_caldac_t *caldacs;
215
unsigned int num_caldacs;
216
} comedi_calibration_setting_t;
222
comedi_calibration_setting_t *settings;
223
unsigned int num_settings;
224
} comedi_calibration_t;
226
comedi_calibration_t* comedi_parse_calibration_file( const char *cal_file_path );
227
int comedi_apply_parsed_calibration( comedi_t *dev, unsigned int subdev, unsigned int channel,
228
unsigned int range, unsigned int aref, const comedi_calibration_t *calibration );
229
char* comedi_get_default_calibration_path( comedi_t *dev );
230
void comedi_cleanup_calibration( comedi_calibration_t *calibration );
231
int comedi_apply_calibration( comedi_t *dev, unsigned int subdev, unsigned int channel,
232
unsigned int range, unsigned int aref, const char *cal_file_path);