Commit graph

21 commits

Author SHA1 Message Date
Ian Abbott
fa9c5d14c9 demo/mmap: limit options.n_chan to 256
Set new macro N_CHANS to 256 - the length of the chanlist[] array.

If the '-n' option sets options.n_chan higher than N_CHANS, reduce it to
avoid overrunning the chanlist[] array.
2016-11-08 14:57:16 +00:00
Ian Abbott
facb713cd8 demo/mmap: check subdevice exists and supports 'read' commands
Check the subdevice actually exists and that it claims to support 'read'
commands (SDF_CMD_READ subdevice flag set), bailing out early if not.
2016-11-08 14:29:58 +00:00
Ian Abbott
ad70295bb4 demo/mmap: use comedi_get_cmd_generic_timed()
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.
2016-11-08 14:25:43 +00:00
Ian Abbott
1e8ca17ba9 demo/mmap: default to 'read' subdevice instead of subdevice 0
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.
2016-11-08 14:20:49 +00:00
Ian Abbott
80d809282c demo: update demo programs to set read or write subdevice
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.
2016-05-13 17:19:10 +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
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
fbdf65b4f5 Made parse_options() write options to a struct instead of passing
them through global variables.
2007-01-03 21:14:53 +00:00
Frank Mori Hess
9d4aa91837 include string.h for memset() 2003-01-01 23:08:07 +00:00
Frank Mori Hess
ea64ba8daa fixing includes for exit(), memset() for gcc 2.96 compiler warnings 2003-01-01 23:07:02 +00:00
Frank Mori Hess
28cbcb99d8 added error check for mmap() call 2002-11-26 20:06:22 +00:00
Frank Mori Hess
8ab0f19e34 changed & to %, before it seemed to assume the buffer size was a power of
2
2002-11-20 00:43:19 +00:00
David Schleef
cd6660ec58 Fix mistake getting buffer head position 2002-08-06 19:39:31 +00:00
Frank Mori Hess
2a637ef62c replaced call to comedi_get_front_count() with call to identical comedi_get_buffer_offset()
since that is the function that is actually declared in comedilib.h
2002-04-16 20:51:56 +00:00
David Schleef
7973a0f2ad Change prototype of comedi_get_cmd_generic_timed 2001-07-15 22:39:54 +00:00
David Schleef
98ead7a4f9 Major hacking, just like cmd.c 2001-07-15 19:57:32 +00:00
David Schleef
31b3e7ed7f Changed the name of verbose_flag; Added a few more flags in main.c 2001-07-14 00:50:52 +00:00
Frank Mori Hess
7263bf6d2c explicitly initialized value, subdevice, channel, aref and range in main.c 2001-05-14 00:04:08 +00:00
David Schleef
01a017f515 5 new demos
cmd uses main.c
removal of direct ioctl calls
2001-03-01 21:57:00 +00:00
David Schleef
49bfad27af removed testing code 2000-11-30 22:59:39 +00:00
David Schleef
7cde371fd4 mmap demo and testing 2000-11-25 04:19:59 +00:00