command: Fix except declaration for get_comedi_cmd_pointer
[pycomedi.git] / pycomedi / _comedilib_h.pxd
1 # Copyright (C) 2011-2012 W. Trevor King <wking@tremily.us>
2 #
3 # This file is part of pycomedi.
4 #
5 # pycomedi is free software: you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation, either version 2 of the License, or (at your option) any later
8 # version.
9 #
10 # pycomedi is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License along with
15 # pycomedi.  If not, see <http://www.gnu.org/licenses/>.
16
17 "Cython interface to comedilib.h"
18
19 from pycomedi._comedi_h cimport *
20
21
22 cdef extern from 'comedilib.h':
23     ctypedef struct comedi_t:
24         pass
25
26     ctypedef struct comedi_range:
27         double min
28         double max
29         unsigned int unit
30
31     comedi_t *comedi_open(char *fn)
32     int comedi_close(comedi_t *it)
33
34     # logging
35
36     int comedi_loglevel(int loglevel)
37     void comedi_perror(char *s)
38     char *comedi_strerror(int errnum)
39     int comedi_errno()
40     int comedi_fileno(comedi_t *it)
41
42     # device queries
43
44     int comedi_get_n_subdevices(comedi_t *it)
45     # COMEDI_VERSION_CODE handled by device.Device.get_version_code()
46     int comedi_get_version_code(comedi_t *it)
47     char *comedi_get_driver_name(comedi_t *it)
48     char *comedi_get_board_name(comedi_t *it)
49     int comedi_get_read_subdevice(comedi_t *dev)
50     int comedi_get_write_subdevice(comedi_t *dev)
51
52     # subdevice queries
53
54     int comedi_get_subdevice_type(comedi_t *it,unsigned int subdevice)
55     int comedi_find_subdevice_by_type(comedi_t *it,int type,unsigned int subd)
56     int comedi_get_subdevice_flags(comedi_t *it,unsigned int subdevice)
57     int comedi_get_n_channels(comedi_t *it,unsigned int subdevice)
58     int comedi_range_is_chan_specific(comedi_t *it,unsigned int subdevice)
59     int comedi_maxdata_is_chan_specific(comedi_t *it,unsigned int subdevice)
60
61     # channel queries
62
63     lsampl_t comedi_get_maxdata(comedi_t *it,unsigned int subdevice,
64         unsigned int chan)
65     int comedi_get_n_ranges(comedi_t *it,unsigned int subdevice,
66         unsigned int chan)
67     comedi_range * comedi_get_range(comedi_t *it,unsigned int subdevice,
68         unsigned int chan,unsigned int range)
69     int comedi_find_range(comedi_t *it,unsigned int subd,unsigned int chan,
70         unsigned int unit,double min,double max)
71
72     # buffer queries
73
74     int comedi_get_buffer_size(comedi_t *it,unsigned int subdevice)
75     int comedi_get_max_buffer_size(comedi_t *it,unsigned int subdevice)
76     int comedi_set_buffer_size(comedi_t *it,unsigned int subdevice,
77             unsigned int len)
78
79     # low-level stuff
80
81     int comedi_do_insnlist(comedi_t *it,comedi_insnlist *il)
82     int comedi_do_insn(comedi_t *it,comedi_insn *insn)
83     int comedi_lock(comedi_t *it,unsigned int subdevice)
84     int comedi_unlock(comedi_t *it,unsigned int subdevice)
85
86     # synchronous stuff
87
88     int comedi_data_read(comedi_t *it,unsigned int subd,unsigned int chan,
89         unsigned int range,unsigned int aref,lsampl_t *data)
90     int comedi_data_read_n(comedi_t *it,unsigned int subd,unsigned int chan,
91         unsigned int range,unsigned int aref,lsampl_t *data, unsigned int n)
92     int comedi_data_read_hint(comedi_t *it,unsigned int subd,unsigned int chan,
93         unsigned int range,unsigned int aref)
94     int comedi_data_read_delayed(comedi_t *it,unsigned int subd,unsigned int chan,
95         unsigned int range,unsigned int aref,lsampl_t *data, unsigned int nano_sec)
96     int comedi_data_write(comedi_t *it,unsigned int subd,unsigned int chan,
97         unsigned int range,unsigned int aref,lsampl_t data)
98     int comedi_dio_config(comedi_t *it,unsigned int subd,unsigned int chan,
99         unsigned int dir)
100     int comedi_dio_get_config(comedi_t *it,unsigned int subd,unsigned int chan,
101         unsigned int *dir)
102     int comedi_dio_read(comedi_t *it,unsigned int subd,unsigned int chan,
103         unsigned int *bit)
104     int comedi_dio_write(comedi_t *it,unsigned int subd,unsigned int chan,
105         unsigned int bit)
106     int comedi_dio_bitfield2(comedi_t *it,unsigned int subd,
107         unsigned int write_mask, unsigned int *bits, unsigned int base_channel)
108
109     # streaming I/O (commands)
110
111     int comedi_get_cmd_src_mask(comedi_t *dev,unsigned int subdevice,
112             comedi_cmd *cmd)
113     int comedi_get_cmd_generic_timed(comedi_t *dev,unsigned int subdevice,
114             comedi_cmd *cmd, unsigned chanlist_len, unsigned scan_period_ns)
115     int comedi_cancel(comedi_t *it,unsigned int subdevice)
116     int comedi_command(comedi_t *it,comedi_cmd *cmd)
117     int comedi_command_test(comedi_t *it,comedi_cmd *cmd)
118     int comedi_poll(comedi_t *dev,unsigned int subdevice)
119
120     # buffer control
121
122     int comedi_set_max_buffer_size(comedi_t *it, unsigned int subdev,
123             unsigned int max_size)
124     int comedi_get_buffer_contents(comedi_t *it, unsigned int subdev)
125     int comedi_mark_buffer_read(comedi_t *it, unsigned int subdev,
126             unsigned int bytes)
127     int comedi_mark_buffer_written(comedi_t *it, unsigned int subdev,
128             unsigned int bytes)
129     int comedi_get_buffer_offset(comedi_t *it, unsigned int subdev)
130
131     # structs and functions used for parsing calibration files
132
133     ctypedef struct comedi_caldac_t:
134         unsigned int subdevice
135         unsigned int channel
136         unsigned int value
137
138     enum: COMEDI_MAX_NUM_POLYNOMIAL_COEFFICIENTS
139
140     ctypedef struct comedi_polynomial_t:
141         double coefficients[COMEDI_MAX_NUM_POLYNOMIAL_COEFFICIENTS]
142         double expansion_origin
143         unsigned order
144
145     ctypedef struct comedi_softcal_t:
146         comedi_polynomial_t *to_phys
147         comedi_polynomial_t *from_phys
148
149     enum: CS_MAX_AREFS_LENGTH
150
151     ctypedef struct comedi_calibration_setting_t:
152         unsigned int subdevice
153         unsigned int *channels
154         unsigned int num_channels
155         unsigned int *ranges
156         unsigned int num_ranges
157         unsigned int arefs[ CS_MAX_AREFS_LENGTH ]
158         unsigned int num_arefs
159         comedi_caldac_t *caldacs
160         unsigned int num_caldacs
161         comedi_softcal_t soft_calibration
162
163     ctypedef struct comedi_calibration_t:
164         char *driver_name
165         char *board_name
166         comedi_calibration_setting_t *settings
167         unsigned int num_settings
168
169     comedi_calibration_t* comedi_parse_calibration_file(
170         char *cal_file_path )
171     int comedi_apply_parsed_calibration( comedi_t *dev, unsigned int subdev,
172         unsigned int channel, unsigned int range, unsigned int aref,
173         comedi_calibration_t *calibration )
174     char* comedi_get_default_calibration_path( comedi_t *dev )
175     void comedi_cleanup_calibration( comedi_calibration_t *calibration )
176     int comedi_apply_calibration( comedi_t *dev, unsigned int subdev,
177         unsigned int channel, unsigned int range, unsigned int aref,
178         char *cal_file_path)
179
180     # New stuff to provide conversion between integers and physical values that
181     # can support software calibrations.
182     enum comedi_conversion_direction:
183         COMEDI_TO_PHYSICAL,
184         COMEDI_FROM_PHYSICAL
185     int comedi_get_softcal_converter(
186         unsigned subdevice, unsigned channel, unsigned range,
187         comedi_conversion_direction direction,
188         comedi_calibration_t *calibration,
189         comedi_polynomial_t *polynomial)
190     int comedi_get_hardcal_converter(
191         comedi_t *dev, unsigned subdevice, unsigned channel, unsigned range,
192         comedi_conversion_direction direction,
193         comedi_polynomial_t *polynomial)
194     double comedi_to_physical(lsampl_t data,
195         comedi_polynomial_t *conversion_polynomial)
196     lsampl_t comedi_from_physical(double data,
197         comedi_polynomial_t *conversion_polynomial)
198     #
199     #int comedi_internal_trigger(comedi_t *dev, unsigned subd, unsigned trignum);
200     #/* INSN_CONFIG wrappers */
201     #int comedi_arm(comedi_t *device, unsigned subdevice, unsigned source);
202     #int comedi_reset(comedi_t *device, unsigned subdevice);
203     #int comedi_get_clock_source(comedi_t *device, unsigned subdevice, unsigned channel, unsigned *clock, unsigned *period_ns);
204     #int comedi_get_gate_source(comedi_t *device, unsigned subdevice, unsigned channel,
205     #        unsigned gate, unsigned *source);
206     #int comedi_get_routing(comedi_t *device, unsigned subdevice, unsigned channel, unsigned *routing);
207     #int comedi_set_counter_mode(comedi_t *device, unsigned subdevice, unsigned channel, unsigned mode_bits);
208     #int comedi_set_clock_source(comedi_t *device, unsigned subdevice, unsigned channel, unsigned clock, unsigned period_ns);
209     #int comedi_set_filter(comedi_t *device, unsigned subdevice, unsigned channel, unsigned filter);
210     #int comedi_set_gate_source(comedi_t *device, unsigned subdevice, unsigned channel, unsigned gate_index, unsigned gate_source);
211     #int comedi_set_other_source(comedi_t *device, unsigned subdevice, unsigned channel,
212     #        unsigned other, unsigned source);
213     #int comedi_set_routing(comedi_t *device, unsigned subdevice, unsigned channel, unsigned routing);
214     #int comedi_get_hardware_buffer_size(comedi_t *device, unsigned subdevice, enum comedi_io_direction direction);