Commit graph

179 commits

Author SHA1 Message Date
Ian Abbott
ac2ce44520 Add channel-specific arm, disarm, and reset wrappers.
The comedi_arm(), comedi_disarm(), and comedi_reset() functions always
set the channel number in the corresponding configuration instructions
to 0, as they assume the channel number will be ignored by the driver.
Some drivers do in fact use the channel number in these configuration
instructions.  Add additional wrapper functions comedi_arm_channel(),
comedi_disarm_channel(), and comedi_reset_channel() to allow the channel
number to be specified.
2016-03-21 11:28:29 +00:00
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
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
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
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
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
f4e228e231 lib/calib_lex.l: Add #define YY_NO_INPUT to C pre-amble
This suppresses a compiler warning about 'input' defined but not used.
2013-03-21 15:49:18 +00:00
Ian Abbott
cc0c9e7405 lib/calib_yacc.y: Move comedi_parse_calibration_file()
Move the comedi_parse_calibration_file() function definition to the
bottom of the file.  It calls calib_yyparse() and the declaration might
not be in scope since we removed the declaration from
"lib/libinternal.h", but we know it will be declared somewhere above the
bottom of the generated "lib/calib_yacc.c" above the new location of
comedi_parse_calibration_file().
2013-03-21 15:36:14 +00:00
Ian Abbott
90ce9a94bd lib: fix calib_yyparse() conflict
For newer versions of Bison, the declaration of our calib_yyparse()
function in "lib/libinternal.h" clashes with that in the generated
"lib/calib_yacc.h".

Remove the declarations of calib_yyerror() and calib_yyparse() from
"lib/libinternal.h" and declare them in "lib/calib_yacc.c".
2013-03-21 15:12:35 +00:00
Anders Blomdell
2b8c2f8087 comedi_open has file descriptor leak
If something fails after a succesful open, cleanup fails to close the file.

The code

   cleanup:
         if(it)
                 free(it);

needs to be replaced with something like:

   cleanup:
         if (it) {
           if (it->fd >= 0) {
             close(it->fd);
           }
         free(it);

Regards

Anders Blomdell
2012-08-22 09:54:19 +01:00
Ian Abbott
2665ee5627 libcomedi: don't ignore channel in comedi_set_clock_source()
Fix bug reported by Finn Hoffman on comedi email list.
2011-12-01 15:37:43 +00:00
Ian Abbott
c530564317 #include <sys/stat.h> needed for fstat(). 2011-01-05 15:02:44 +00:00
Ian Abbott
b8a4f1a265 Added channel parameter to comedi_set_clock_source() and
comedi_get_clock_source().  Bumped library version to 0.10.0.
2010-03-19 13:44:56 +00:00
Ian Abbott
b06cecc151 comedi_find_range() should skip ranges that don't match specified units. 2010-02-17 18:28:15 +00:00
Ian Abbott
12eedd26b3 comedi_get_default_calibration_path(): Check result of asprintf() for error. 2009-02-18 15:35:09 +00:00
Ian Abbott
f2fdf25018 Move "comedi_errno.h" into "include/" and install it. 2009-02-18 14:47:06 +00:00
Ian Abbott
76a2e658b7 Put __comedi_errno variable into thread-local storage if the compiler
supports it.  Configuration test uses Alan Woodland's 'ax_tls.m4' from
<http://autoconf-archive.cryp.to/ax_tls.html>.
2009-02-18 14:10:54 +00:00
Ian Abbott
564e9680b0 Fixed do_test_for_insn_bits(), broken by validity checks added to
comedi_do_insnlist().  Call comedi_ioctl() instead of comedi_do_insnlist().
2008-12-18 17:23:14 +00:00
Ian Abbott
9a06deb6f9 Removed unneeded comedi_insnlist from do_test_for_insn(). 2008-12-18 16:44:20 +00:00
Ian Abbott
d8c3b29ca4 Corrected the 'BUG' message in do_test_for_insnlist() (it reported the
wrong function).
2008-12-18 16:38:51 +00:00
Ian Abbott
4df5ffd451 Added some device and subdevice validity checks. 2008-11-05 12:52:25 +00:00
Frank Mori Hess
8103c5334a Updated it to only run the (unreliable) do_test_for_insn_bits() if the
information was not available in the subdevice info.
2008-09-16 14:49:35 +00:00
Frank Mori Hess
b94b2ba024 Fixed memory leak in comedi_cleanup_calibration(). 2008-08-29 19:17:40 +00:00
Ian Abbott
64f8e05331 Fix some 64-bit warnings. 2008-04-23 18:53:09 +00:00
Frank Mori Hess
d0956ca8b5 Added comedi_get_hardware_buffer_size() wrapper function, and made
comedi_strerror return a const char*.
2008-03-28 15:56:35 +00:00
Frank Mori Hess
e0b0b89338 Allow comedi_cleanup_calibration to accept a NULL argument. 2008-03-14 17:52:20 +00:00
Frank Mori Hess
0695475797 Updated comedi_dio_config implementation to reflect logical split
between COMEDI_INPUT/COMEDI_OUTPUT and corresponding config insn ids
(even though they still have the same value).  Made comedi_dio_config
return 0 on success for better consistency in API.
2008-02-12 18:27:00 +00:00
Frank Mori Hess
0c69850ffc Made comedi_ioctl take its third argument as a void* instead of
and integer type, and got rid of a bunch of casts (and added a few).
2008-02-12 01:12:46 +00:00
Frank Mori Hess
a61ed59402 Fixed return values from comedi_mark_buffer_read/written(). Removed
some redundant assignments of __comedi_errno
2008-02-11 20:50:14 +00:00
Frank Mori Hess
a06bba542a Added more INSN_CONFIG wrappers: comedi_get_clock_source(),
comedi_get_gate_source(), and comedi_get_routing().  Added "channel"
parameter to some of the INSN_CONFIG wrappers.
2008-01-23 18:56:52 +00:00
Frank Mori Hess
76791bfeed Added comedi_set_filter() and comedi_set_routing() configuration
instruction wrappers.
2008-01-18 16:37:32 +00:00
Ian Abbott
1979b2f2cc More memory initialization, error detection and cleanup in get_subdevices()
and get_rangeinfo().
2008-01-17 13:52:02 +00:00
Ian Abbott
625d44af04 Free elements of rangeinfo_list on close. 2008-01-17 13:50:32 +00:00
Frank Mori Hess
37dc388297 Return 0 from the INSN_CONFIG wrappers on success. 2008-01-16 20:09:38 +00:00
Frank Mori Hess
ebe72a2b2a Added more memory initialization for the sake of valgrind (especially
memory that gets set by ioctls that valgrind can't see).  Added a little
error handling for a few memory allocations.
2008-01-16 19:45:05 +00:00
Frank Mori Hess
4d07ce9969 Moved some wrappers for INSN_CONFIG instructions into comedilib.
Will add some reference documentation for the new functions soon.
2008-01-15 21:01:40 +00:00
Ian Abbott
0b21f80783 Avoid mixing declarations and code. 2007-12-10 13:20:19 +00:00
Frank Mori Hess
f87490e0f6 Fixed setting of comedi_errno in comedi_dio_config() for invalid
arguments.
2007-12-01 15:54:08 +00:00
Frank Mori Hess
792e4b741f Got rid of obsolete error codes. 2007-12-01 15:53:18 +00:00
Frank Mori Hess
1081d0ff02 Gave libscxi independent version info from libcomedi. Removed
attempt to link to libcomedi when building libscxi.
2007-08-19 18:30:26 +00:00
Frank Mori Hess
c1082cee65 Fixed comedi_get_cmd_generic_timed() by adding a chanlist_len
parameter.  Old version is still available in library, thanks to the
magic of the version_script.
2007-08-02 19:46:44 +00:00
Frank Mori Hess
2b04263bed Actually, according to current:revision:age practice, the next
release should be 0.8.0 since new functions have been added since
0.7.22.
2007-07-31 02:44:29 +00:00
Frank Mori Hess
8d74d571b3 Move to current:revision:age discipline for library version numbers.
Bumped version for next release.
2007-07-31 02:21:24 +00:00
Ian Abbott
06fa9b06b1 Add calib_lex.h to noinst_HEADERS. 2007-07-24 13:38:14 +00:00
Frank Mori Hess
c80870a4a6 Fixed compile warning under gcc 4.1.2 2007-04-18 14:04:39 +00:00
Frank Mori Hess
34b9800e40 Added const qualifiers to some char* return values. Added new
experimental comedi_dio_bitfield2() function which works with
> 32 channels.  Only works properly with ni_65xx currently.
Will post a request for review by any interested
parties to list before I bother making the rest of the drivers
work with it.
2006-10-17 18:19:29 +00:00