Use local function prepare_cmd_lib() -- which uses
comedi_get_cmd_generic_timed() -- to prepare a good command for the
device. Bail out early if it fails.
If the '-s' option has not been specified, default to using the current
'read' subdevice if there is one instead of defaulting to subdevice 0.
Fall back to using subdevice 0 if there is no 'read' subdevice.
If the '-s' option has not been specified, default to using the current
'read' subdevice if there is one instead of defaulting to subdevice 0.
Fall back to using subdevice 0 if there is no 'read' subdevice.
Report the seconds and microseconds values from the INSN_GTOD
instructions as unsigned values to postpone the Y2038 problem to a Y2106
problem. Be a bit more careful with the conversion to a signed
difference. We wouldn't normally expect time to go backwards, but it is
possible if the system time is set to to an older time between the
instructions.
Also, in the description of INSN_GTOD in the Comedilib manual,
explicitly mention that the seconds and microseconds values are
unsigned.
Attempt to make the streaming command demos work if the specified
subdevice is not the default 'read' or 'write' subdevice (depending on
the direction of the command).
This uses the new comedi_set_read_subdevice() and
comedi_set_write_subdevice() functions.
Changing the read or write subdevice is currently supported only by the
Linux "in-tree" version of Comedi since kernel version 3.19.
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'.
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!
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.
"Selecting master clock %d for channel %d on subdevice %d.\n"
The %d after subdevice was missing although the corresponding parameter
in the argument list was present.
also updated the tutorial. I've simplified the tut2.c
by using comedi2phys instead of comedi2physical. The use of
polynomials as a 2nd comedi program is a bit too difficult
for a novice and might deter the user to dig deeper into
the coding. Also, I've added tut3.c which is a stripped
down version of cmd.c and of that again the relevant lines
for the handbook to save space.
The old method only worked out of the box if you were running Python
2.1 on a 586. I imagine that is too small a slice of current users to
be worth hard coding ;).
This avoids:
Traceback (most recent call last):
...
File ".../mmap.py", line 96, in prepare_cmd
C.scan_begin_arg = 1e9/freq
...
TypeError: in method 'comedi_cmd_struct_scan_begin_arg_set',
argument 2 of type 'unsigned int'
With the previous implementation, `mmap` was importing the demo
script, not the standard `mmap` library module. From the docs [1]:
The directory containing the script being run is placed at the
beginning of the search path, ahead of the standard library
path. This means that scripts in that directory will be loaded
instead of modules of the same name in the library directory.
I'm not sure when this changed in Python, since the demo script
presumably worked with an earlier version.
[1]: http://docs.python.org/tutorial/modules.html#the-module-search-path
This catches it up for the folowing commits to the comedi repository:
commit 311e9c540217d60bdf56a1dba9eafe474fd3b218
Author: Bernd Porr <Bernd.Porr@f2s.com>
Date: Sun Jan 13 23:07:02 2008 +0000
Added a proper PWM subdevice for comedi.
commit 8092ed57ff38e1fcaf75a7e0bf3b8c4f5372f3d7
Author: Frank Mori Hess <fmhess@speakeasy.net>
Date: Sat Jan 31 22:13:09 2004 +0000
serial dio (SCXI) support from Caleb Tennis
This catches the Python demos up to:
commit 003b9ec501
Author: Ian Abbott <abbotti@mev.co.uk>
Date: Mon Nov 8 11:01:42 2010 +0000
Add chanlist_len parameter to comedi_get_cmd_generic_timed.