Add comedi_set_read_subdevice() and comedi_set_write_subdevice()
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.
This commit is contained in:
parent
6458b08e56
commit
66070c6af6
4 changed files with 72 additions and 2 deletions
|
@ -204,7 +204,7 @@ Param: comedi_t * device
|
|||
Description:
|
||||
The function <function>comedi_get_read_subdevice</function> returns the
|
||||
index of the subdevice
|
||||
whose streaming input buffer is accessible through the
|
||||
whose streaming input buffer is currently accessible through the
|
||||
device <parameter class="function">device</parameter>. If
|
||||
there is no such subdevice, <literal>-1</literal> is returned.
|
||||
|
||||
|
@ -214,7 +214,7 @@ Param: comedi_t * device
|
|||
Description:
|
||||
The function <function>comedi_get_write_subdevice</function> returns the
|
||||
index of the subdevice
|
||||
whose streaming output buffer is accessible through the
|
||||
whose streaming output buffer is currently accessible through the
|
||||
device <parameter class="device">device</parameter>. If there is no such subdevice,
|
||||
<literal>-1</literal> is returned.
|
||||
|
||||
|
@ -322,3 +322,35 @@ Description:
|
|||
size requires the user to have appropriate privileges.
|
||||
Returns:
|
||||
The new maximum buffer size is returned on success. On error, <literal>-1</literal> is returned.
|
||||
|
||||
Function: comedi_set_read_subdevice -- set streaming input subdevice
|
||||
Retval: int
|
||||
Param: comedi_t * device
|
||||
Param: unsigned int subdevice
|
||||
Status: Works for Linux "in-tree" Comedi since kernel version 3.19.
|
||||
Description:
|
||||
The function <function>comedi_set_read_subdevice</function> sets
|
||||
<parameter class="function">subdevice</parameter> as the current streaming
|
||||
input subdevice if the subdevice supports streaming input commands.
|
||||
|
||||
Changes are local to the <em>open file description</em> for this
|
||||
<parameter class="function">device</parameter> and have no effect on other
|
||||
open file descriptions for the underlying device node.
|
||||
Returns:
|
||||
<literal>0</literal> on success, <literal>-1</literal> on error.
|
||||
|
||||
Function: comedi_set_write_subdevice -- set streaming output subdevice
|
||||
Retval: int
|
||||
Param: comedi_t * device
|
||||
Param: unsigned int subdevice
|
||||
Status: Works for Linux "in-tree" Comedi since kernel version 3.19.
|
||||
Description:
|
||||
The function <function>comedi_set_write_subdevice</function> sets
|
||||
<parameter class="function">subdevice</parameter> as the current streaming
|
||||
output subdevice if the subdevice supports streaming output commands.
|
||||
|
||||
Changes are local to the <em>open file description</em> for this
|
||||
<parameter class="function">device</parameter> and have no effect on other
|
||||
open file descriptions for the underlying device node.
|
||||
Returns:
|
||||
<literal>0</literal> on success, <literal>-1</literal> on error.
|
||||
|
|
|
@ -131,6 +131,16 @@ int comedi_do_insnlist(comedi_t *it,comedi_insnlist *il);
|
|||
int comedi_do_insn(comedi_t *it,comedi_insn *insn);
|
||||
int comedi_lock(comedi_t *it,unsigned int subdevice);
|
||||
int comedi_unlock(comedi_t *it,unsigned int subdevice);
|
||||
/*
|
||||
* Changing read and write subdevice is supported for the version of comedi
|
||||
* in the Linux kernel sources since Linux kernel version 3.19.
|
||||
*
|
||||
* The functions to set and get the read and write subdevice are unusual in
|
||||
* that changes are local to the "open file description" for the Comedi
|
||||
* device.
|
||||
*/
|
||||
int comedi_set_read_subdevice(comedi_t *it,unsigned int subdevice);
|
||||
int comedi_set_write_subdevice(comedi_t *it,unsigned int subdevice);
|
||||
|
||||
/* physical units */
|
||||
double comedi_to_phys(lsampl_t data,comedi_range *rng,lsampl_t maxdata);
|
||||
|
|
26
lib/comedi.c
26
lib/comedi.c
|
@ -231,3 +231,29 @@ int _comedi_unlock(comedi_t *it,unsigned int subdevice)
|
|||
return comedi_ioctl(it->fd, COMEDI_UNLOCK, (void*)(unsigned long)subdevice);
|
||||
}
|
||||
|
||||
EXPORT_ALIAS_DEFAULT(_comedi_set_read_subdevice,comedi_set_read_subdevice,0.11.0);
|
||||
int _comedi_set_read_subdevice(comedi_t *it,unsigned int subdevice)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if(!valid_dev(it)) return -1;
|
||||
ret = comedi_ioctl(it->fd, COMEDI_SETRSUBD, (void*)(unsigned long)subdevice);
|
||||
if(ret == 0){
|
||||
it->devinfo.read_subdevice = subdevice;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
EXPORT_ALIAS_DEFAULT(_comedi_set_write_subdevice,comedi_set_write_subdevice,0.11.0);
|
||||
int _comedi_set_write_subdevice(comedi_t *it,unsigned int subdevice)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if(!valid_dev(it)) return -1;
|
||||
ret = comedi_ioctl(it->fd, COMEDI_SETWSUBD, (void*)(unsigned long)subdevice);
|
||||
if(ret == 0){
|
||||
it->devinfo.write_subdevice = subdevice;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -126,4 +126,6 @@ v0.11.0 {
|
|||
comedi_digital_trigger_disable;
|
||||
comedi_digital_trigger_enable_edges;
|
||||
comedi_digital_trigger_enable_levels;
|
||||
comedi_set_read_subdevice;
|
||||
comedi_set_write_subdevice;
|
||||
} v0.10.0;
|
||||
|
|
Loading…
Add table
Reference in a new issue