Relying on <sys/types.h> to define major(), minor() and makedev() is
deprecated, so include <sys/sysmacros.h> to define them.
Als include <sys/types.h> and <unistd.h> as the Linux man page for
fstat() has them in the synopsys.
comedi_dio_get_config(), comedi_dio_read(), comedi_dio_write(),
comedi_dio_bitfield2() (and comedi_dio_bitfield()) return -1 if the
subdevice type is unsuitable, but do not set an internal comedi error
code in that case. Change them to do so.
Also, don't bother checking if instruction list ioctl is supported in
comedi_get_dio_config(), as it doesn't use it.
Change comedi_set_read_subdevice() and comedi_set_write_subdevice() to
do nothing if the requested subdevice is already set as the current read
or write subdevice, respectively.
The functions now return success even if the Comedi drivers do not
support changes to the read or write subdevice as long as the specified
subdevice is the default one.
Added comedi_get_buffer_read_offset(), comedi_get_buffer_write_offset(),
comedi_get_buffer_read_count(), and comedi_get_buffer_write_count().
comedi_get_buffer_read_offset() is the same as
comedi_get_buffer_offset(), which has now been documented as deprecated,
but is currently still declared in "comedilib.h" by default. It gets
the read position within the buffer as an offset from the start of the
buffer (modulo the buffer size).
comedi_get_buffer_write_offset() gets the write position within the
buffer as an offset from the start of the buffer (modulo the buffer
size).
comedi_get_buffer_read_count() gets the number of bytes read from the
buffer, modulo UINT_MAX+1.
comedi_get_buffer_write_count() gets the number of bytes written to the
buffer, modulo UINT_MAX+1.
These functions allow the current read or write subdevice to be changed
to another subdevice that supports streaming input (for read), or
streaming output (for write) asynchronous commands.
They return 0 on success, in which case the comedi_get_read_subdevice()
or comedi_get_write_subdevice() functions will get the updated read or
write subdevice.
Changes are local to the "open file description" that was created by
comedi_open() (actually, by open()), and have no effect on other open
file descriptions created by other calls to comedi_open() (or open())
for the same underlying Comedi device node.
Changes to the read or write subdevice is not currently supported by the
comedi.org version of the Comedi drivers, but is supported by the Linux
"in-tree" Comedi drivers since kernel version 3.19.
Since comedi_ioctl() calls libc_error() to set __comedi_errno to errno
(and possibly print an error message), there is no need for callers of
comedi_ioctl() to set __comedi_errno immediately afterwards. But
comedi_command(), comedi_command_test(), and comedi_do_insnlist()
currently do that. Remove the unneeded setting of __comedi_errno in
those functions.
Also, comedi_command() and comedi_command_test() check __comedi_errno
regardless of whether comedi_ioctl() returnis an error, and possibly
modify the error code to an internal comedi error. Change them to only
do that if comedi_ioctl() returns an error, because __comedi_errno might
contain a stale value.
Add wrapper functions for the INSN_CONFIG_DIGITAL_TRIG configuration
instruction. These are comedi_digital_trigger_disable(),
comedi_digital_trigger_enable_edges(), and
comedi_digital_trigger_enable_levels().
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.
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.
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.)
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.
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.
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.
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.
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.
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().
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().
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".
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
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.