Commit graph

1375 commits

Author SHA1 Message Date
Ian Abbott
2062d615ff Add comedi_disarm() and bump to 0.11.0
Add the comedi_disarm() function to send the INSN_CONFIG_DISARM
configuration instruction to a subdevice.

In configure.ac, bump the comedilib libtool version code to 11:0:11, so
the comedilib version becomes 0.11.0.  Also bump the comedilib manual
version to 0.11.0 in doc/comedilib.ent.
2016-03-21 11:28:29 +00:00
Ian Abbott
0378db7399 comedi.h: adjust header comment
Don't mention where the header gets installed.
2016-03-21 11:27:40 +00:00
Ian Abbott
8b01d77b80 comedi.h: Add note that the "aux data" config options are still used
The COMEDI_DEVCONF_AUX_DATA3_LENGTH, COMEDI_DEVCONF_AUX_DATA2_LENGTH,
COMEDI_DEVCONF_AUX_DATA1_LENGTH, COMEDI_DEVCONF_AUX_DATA0_LENGTH,
COMEDI_DEVCONF_AUX_DATA_HI, COMEDI_DEVCONF_AUX_DATA_LO, and
COMEDI_DEVCONF_AUX_DATA_LENGTH config option indices are still used by
the standalone COMEDI kernel modules built from comedi.org sources for
loading firmware in some driver modules, although they are no longer
used by the COMEDI kernel modules in the Linux kernel sources.  Adjust
the comment to reflect this.
2016-03-21 11:08:06 +00:00
Ian Abbott
ef4c4e2e08 Avoid using BIT(x) macro
The BIT(x) macro is used by some internal kernel headers and is not
used in user API kernel headers.  It was used incorrectly in the
"staging" kernel version of "comedi.h" in the "linux-next" tree for a
brief period.

Replace the use of BIT(x) with explicit masks.  Handle CR_INVERT
specially in SWIG to avoid it appearing as a negative integer.
_CR_FLAGS_MASK was defined twice, identically, in SWIG, so remove one of
the definitions.
2016-03-21 10:35:16 +00:00
Spencer E. Olson
32cb61fe90 Reimplement 371dcc56e6f7(strip comedi_/COMEDI prefix)
This patch reimplements 371dcc56e6 where the comedi_/COMEDI_ prefix was
removed.  Just like that patch, this patch also allows for all old names
to resolve properly.  Differently than that patch, this patch simply adds
new items in the modules dictionary with the comedi_/COMEDI_ prefix
removed.  Benefits of this approach:

1) Do not have to create a fake module.
2) Tab completion works well in ipython/python since the module is left
   intact.
3) Adding new items without the comedi_/COMEDI_ prefix happens only once at
   module load time, instead of every time an item is requested from the
   module.
2016-03-19 22:54:37 -06:00
Spencer E. Olson
b9821b9d8c Sync removal of obsolete/useless items in comedi.h
This patch removes COMEDI_CB_* macros that are of no use to userspace at
any rate.  COMEDI_CB_* are no longer in comedi.h in the staging tree, but
rather in comedidev.h.

This patch also removes an old commented-out INSN_CONFIG_GET_OTHER_SRC, the
value of which was already taken long ago by
INSN_CONFIG_GET_HARDWARE_BUFFER_SIZE.
2016-03-18 12:26:52 -06:00
Spencer E. Olson
5d36757aa6 Move old items of comedi.h into new "deprecated" section
This allows the body of comedi to maintain visual sync to that of the
staging tree.
2016-03-18 12:19:22 -06:00
Spencer E. Olson
5cb320d559 Use BIT(x) macro for better sync to staging comedi.h
This patch defines a copy of the kernel BIT(x) macro and syncs the use of
BIT(x) between the staging tree and comedilib versions of comedi.h
2016-03-18 12:09:04 -06:00
Spencer E. Olson
0bb9805c82 Inherit documentation from staging comedi.h
This partial sync of staging tree to the comedilib version of comedi.h
brings documentation and some mild formatting.  The documentation should be
beneficial to userspace and the sync helps to visually maintain future
syncing between kernel and userspace code.
2016-03-18 12:05:17 -06:00
Spencer E. Olson
823bf1e398 Teach SWIG to properly handle some unsigned consts for python
This revisits the change made in da0fe745fc:
1)  Changes c-macro constants back to their original definition (without
    explicit typing them as unsigned) so-as to more exactly compare
    the comedilib version of comedi.h with that of the kernel module.
2)  Removes the duplicate definition of NI_GPCT_INVERT_CLOCK_SRC_BIT in
    comedi.i.
3)  Instead of redefining the macros to fix the mishandling of signedness
    by SWIG for python, teach SWIG to treat these as unsigned ints.
2016-03-18 10:17:11 -06:00
Spencer E. Olson
9d4b7367eb change static inline NI_* to macros
This is a partial sync of the staging tree to comedilib with these
benefits:
1.  This is first in a series of patches to sync comedilib to the kernel
    modules in the staging development tree.  The point of this series of
    patches is to make the syncing of the userspace and kernel comedi.h
    files be visually more easily done.

2.  This patch also teaches SWIG out to properly wrap these macros and
    provide them to the user.

3.  The redef of static inline NI_* functions as macro functions eases
    alternative use of comedi.h as an import source for a new ctypes-based
    python interface for comedilib.
2016-03-18 10:12:37 -06:00
Ian Abbott
ba27bddca4 include/comedi.h: synced with comedi
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
2016-03-18 12:07:08 +00:00
Spencer E. Olson
3f19af6b53 Documents stop_arg!=0 when stop_src=TRIG_NONE
This patch documents the new interpretation of stop_arg when stop_src ==
TRIG_NONE.  In the new interpretation, if stop_src==TRIG_NONE, a user may
specify that a buffer of finite length (and less than or equal to the
maximum buffer size) be repeated indefinitely.

For now, only the NI MIO driver implements this new interpretation.  All
other drivers should continue to force stop_arg==0 when
stop_src==TRIG_NONE.  In this case, the old behavior is maintained.
2016-03-08 22:47:52 -07:00
Spencer E. Olson
ea09b60196 update supported hardware list to include NI PXI-6251 2016-03-08 22:42:34 -07:00
Ian Abbott
65063d785e demo/mmap: support integer wraparound and large sample size
Currently, the 'front' and 'back' variables are of type 'int' (signed
32-bit integers).  The loop will break when 'front < back', which will
happen when more than 'INT_MAX' bytes of data have been produced.
Redefine them as 'unsigned int' and also allow 'front < back' which will
happen when more than 'UINT_MAX' bytes of data have been produced.
Because the buffer size is not necessarily a power of 2, we can no
longer just use '(back + i) % size' to get the buffer position
corresponding to 'back + i', so introduce a new variable 'bufpos' to
keep track of the buffer position.

Also allow for subdevices that set the 'SDF_LSAMPL' flag to indicate
they use the large (32-bit, 'lsampl_t') sample type instead of the small
(16-bit, 'sampl_t') sample type.

Also, rename the buffer size variable 'size' to 'bufsize'.
2015-11-23 16:04:11 +00:00
Ian Abbott
49f298cf86 lib/range.c: deal with samples > maxdata when converting to phys
By default, comedi_to_phys() and comedi_sample_to_phys() return NAN (not
a number) if the raw sample value is 0 or maxdata.  Change it to convert
any raw sample values above maxdata to NAN.  Such raw samples shouldn't
occur, but this seems like a sensible thing to do.  (Note that the
conversion of out-of-range values to NAN behavior can be changed via the
comedi_set_global_oor_behavior() function.)
2015-08-24 17:33:11 +01:00
Ian Abbott
3e337824f4 lib/calib_yacc.y: fix segfault in comedi_parse_calibration_file()
Don't call fill_inverse_linear_polynomials(priv.parsed_file) if
priv.parsed_file is NULL as that would dereference the NULL pointer
leading to a segmentation fault.
2015-08-20 13:02:53 +01:00
Ian Abbott
abb45335e3 doc: Bump to version 0.10.3. 2015-06-08 11:53:50 +01:00
Ian Abbott
6065b188d1 configure.ac: Bump to 0.10.3
Bump the comedilib libtool version code to 10:3:10, so the comedilib
version becomes 0.10.3.
2015-06-08 11:52:07 +01:00
Éric Piel
da0fe745fc include: explicitly indicate values are unsigned when it could matter
In C, mixing up between int and unsigned int doesn't matter too much for constants
because in memory they end up the same.
However, in Python, they appear differently.

Swig assumes (wrongly?) by default that the constants are signed, intead of being unsigned.
For every value equal or greater that 2**31, it matters.
For instance CR_INVERT should be 2147483648, but it is -2147483648 in python.
By marking the values explicitly unsigned, swig generates the right values.

That's excepted for enum, which swig just consider int. So for the only constant in that
case, we manually override it in swig.
2015-06-08 11:21:11 +01:00
Ian Abbott
cda898efc6 doc: update copyright years 2015-05-28 13:45:18 +01:00
Ian Abbott
29607869cd doc: fix capitalization of National Instruments 2015-05-28 13:35:58 +01:00
Éric Piel
16142b8d9c doc: add information about using the National Instrument GPCT
The counter interface might eventually be changed to a more generic one.
However, for now it's good to have something documented on how things work.
2015-05-28 13:33:57 +01:00
Éric Piel
027ca2c5ad doc: fix names of *SOURCE constants to *_SRC
Synchronises the content of the documentation with the actually content of the include files.
2015-05-28 13:30:26 +01:00
Ian Abbott
9683559f51 comedi_test: fix test_cmd_write_fast_1chan() for big buffer
If the comedi data buffer is larger than the total size of the data
being written to the buffer in first test_cmd_write_fast_1chan(), the
first loop iterates endlessly writing 0 bytes to the buffer.  Break out
of the first loop once the required amount of data has been written.
2014-04-10 20:19:43 +01:00
Ian Abbott
207c72b0f9 Makefile.am: Use '$(localstatedir)' instead of '${localstatedir}'
In the rule to make the 'calibrations' directory during installation,
use Make variable '$(localstatedir)' instead of shell variable
'${localstatedir}'.  Also remove an unnecessary '/' after '$(DESTDIR)'
in the rule.
2014-04-04 15:03:25 +01:00
Ian Abbott
2b4d72f009 Makefile.am: create calibrations directory during installation
Add an install-data-local rule that creates the
${localstatedir}/lib/comedi/calibrations during installation.  This
matches the directory name used by the
comedi_get_default_calibration_path() function.
2014-04-04 12:11:35 +01:00
Ian Abbott
ae0e6dae04 configure.ac: Added AC_PROG_MKDIR_P 2014-04-04 11:19:50 +01:00
Ian Abbott
f55d30396a lib/Makefile.am: Add 'comedi_la_LIBADD = -lm'
Builds on some systems need the line:

comedi_la_LIBADD = -lm

in lib/Makefile.am

Reported by Jan Banda, using a Linux Mint Petra system with gcc version
4.8.1.
2014-02-13 11:39:35 +00:00
Éric Piel
371dcc56e6 swig: remove comedi_ prefix from the function names
python always use the namespace of the library so it was redundant.

so what used to be written comedi.comedi_open() can be written comedi.open().

The main trick is to add a special python code that allows for the old names to still be compatible.
That avoids to break every single python program previously written.
2014-02-03 12:32:51 +00:00
Ian Abbott
1465834a26 demo/inpn: correct ranges in range loop
The demo is supposed to take one reading for each channel for each
range, but was using the range from the command line options instead.

Thanks to Daniele Mazzi for spotting the bug!
2014-01-09 15:23:13 +00:00
Ian Abbott
6ee63ff0b0 README.Git: add minimum required Bison version
The minimum required version of Bison when building from git sources is
1.875 or possibly higher.  Mention 1.875 as the minimum version for now.
2014-01-07 14:56:22 +00:00
Ian Abbott
2277e82787 lib/calib_yacc.y: eliminate priv() casting function
Parse parameters are now passed as the correct type instead of `void *`,
so the static inline priv() function is no longer needed to cast the
pointer to the correct type.
2014-01-07 14:28:43 +00:00
Ian Abbott
c689eff475 lib: replace YYPARSE_PARAM and YYLEX_PARAM
In the Bison source calib_yacc.y, replace the use of YYPARSE_PARAM and
YYLEX_PARAM C macros with the %parse-param and %lex-param declarations.
I still need a C macro in combination with %lex-param for it to work, so
I'm not sure I'm doing it right!

Also correct the %pure_parser declaration which should be %pure-parser
(i.e. the underscore should be a dash).  This has a knock-on effect for
the yyerror() function, which now needs an extra parameter.
2014-01-07 14:24:36 +00:00
Ian Abbott
e8cefc0a0d demo/ao_mmap: remove spurious 'i' from an output message 2013-11-08 13:12:01 +00:00
Ian Abbott
1f0020e108 demo/ao_mmap: remove msync() call
The msync() call doesn't seem to work on Comedi devices, and seems a bit
pointless anyway, as it is meant for use on files with a backing store.
Remove it.
2013-11-08 13:06:38 +00:00
Ian Abbott
5f3b60573e m4/am-check-python-headers.m4: Try python-config --includes
Some systems (e.g. Arch Linux) put the Python C headers in a strange
place, so try and run `$PYTHON-config --includes` first to find the -I
options to pass to the C compiler.  Fall back to the old method if it
fails.

Thanks to Darrell Enns for reporting the problem and suggesting a
solution.  I changed it a bit.
2013-08-21 11:06:24 +01:00
Ian Abbott
155529234a doc/funcref: fixed a couple of minor mark-up issues. 2013-07-23 17:43:19 +01:00
Ian Abbott
18fc613988 include/comedi.h: synced with comedi
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
2013-05-14 17:35:49 +01:00
Ian Abbott
6c5d883481 demo: tut3.c: add 'return 0;' to end of main() function. 2013-05-14 14:25:50 +01:00
Ian Abbott
0404ed50dd doc/driverwriting.xml: editing Kbuild
Add a step to the instructions for integrating a new driver into comedi.
The Kbuild file needs to be edited.
2013-05-14 12:50:14 +01:00
Ian Abbott
383919639a demo/sender: add error checking
Check for errors from comedi_dio_config() and comedi_do_insnlist().
2013-05-07 13:43:11 +01:00
Ian Abbott
c413483a66 demo/dio: exit with failure if comedi_dio_config() fails. 2013-05-07 13:29:54 +01:00
Ian Abbott
a19f4d463f demo/choose_routing: remove unused variable 'period_ns'. 2013-05-07 13:24:03 +01:00
Ian Abbott
82ee0c80e2 testing: remove unused variables in comedi_test program
Remove the global variable 'capabilities' which is set to 0 by the
get_capabilities() function but not used anywhere else.  Remove the
'type' and 'flags' local variables from get_capabilities() which are set
to the return values of comedi_get_subdevice_type() and
comedi_get_subdevice_flags() but never used.  Remove the 'tmp' local
variable from test_segfault(); it was involved in a volatile memory
access to test for segmentation faults.  Still do the volatile memory
access but don't use the variable.
2013-05-07 13:15:54 +01:00
Ian Abbott
fdf9d2d98b lib/data.c: remove unused variables
Remove unused variable 's' from comedi_data_write() and
comedi_data_read_delayed().
2013-05-07 13:01:08 +01:00
Ian Abbott
0868eccbf7 lib: remove cached cmd_timed and cmd_timed_errno from subdevice
Remove the cmd_timed and cmd_timed_errno members from the internal
struct subdevice_struct.

cmd_timed_errno is checked but never set, so it will always be 0 and the
code that uses it is buggy as it returns the value of s->cmd_mask_errno
if s->cmd_timed_errno is non-zero and sets s->cmd_mask_errno on failure.
It shouldn't be setting s->cmd_mask_errno at all.

Since the generic timed command could depend on the length of the
channel list, don't bother caching the result, and don't set
s->cmd_mask_errno on failure.
2013-05-07 12:58:30 +01:00
Ian Abbott
2811aea038 lib: check some malloc/calloc/realloc failures
Some calls to malloc(), realloc() or calloc() do not check the result.
Do so.  Also call internal function libc_error() if they fail to set the
result for comedi_errno().
2013-05-07 12:32:26 +01:00
Ian Abbott
df2466c0f6 doc: add missing -lm option to command line for compiling tut1 2013-04-15 12:26:05 +01:00
Ian Abbott
ada711164c doc: Bump to version 0.10.2. 2013-03-21 16:36:42 +00:00