Commit graph

177 commits

Author SHA1 Message Date
Ian Abbott
7a8b838e66 demo: poll: fix polling of wrong subdevice
The call to comedi_poll() always sets the subdevice parameter to 0.  Set
it to the subdevice that the streaming command is using.
2016-05-13 16:42:14 +01: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
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
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
6c5d883481 demo: tut3.c: add 'return 0;' to end of main() function. 2013-05-14 14:25:50 +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
648fac4772 demo/tut3.c: memset options to 0 before modifying
options.verbose was used uninitialized.
2012-05-14 15:04:10 +01:00
Ian Abbott
d1ad074b8c demo/tut3: Removed a couple of unused variables. 2012-05-14 14:54:33 +01:00
Ian Abbott
51dbae239b demo/pwm: Removed an unused variable. 2012-05-14 14:53:13 +01:00
Ian Abbott
68e11852cf demo/pwm: Bug fix - should have called comedi_close()
The code called close(device) instead of comedi_close(device) where
device came from comedi_open.
2012-05-14 14:51:06 +01:00
Ian Abbott
77e2628600 demo/choose_clock: Fix a printf.
"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.
2012-05-14 14:45:37 +01:00
Ian Abbott
ac090c7bdf demo/python/mmap.py: Fix buffer wraparound bug.
Fix bug reported by Ross Williamson where the code does not deal with
buffer wraparound within a chunk of data.
2012-05-10 13:49:57 +01:00
Bernd Porr
74a1207a29 Added info that '-n' is used to select the waveform. 2012-05-02 18:40:07 +01:00
Bernd Porr
90ea57b2e9 Created a PWM demo using the newly introduced defines to
manipulate PWM frequency.
2012-05-02 17:58:15 +01:00
Ian Abbott
5fdc15c302 doc: A few whitespace tweaks in program listings 2012-05-01 12:51:08 +01:00
Bernd Porr
df6a97ec6c I've updated the manual in the section configuration and
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.
2012-04-27 01:37:33 +01:00
W. Trevor King
db4fd99309 Suggest people use PYTHONPATH rather than adjusting sys.path internally.
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 ;).
2012-03-13 09:30:45 -04:00
W. Trevor King
55b6a03a50 Add myself to the old Python demo copyrights, since I just tweaked each demo. 2012-03-13 09:24:07 -04:00
W. Trevor King
b415c91aac Oops, fix copyright month on demo/python/insn.py. 2012-03-13 09:22:03 -04:00
W. Trevor King
3d79204427 Cast the period to an integer in demo/python/mmap.py's command setup.
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'
2012-03-13 09:17:08 -04:00
W. Trevor King
8add63faa3 Adjust sys.path before importing mmap in demo/python/mmap.py.
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
2012-03-13 09:12:41 -04:00
W. Trevor King
7a277ab0cb Cast the period to an integer in demo/python/cmd.py's command setup.
This avoids:

  TypeError: in method 'comedi_get_cmd_generic_timed',
    argument 5 of type 'unsigned int'
2012-03-13 08:58:19 -04:00
W. Trevor King
fe3cdd466b Add serial and PWM subdevice types to demo/python/info.py.
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
2012-03-13 08:55:08 -04:00
W. Trevor King
4b56f24232 Add chanlist_len to comedi_get_cmd_generic_timed() calls in Python demos.
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.
2012-03-13 08:41:24 -04:00
W. Trevor King
70eca90662 Add demo/python/insn.py, a Python clone of demo/insn.c. 2012-03-13 08:36:39 -04: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
becded6ae0 Check subdevice type. 2009-08-13 11:16:04 +00:00
Ian Abbott
8a29362cd4 Use negative options.value to set up time as a duty cycle. 2009-08-13 11:09:05 +00:00
Ian Abbott
0038ed1467 Handle COMEDI_SUBD_PWM and check for future unknown subdevice types. 2008-11-05 11:40:42 +00:00
Frank Mori Hess
c13e19648b fixed typo in printf. 2008-09-04 21:24:42 +00:00
Frank Mori Hess
72c2c73a1e Added comment about using gpct_encoder demo with 660x boards. 2008-08-20 00:27:16 +00:00
Frank Mori Hess
d7434f79bb trivial change to a comment. 2008-02-08 18:23:05 +00:00
Frank Mori Hess
f6a4444de8 Switched to use comedi_to_physical instead of deprecated comedi_to_phys. 2008-02-08 16:23:36 +00:00
Frank Mori Hess
9a472f9f4a Added some checking of return values for errors 2008-02-08 16:22:43 +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
Frank Mori Hess
64d656994a Updated to use comedi_set_clock_source() wrapper. 2008-01-17 17:10:07 +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
Ian Abbott
3464515b7d Added blancmange curve. 2007-11-30 18:20:15 +00:00
Ian Abbott
92eb0d52bc Selected waveform with -n. Shifted up sine wave if necessary. Added new
waveforms.  Fixed cycloid. :-)
2007-11-30 16:02:30 +00:00
Ian Abbott
94ad4788d9 Support -c channel and -r range options. 2007-11-22 18:11:22 +00:00
Ian Abbott
605fd55655 Fix use of INSN_GTOD so it works on 64-bit platforms.
A struct timeval is not the same size as a pair of lsampl_t's for 64-bit,
so can't point 'data' in a comedi_insn to a struct timeval and expect it
to work!
2007-11-07 13:01:50 +00:00
Frank Mori Hess
bf4a793f51 Fixed warning on 32 bit arch, caused by my fix for 64 bits. 2007-10-29 01:12:57 +00:00
Frank Mori Hess
464fb550cc Fixed compile warning on amd64 2007-10-26 21:10:05 +00:00
Frank Mori Hess
aa782ffee1 Added blurb about do_waveform. 2007-08-14 13:21:47 +00:00
Frank Mori Hess
70dfd75dfb Added digital output command demo. 2007-08-13 21:21:39 +00:00