pycomedi.git
10 years agoconstant: Avoid non-integer values in _Enum
W. Trevor King [Thu, 17 Jul 2014 18:12:36 +0000 (11:12 -0700)]
constant: Avoid non-integer values in _Enum

When my lowercase names collide (e.g. for COMEDI_TO_PHYSICAL and
comedi_to_physical), we want to add the integer value to the enum, not
the function value.  This avoids:

  >>> from pycomedi.device import Device
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "instruction.pxd", line 22, in init pycomedi.device (pycomedi/device.c:4532)
    File "instruction.pyx", line 25, in init pycomedi.instruction (pycomedi/instruction.c:2427)
    File "chanspec.pyx", line 20, in init pycomedi.chanspec (pycomedi/chanspec.c:2571)
    File "constant.pyx", line 469, in init pycomedi.constant (pycomedi/constant.c:10017)
    File "constant.pyx", line 244, in pycomedi.constant._Enum.__init__ (pycomedi/constant.c:3804)
    File "constant.pyx", line 260, in pycomedi.constant._Enum._add_item (pycomedi/constant.c:4305)
  TypeError: unorderable types: builtin_function_or_method() < int()

I'm not sure how I haven't bumped into this before.  Perhaps Cython
0.19.1 has stronger type-checking for its comparison operaters than my
old 0.17.4.

10 years agoconstant: Use dir(comedi.wrapped) when comedi.wrapped exists
W. Trevor King [Thu, 17 Jul 2014 17:35:00 +0000 (10:35 -0700)]
constant: Use dir(comedi.wrapped) when comedi.wrapped exists

Since 371dcc5 (swig: remove comedi_ prefix from the function names,
2014-01-31, released in comedilib 0.10.2), dir(comedi) no longer lists
the meaty-bits:

  >>> import comedi
  >>> comedi.CR_ALT_FILTER
  67108864
  >>> [attr for attr in dir(comedi) if attr.startswith('CR_')]

Instead, they have shifted to comedi.wrapped:

  >>> [attr for attr in dir(comedi.wrapped) if attr.startswith('CR_')]
  ['CR_ALT_FILTER', 'CR_ALT_SOURCE', 'CR_DEGLITCH', 'CR_DITHER', 'CR_EDGE',
   'CR_FLAGS_MASK', 'CR_INVERT']

This commit adjusts pycomedi to use comedi.wrapped when it exists, so
pycomedi will work with the new comedilib (and continue working with
the old comedilibs).

I also have to remove 'COMEDI_' from the prefixes that contain it to
catch up with 371dcc5:

  +%rename("%(strip:[COMEDI_])s", regextarget=1) "COMEDI_.*";

Reported-by: Colin Jermain <clj72@cornell.edu>
11 years agoMANIFEST.in: Distribute test.sh
W. Trevor King [Tue, 26 Mar 2013 23:42:24 +0000 (19:42 -0400)]
MANIFEST.in: Distribute test.sh

Like the docs, this script is useful to have in the distributed
tarball, even if it's not installed by setup.py.

Reported-by: Nuno Rombert Pinhão <npinhao@ctn.ist.utl.pt>
11 years agoMANIFEST.in: Distribute the doc directory (but don't install it)
W. Trevor King [Tue, 26 Mar 2013 19:32:29 +0000 (15:32 -0400)]
MANIFEST.in: Distribute the doc directory (but don't install it)

Put the docs in the distribution tarball, so folks don't need to
checkout the Git repository just to read the docs.

Reported-by: Nuno Rombert Pinhão <npinhao@ctn.ist.utl.pt>
11 years agoBump to version 0.7 0.7
W. Trevor King [Wed, 6 Feb 2013 23:08:24 +0000 (18:08 -0500)]
Bump to version 0.7

Changes since 0.6:
* MANIFEST.in: Distribute *.pxd files
* channel: Fix to-physical setup in AnalogChannel._get_converter
* A few documentation fixes and updates

11 years agoMANIFEST.in: Distribute *.pxd files
W. Trevor King [Wed, 6 Feb 2013 23:07:10 +0000 (18:07 -0500)]
MANIFEST.in: Distribute *.pxd files

On Wed, Feb 06, 2013 at 07:35:31PM -0200, Mauricio de Alencar wrote:
> The package at pypi is incomplete (see below). I got the source from
> git and it builds OK.

11 years agoREADME: Double-backtick code for proper ReST markup
W. Trevor King [Thu, 17 Jan 2013 22:51:28 +0000 (17:51 -0500)]
README: Double-backtick code for proper ReST markup

11 years agochannel: Fix to-physical setup in AnalogChannel._get_converter
W. Trevor King [Thu, 17 Jan 2013 14:00:20 +0000 (09:00 -0500)]
channel: Fix to-physical setup in AnalogChannel._get_converter

This fixes a bug introduced by

  commit ac38a7987800c3982ac363af5b7780885c88d3a1
  Author: W. Trevor King <wking@tremily.us>
  Date:   Fri Oct 19 09:53:22 2012 -0400

    calibration: support to-physical-only softcal boards.

where the converter's _from_physical was only initialized if there was
an error trying to determine its value.  Obviously, we should only be
initializing it if there *wasn't* an error.

11 years agochannel: Add docstring summaries to get_{hard,soft}cal_converter
W. Trevor King [Thu, 17 Jan 2013 13:49:01 +0000 (08:49 -0500)]
channel: Add docstring summaries to get_{hard,soft}cal_converter

12 years agosetup.py: add explicit classifier for GPLv2+
W. Trevor King [Tue, 20 Nov 2012 03:33:41 +0000 (22:33 -0500)]
setup.py: add explicit classifier for GPLv2+

12 years agoBump to version 0.6. 0.6
W. Trevor King [Tue, 20 Nov 2012 03:16:59 +0000 (22:16 -0500)]
Bump to version 0.6.

Major changes since v0.5:

* Python 3 compatibility
* Soft-calibration support (with help from Éric Piel) with new
  calibration classes: Caldac, CalibrationSetting, and Calibration

12 years agob89928: upgrade to Bugs Everywhere Directory v1.5
W. Trevor King [Sat, 27 Oct 2012 16:31:38 +0000 (12:31 -0400)]
b89928: upgrade to Bugs Everywhere Directory v1.5

12 years agodemo/aout: support also samples with only one channel
Éric Piel [Mon, 22 Oct 2012 14:07:32 +0000 (15:07 +0100)]
demo/aout: support also samples with only one channel

scipy.io.wavfile returns a one dimension array if the wav file is only one channel

12 years ago.update-copyright.conf: update to pipe separators.
W. Trevor King [Sat, 20 Oct 2012 11:14:55 +0000 (07:14 -0400)]
.update-copyright.conf: update to pipe separators.

This brings the config file up to speed with the following
update-copyright commit:

  commit 3c68a1a48419d8b2bbc2ce0e7f1700b996ec30e9
  Author: W. Trevor King <wking@tremily.us>
  Date:   Fri Oct 19 21:52:48 2012 -0400

    project: for consistency, also separate ignored paths with pipes

12 years agoFix broken dependency linearization.
W. Trevor King [Sat, 20 Oct 2012 02:20:20 +0000 (22:20 -0400)]
Fix broken dependency linearization.

I had tried to break circular dependencies with:

  commit c19dd6ff6ce26beaf1b0ffc57d505b71898f8d0f
  Author: W. Trevor King <wking@tremily.us>
  Date:   Fri Oct 19 08:58:34 2012 -0400

    Break circular dependencies for Python 3 compatibility.

Which was causing errors like:

  Exception AttributeError:
    "'pycomedi.device.Device' object has no attribute 'device'"
    in 'pycomedi.subdevice.Subdevice._device'

because when you treat Device instances as Python objects, you cannot
access their private (C-only) attributes.  This commit avoids that
problem by adding low level classes (DeviceHolder and SubdeviceHolder)
that can be imported by both the high level classes (Device and
Subdevice) and their users (Subdevice and Channel), avoiding circular
dependencies while preserving critical C-only attributes.

12 years agoAllow exceptions from other cdef functions.
W. Trevor King [Sat, 20 Oct 2012 00:26:22 +0000 (20:26 -0400)]
Allow exceptions from other cdef functions.

12 years agosend excpetions from get_softcal_converter and get_hardcal_converter
Éric Piel [Fri, 19 Oct 2012 14:50:50 +0000 (16:50 +0200)]
send excpetions from get_softcal_converter and get_hardcal_converter

this allows to catch them from _get_converter()

12 years agocalibration: support to-physical-only softcal boards.
W. Trevor King [Fri, 19 Oct 2012 13:53:22 +0000 (09:53 -0400)]
calibration: support to-physical-only softcal boards.

This is a hack to fix Éric Piel's issue:

On Thu, Oct 18, 2012 at 12:10:49PM +0200, Éric Piel wrote:
> Unfortunately, with my device there seems to still be a problem with
> comedi_get_softcal_converter(), which returns -1 with direction
> from_physical. I get the same problem when using the SWIG wrapper, so
> it's probably not an error in pycomedi. So when I run cmd.py I get this
> error, but it works anyway as the _to_phys converter works:
> ./cmd.py -f /dev/comedi0 -s 0 -c 0 -a diff -N 1 -p
> Exception pycomedi.PyComediError:
> PyComediError('comedi_get_softcal_converter: Resource temporarily
> unavailable (-1)',) in
> 'pycomedi.channel.AnalogChannel.get_softcal_converter' ignored
> 0.220157

I feel like we should make an effort to invert the from_physical
polynomial, but as a stop-gap measure, we can just raise the original
exception and let the user decide what to do about it.

12 years agoREADME: update to mention optional python-kmod dependency.
W. Trevor King [Fri, 19 Oct 2012 13:26:25 +0000 (09:26 -0400)]
README: update to mention optional python-kmod dependency.

12 years agoinfo.py: add optional kmod modinfo section.
W. Trevor King [Fri, 19 Oct 2012 13:19:15 +0000 (09:19 -0400)]
info.py: add optional kmod modinfo section.

The older info.py version only used comedilib to extract board
information, including the comedi version in use.  While the
out-of-kernel comedi module does bump their versions (occasionally ;),
the in-kernel staging drivers still claim version 0.7.76 (despite
being mostly equivalent to the out-of-tree module 0.10.1).  This makes
it useful to differentiate between in-kernel and out-of-kernel modules
by printing some modinfo details, for which I'm using the kmod Python
bindings (python-kmod).

I'm currently using my Cython branch of python-kmod, which is pending
a merge upstream [1].

[1]: https://github.com/agrover/python-kmod/pull/3

12 years agoUpdate to `except ... as ...` syntax for Python 3.
W. Trevor King [Fri, 19 Oct 2012 13:05:17 +0000 (09:05 -0400)]
Update to `except ... as ...` syntax for Python 3.

12 years agoBreak circular dependencies for Python 3 compatibility.
W. Trevor King [Fri, 19 Oct 2012 12:58:34 +0000 (08:58 -0400)]
Break circular dependencies for Python 3 compatibility.

12 years agocmd.py: importing matplotlib without X can raise RuntimeErrors.
W. Trevor King [Thu, 18 Oct 2012 18:09:53 +0000 (14:09 -0400)]
cmd.py: importing matplotlib without X can raise RuntimeErrors.

For example, with the GTKAgg backend selected in
~/.matplotlib/matplotlibrc, running cmd.py without X raises:

  Traceback (most recent call last):
    File "./cmd.py", line 32, in <module>
      from matplotlib import pyplot as _pyplot
    ...
  RuntimeError: could not create GdkCursor object

12 years agocalibration: fix parameter type
Éric Piel [Thu, 18 Oct 2012 09:52:58 +0000 (11:52 +0200)]
calibration: fix parameter type

need to send the pointer to the C struct, not the python object

12 years agofix compilation with cython 0.15.1
Éric Piel [Thu, 18 Oct 2012 08:32:48 +0000 (10:32 +0200)]
fix compilation with cython 0.15.1

Need to help cython to find out that a new CalibrationSetting is a CalibrationSetting, otherwise
it thinks that its properties are python objects.

12 years agoAdd `-*- coding: utf-8 -*-` comments where Éric Piel is in authors.
W. Trevor King [Wed, 17 Oct 2012 20:05:24 +0000 (16:05 -0400)]
Add `-*- coding: utf-8 -*-` comments where Éric Piel is in authors.

12 years agoRan update-copyright.py.
W. Trevor King [Wed, 17 Oct 2012 20:03:01 +0000 (16:03 -0400)]
Ran update-copyright.py.

12 years agoMANIFEST.in: add AUTHORS (generated by update-copyright.py).
W. Trevor King [Wed, 17 Oct 2012 20:02:40 +0000 (16:02 -0400)]
MANIFEST.in: add AUTHORS (generated by update-copyright.py).

12 years agosetup: use format() for formatting strings.
W. Trevor King [Wed, 17 Oct 2012 19:41:44 +0000 (15:41 -0400)]
setup: use format() for formatting strings.

12 years agosetup: add explicit Python 2.7 and 3.2 classifiers.
W. Trevor King [Wed, 17 Oct 2012 19:40:55 +0000 (15:40 -0400)]
setup: add explicit Python 2.7 and 3.2 classifiers.

12 years agocmd: add --plot option (for use with --callback).
W. Trevor King [Wed, 17 Oct 2012 19:59:17 +0000 (15:59 -0400)]
cmd: add --plot option (for use with --callback).

12 years agocmd: add poll() calls to try and flush data off card.
W. Trevor King [Wed, 17 Oct 2012 19:46:09 +0000 (15:46 -0400)]
cmd: add poll() calls to try and flush data off card.

In order to bring data off the card faster, we'll try and use the
subdevice.poll() command.  I may be doing this wrong, though, because
all of the poll() calls return zero.

12 years agopycomedi_demo_args: comment on what happens with lots of verbose args.
W. Trevor King [Wed, 17 Oct 2012 18:38:46 +0000 (14:38 -0400)]
pycomedi_demo_args: comment on what happens with lots of verbose args.

For example, if you call

  cmd.py -vvvvvvv

This will set pycomedi.LOG to DEBUG.

  WARN -> INFO
  INFO -> DEBUG
  no-op
  no-op
  etc.

The new comment makes this clearer, because it took me a minute to
understand the implementation ;).

12 years agocmd: flush stream in write_data().
W. Trevor King [Wed, 17 Oct 2012 18:30:02 +0000 (14:30 -0400)]
cmd: flush stream in write_data().

12 years agocalibration: fix Python-to-caldac cast in CalibrationSetting._caldacs_set.
W. Trevor King [Wed, 17 Oct 2012 17:12:31 +0000 (13:12 -0400)]
calibration: fix Python-to-caldac cast in CalibrationSetting._caldacs_set.

Pointed out by Éric Piel using Cython 0.15.1:

  Error compiling Cython file:
  ------------------------------------------------------------
  ...
              raise MemoryError()
          self.setting.num_caldacs = length
          for i,x in enumerate(value):
              if i >= length:
                  raise ValueError((i, length))
              self.setting.caldacs[i] = x
                                        ^
  ------------------------------------------------------------

  pycomedi/calibration.pyx:505:39: Cannot convert Python object to
  'comedi_caldac_t'

12 years agocalibration: set .num_arefs in CalibrationSetting._arefs_set.
W. Trevor King [Wed, 17 Oct 2012 17:07:23 +0000 (13:07 -0400)]
calibration: set .num_arefs in CalibrationSetting._arefs_set.

12 years agocalibration: add CalibrationSetting attribute-setting doctests.
W. Trevor King [Wed, 17 Oct 2012 17:04:35 +0000 (13:04 -0400)]
calibration: add CalibrationSetting attribute-setting doctests.

12 years agocalibration: shift settings[0] doctest spacing.
W. Trevor King [Wed, 17 Oct 2012 17:00:22 +0000 (13:00 -0400)]
calibration: shift settings[0] doctest spacing.

12 years agocalibration: add Caldac.allocate() for stand-alone caldac instances.
W. Trevor King [Wed, 17 Oct 2012 16:56:41 +0000 (12:56 -0400)]
calibration: add Caldac.allocate() for stand-alone caldac instances.

12 years agoREADME: warn about channel output during testing.
W. Trevor King [Wed, 17 Oct 2012 15:46:27 +0000 (11:46 -0400)]
README: warn about channel output during testing.

12 years agoMerge calibaration branch into master.
W. Trevor King [Wed, 17 Oct 2012 15:33:36 +0000 (11:33 -0400)]
Merge calibaration branch into master.

This feature branch adds support for loading and applying calibration
files, as well as for loading soft calibration converters.

12 years agochannel: standardize indentation in AnalogChannel._get_converter().
W. Trevor King [Wed, 17 Oct 2012 15:31:43 +0000 (11:31 -0400)]
channel: standardize indentation in AnalogChannel._get_converter().

12 years agochannel: add AnalogChannel.apply_calibration.
W. Trevor King [Wed, 17 Oct 2012 15:30:41 +0000 (11:30 -0400)]
channel: add AnalogChannel.apply_calibration.

12 years agocalibration: add Caldac, CalibrationSetting, and Calibration.
W. Trevor King [Tue, 16 Oct 2012 19:11:37 +0000 (15:11 -0400)]
calibration: add Caldac, CalibrationSetting, and Calibration.

Add Python wrappers around comedi_calibration_t and its
sub-structures.  This allows you to load calibration files (soft and
hard) and manipulate their contents in Python.

12 years agotest.sh: use Python-3-compatible print().
W. Trevor King [Tue, 16 Oct 2012 19:45:28 +0000 (15:45 -0400)]
test.sh: use Python-3-compatible print().

12 years agodevice: remove trailing whitespace from Éric's patch.
W. Trevor King [Tue, 16 Oct 2012 18:16:45 +0000 (14:16 -0400)]
device: remove trailing whitespace from Éric's patch.

12 years agoadd support for soft calibration
Éric Piel [Tue, 16 Oct 2012 10:44:30 +0000 (12:44 +0200)]
add support for soft calibration

12 years agoStrip trailing whitespace.
W. Trevor King [Tue, 16 Oct 2012 18:06:34 +0000 (14:06 -0400)]
Strip trailing whitespace.

12 years agoBump to version 0.5. 0.5
W. Trevor King [Sun, 22 Jul 2012 16:19:24 +0000 (12:19 -0400)]
Bump to version 0.5.

12 years agoAdd MANIFEST to .gitignore.
W. Trevor King [Sun, 22 Jul 2012 16:19:10 +0000 (12:19 -0400)]
Add MANIFEST to .gitignore.

12 years agoRan update-copyright.py.
W. Trevor King [Fri, 11 May 2012 18:06:14 +0000 (14:06 -0400)]
Ran update-copyright.py.

12 years agoAUTHORS should not be version controlled (generated by update-copyright.py).
W. Trevor King [Fri, 11 May 2012 18:05:46 +0000 (14:05 -0400)]
AUTHORS should not be version controlled (generated by update-copyright.py).

12 years ago.update-copyright.conf should not be executable.
W. Trevor King [Fri, 11 May 2012 18:04:08 +0000 (14:04 -0400)]
.update-copyright.conf should not be executable.

12 years agoOops, convert period from seconds to nanoseconds in cmd.py demo.
W. Trevor King [Thu, 26 Apr 2012 18:27:27 +0000 (14:27 -0400)]
Oops, convert period from seconds to nanoseconds in cmd.py demo.

12 years agoAdd --callback option to cmd.py demo to use CallbackReader.
W. Trevor King [Thu, 26 Apr 2012 17:21:42 +0000 (13:21 -0400)]
Add --callback option to cmd.py demo to use CallbackReader.

12 years agoThe --verbose argument to the demo scripts doesn't take arguments.
W. Trevor King [Thu, 26 Apr 2012 17:17:02 +0000 (13:17 -0400)]
The --verbose argument to the demo scripts doesn't take arguments.

12 years agoFix conversion to physical in cmd.py demo ('float32' is not defined).
W. Trevor King [Thu, 26 Apr 2012 17:06:36 +0000 (13:06 -0400)]
Fix conversion to physical in cmd.py demo ('float32' is not defined).

12 years agoAdd pycomedi.utility.CallbackReader for handling read data as it comes in.
W. Trevor King [Thu, 26 Apr 2012 16:56:43 +0000 (12:56 -0400)]
Add pycomedi.utility.CallbackReader for handling read data as it comes in.

12 years agoChange my email address from drexel.edu to tremily.us.
W. Trevor King [Wed, 18 Apr 2012 17:22:07 +0000 (13:22 -0400)]
Change my email address from drexel.edu to tremily.us.

12 years agoRan update-copyright.py.
W. Trevor King [Tue, 17 Apr 2012 16:37:15 +0000 (12:37 -0400)]
Ran update-copyright.py.

12 years agoAdd doc/demo/aout.py example of repeated analog output.
W. Trevor King [Tue, 17 Apr 2012 16:30:27 +0000 (12:30 -0400)]
Add doc/demo/aout.py example of repeated analog output.

This script contains the condensed wisdom of mailing list
discussions between Richard Höchenberger and myself.

Cc: Richard Höchenberger
12 years agoWrap long lines in doc/demo/info.py.
W. Trevor King [Tue, 17 Apr 2012 16:29:54 +0000 (12:29 -0400)]
Wrap long lines in doc/demo/info.py.

12 years ago'channels' default should be a list in pycomedi_demo_args.py.
W. Trevor King [Tue, 17 Apr 2012 16:29:34 +0000 (12:29 -0400)]
'channels' default should be a list in pycomedi_demo_args.py.

12 years agoWrap long help lines in pycomedi_demo_args.py.
W. Trevor King [Tue, 17 Apr 2012 16:29:00 +0000 (12:29 -0400)]
Wrap long help lines in pycomedi_demo_args.py.

12 years agoAdd `block_while_running` option to `_ReadWriteThread`.
W. Trevor King [Tue, 17 Apr 2012 16:22:22 +0000 (12:22 -0400)]
Add `block_while_running` option to `_ReadWriteThread`.

This way users don't need to understand the following distinctions:

* written to driver vs. output from card.
* `SDF_BUSY` vs. `SDF_RUNNING`.

The `subdevice.cancel` call in `_ReadWriteThread.block` is because the
`RUNNING` flag is cleared after output completes, but the `BUSY` flag
is not.  This may be a bug in Comedi.  I've asked on the mailing list,
but haven't heard back yet.

12 years agoAdd positional arguments to format strings for Python 2.6 compatibility.
W. Trevor King [Thu, 12 Apr 2012 14:43:19 +0000 (10:43 -0400)]
Add positional arguments to format strings for Python 2.6 compatibility.

For 2.7 and later, the positional arguments can be omitted, but
Richard Höchenberger (and others?) wants to run pycomedi on 2.6.

12 years agoAdd trailing slash to Gentoo overlay link in README.
W. Trevor King [Wed, 21 Mar 2012 16:48:59 +0000 (12:48 -0400)]
Add trailing slash to Gentoo overlay link in README.

12 years agoRework demos so that test.sh covers their critical parts.
W. Trevor King [Tue, 20 Mar 2012 11:51:26 +0000 (07:51 -0400)]
Rework demos so that test.sh covers their critical parts.

12 years agoAdd --mmap argument to cmd.py demo and fix some pycomedi_demo_args.py bugs.
W. Trevor King [Tue, 20 Mar 2012 01:16:06 +0000 (21:16 -0400)]
Add --mmap argument to cmd.py demo and fix some pycomedi_demo_args.py bugs.

12 years agoFix subdevice._device -> subdevice.device in _MMapReadWriteThread._fileno().
W. Trevor King [Tue, 20 Mar 2012 01:07:00 +0000 (21:07 -0400)]
Fix subdevice._device -> subdevice.device in _MMapReadWriteThread._fileno().

When I was writing the Cython implementation, I initially tried to
keep more things private, before realizing that that wasn't a good
idea.  This snippit missed the initial transition.

12 years agoConsolidate demo argument parsing in pycomedi_demo_args.py to reduce duplication.
W. Trevor King [Mon, 19 Mar 2012 18:51:40 +0000 (14:51 -0400)]
Consolidate demo argument parsing in pycomedi_demo_args.py to reduce duplication.

12 years agoAdd cmd.py demo.
W. Trevor King [Mon, 19 Mar 2012 17:47:29 +0000 (13:47 -0400)]
Add cmd.py demo.

12 years agoAllow AnalogChannel.__init__ to take integers for `range`.
W. Trevor King [Mon, 19 Mar 2012 17:34:25 +0000 (13:34 -0400)]
Allow AnalogChannel.__init__ to take integers for `range`.

If you know the index of your desired range, you can now use that
index directly and skip the usual call to `find_range`.

12 years agoActually listen to the --subdevice option in the insn.py demo.
W. Trevor King [Mon, 19 Mar 2012 16:41:29 +0000 (12:41 -0400)]
Actually listen to the --subdevice option in the insn.py demo.

12 years agoAdd insn.py demo.
W. Trevor King [Mon, 19 Mar 2012 16:21:53 +0000 (12:21 -0400)]
Add insn.py demo.

12 years agoDon't set log levels for pycomedi.LOG handlers.
W. Trevor King [Mon, 19 Mar 2012 16:17:40 +0000 (12:17 -0400)]
Don't set log levels for pycomedi.LOG handlers.

That's too much granularity for the default situation, where there is
only one handler and we can use the logger's level to control
verbosity.

12 years agoFix error condition `ret < 0` -> `ret < len(insnlist)` for Device.do_insnlist.
W. Trevor King [Mon, 19 Mar 2012 16:10:18 +0000 (12:10 -0400)]
Fix error condition `ret < 0` -> `ret < len(insnlist)` for Device.do_insnlist.

The previous implemenation would apparently succeed if there was an
error executing an instruction.  It would only raise an exception if a
failure occured before the first instruction could be executed.

12 years agoAdd 'external' unit for RF_EXTERNAL (see previous commit for reasoning).
W. Trevor King [Mon, 19 Mar 2012 15:43:34 +0000 (11:43 -0400)]
Add 'external' unit for RF_EXTERNAL (see previous commit for reasoning).

12 years agoRevert "Mask range.unit with 0xff when determining the unit."
W. Trevor King [Mon, 19 Mar 2012 15:26:43 +0000 (11:26 -0400)]
Revert "Mask range.unit with 0xff when determining the unit."

This reverts commit d721a0c05450c793a5e0e562d286a689565cf81b.

From the National Instruments E Series User Manual [1], page 3-2:

  Reference Selection

  (NI 6020E, NI PXI-6040E, NI 6052E, NI 6062E, NI 6070E/6071E, and
  PCI-MIO-16E-4 Devices Only) You can connect each DAC to the device
  internal reference of 10 V or to the external reference signal
  connected to the external reference (AO EXT REF) pin on the I/O
  connector. This signal applied to EXT REF should be within
  ±11 V. You do not need to configure both channels for the same mode.

So RF_EXTERNAL is a valid unit (i.e. in units of the AO EXT REF
signal).  The next commit will add this unit.

[1]: http://digital.ni.com/manuals.nsf/websearch/06115536722DAA558625728E007E6BA4
  Edition Date: February 2007
  Part Number:    370503K-01
  p

12 years agoAdd info.py demo.
W. Trevor King [Mon, 19 Mar 2012 15:10:30 +0000 (11:10 -0400)]
Add info.py demo.

12 years agoMask range.unit with 0xff when determining the unit.
W. Trevor King [Mon, 19 Mar 2012 14:48:36 +0000 (10:48 -0400)]
Mask range.unit with 0xff when determining the unit.

This avoids crashes like:

  Traceback (most recent call last):
    ...
    File "range.pyx", line 62, in pycomedi.range.Range.__str__
    File "range.pyx", line 70, in pycomedi.range.Range._unit_get
    File "constant.pyx", line 269, in pycomedi.constant._Enum.index_by_value
  KeyError: 256L

when RF_EXTERNAL is set.

12 years agoAdd attributes to PyComediError to make intelligent error handling easier.
W. Trevor King [Mon, 19 Mar 2012 13:31:28 +0000 (09:31 -0400)]
Add attributes to PyComediError to make intelligent error handling easier.

12 years agoAdd .ranges() method to Channel class.
W. Trevor King [Mon, 19 Mar 2012 13:09:30 +0000 (09:09 -0400)]
Add .ranges() method to Channel class.

12 years agoAdd .channels() method to Subdevice class.
W. Trevor King [Mon, 19 Mar 2012 13:04:42 +0000 (09:04 -0400)]
Add .channels() method to Subdevice class.

12 years agoAllow keywords for Channel.get_range().
W. Trevor King [Thu, 15 Mar 2012 13:54:41 +0000 (09:54 -0400)]
Allow keywords for Channel.get_range().

12 years agoAdd docstring to Channel.get_range.
W. Trevor King [Thu, 15 Mar 2012 13:45:57 +0000 (09:45 -0400)]
Add docstring to Channel.get_range.

12 years agoBump to verssion 0.4. 0.4
W. Trevor King [Thu, 15 Mar 2012 03:06:55 +0000 (23:06 -0400)]
Bump to verssion 0.4.

12 years agoAdd __reduce__() method to BitwiseOperator and _NamedInt.
W. Trevor King [Thu, 15 Mar 2012 02:55:45 +0000 (22:55 -0400)]
Add __reduce__() method to BitwiseOperator and _NamedInt.

This makes it possible to successfully pickle and deepcopy instances
of these types [1,2].  This gets the

  TRIG_SRC.now == copy.deepcopy(TRIG_SRC.now)

doctest working, which I needed to successfully dump h5config
ChoiceConfig objects that use _Enum choices [3].

For example, the newly fixed pypiezo.config.ChannelConfig [4] uses the
AREF enum values as possible choices for it's `analog-reference`
setting.  h5config makes deepcopies of mutable objects to avoid
confusion if the mutable is changed externally.  It then compares the
deepcopies with uncopied values.  Now that deepcopying works for
_NamedInts, the h5config behavior will work.

[1] http://docs.python.org/library/pickle.html#pickling-and-unpickling-extension-types
[2] http://docs.python.org/library/copy.html
[3] http://pypi.python.org/pypi/h5config/
[4] http://pypi.python.org/pypi/pypiezo/

12 years agoUse utility.lsample instead of numpy.uint in calibration._convert().
W. Trevor King [Thu, 15 Mar 2012 02:36:21 +0000 (22:36 -0400)]
Use utility.lsample instead of numpy.uint in calibration._convert().

Don't repeat yourself!  Also, numpy.uint is a uint64 on my amd64, and
that does not match with lsampl_t.

12 years agoYes, 2 < 3. (fix constant comparison doctest).
W. Trevor King [Thu, 15 Mar 2012 02:19:22 +0000 (22:19 -0400)]
Yes, 2 < 3.  (fix constant comparison doctest).

12 years agoFix rich comparison doctest prompts and add comparisons to None.
W. Trevor King [Thu, 15 Mar 2012 01:46:00 +0000 (21:46 -0400)]
Fix rich comparison doctest prompts and add comparisons to None.

The None comparison logic avoids:

  TypeError: long() argument must be a string or a number, not 'NoneType'

12 years agoOops, Cython uses __richcmp__() instead of __eq__(), etc.
W. Trevor King [Thu, 15 Mar 2012 01:37:59 +0000 (21:37 -0400)]
Oops, Cython uses __richcmp__() instead of __eq__(), etc.

http://docs.cython.org/src/userguide/special_methods.html#rich-comparisons

12 years agoAdd rich comparisons to BitwiseOperator (compare by .value).
W. Trevor King [Thu, 15 Mar 2012 01:33:06 +0000 (21:33 -0400)]
Add rich comparisons to BitwiseOperator (compare by .value).

12 years agoFix get_version_code parsing and split it off into a new Device.get_version method.
W. Trevor King [Wed, 14 Mar 2012 22:21:28 +0000 (18:21 -0400)]
Fix get_version_code parsing and split it off into a new Device.get_version method.

12 years agoFix wrtier -> writer typo in `pycomedi.utility._MMapReadWriteThread` docstring.
W. Trevor King [Tue, 13 Mar 2012 13:01:26 +0000 (09:01 -0400)]
Fix wrtier -> writer typo in `pycomedi.utility._MMapReadWriteThread` docstring.

12 years agoMove function_name extraction up in pycomedi/_error.pyx's comedi_get.
W. Trevor King [Thu, 8 Mar 2012 19:51:24 +0000 (14:51 -0500)]
Move function_name extraction up in pycomedi/_error.pyx's comedi_get.

This avoids:
  pycomedi/_error.pyx:43:29:
    local variable 'function_name' referenced before assignment

12 years agoUpdate URLs from einstein to tremily.
W. Trevor King [Wed, 22 Feb 2012 18:33:22 +0000 (13:33 -0500)]
Update URLs from einstein to tremily.

12 years agoRan update-copyright.py.
W. Trevor King [Thu, 16 Feb 2012 23:01:12 +0000 (18:01 -0500)]
Ran update-copyright.py.

12 years agoTransition to my external update-copyright package.
W. Trevor King [Thu, 16 Feb 2012 22:58:57 +0000 (17:58 -0500)]
Transition to my external update-copyright package.

http://pypi.python.org/pypi/update-copyright/

12 years agoChange to GPLv2+ licensing.
W. Trevor King [Wed, 25 Jan 2012 15:08:24 +0000 (10:08 -0500)]
Change to GPLv2+ licensing.

Previously COPYING and the README had claimed GPLv3+, but the headers
generated by update_copyright had used GPLv2+.  GPLv2+ is more
inclusive and closer to the standard Comedi library's LGPLv2.1+.