Hi everyone,
I have a trivial patch for asyn 4-13-1, I thought I'd send it to the
list for comment as well as to Mark directly.
I've been setting up a lot single binary inputs and outputs, so making
masks like this:
field(OUT,"@asynMask( xvme260-1 0 0x4000 )")
and I was thinking it'd be nice to be able to use a 1<<x or a BITx
notation for single bit values. Most of the cards I'm using have a
direct relationship between bit number and channel number, and it's nice
to save the reader from having to do it in their head.
So my tiny patch just adds support for optionally specifying single bit
values, in masks, as follows:
field(OUT,"@asynMask( xvme260-1 0 bit14 )")
The patch adds a mention in the documentation as well, although I
haven't added any test cases.
Hope this is of some use,
- Angus
Index: documentation/asynDriver.html
===================================================================
--- documentation/asynDriver.html (revision 16)
+++ documentation/asynDriver.html (working copy)
@@ -3933,7 +3933,9 @@
interface asynUInt32Digital. The INP or OUT field must define asynMask. The mask
specified in the argument to asynMask is used in the calls to asynUInt32Digital
methods. In addition it is used to set the mask fields in bi and bo records and
- the mask and shft fields in mbbi, mbbo, mbbiDirect, and mbboDirect records.</p>
+ the mask and shft fields in mbbi, mbbo, mbbiDirect, and mbboDirect records. Mask
+ values can be specified as decimal or hexadecimal integers, or a single bit can be
+ identified using the notation 'bitX' (equivalent to the C expression 1<<X.)</p>
<ul>
<li>biRecord
<p>
@@ -3992,7 +3994,7 @@
Binary Output Example Record</p>
<pre>record(bo,"boUInt32Bit2") {
field(DTYP,"asynUInt32Digital")
- field(OUT,"@asynMask( $(port) , 0, 0x4 , 1.0) ")
+ field(OUT,"@asynMask( $(port) , 0, bit2 , 1.0) ")
field(ZNAM,"zero")
field(ONAM,"one")
}</pre>
Index: asyn/devEpics/asynEpicsUtils.c
===================================================================
--- asyn/devEpics/asynEpicsUtils.c (revision 16)
+++ asyn/devEpics/asynEpicsUtils.c (working copy)
@@ -155,7 +155,21 @@
}
return(asynSuccess);
}
-
+
+// Scan a value for a bitmask, which can be either a number suitable for
+// strtoul or a value 'bitX' for X in the range 0-31
+epicsUInt32 scanMaskValue(const char *start, char **end)
+{
+ if(strncmp(start, "bit", 3) == 0) {
+ epicsUInt32 bitValue = strtoul(start+3,end,0);
+ if(bitValue || !errno)
+ return 1<<bitValue;
+ else
+ return 0;
+ }
+ return strtoul(start,end,0);
+}
+
static asynStatus parseLinkMask(asynUser *pasynUser, DBLINK *plink,
char **port, int *addr, epicsUInt32 *mask,char **userParam)
{
@@ -196,7 +210,7 @@
pnext = skipWhite(pnext,1);
if(*pnext==0 || *pnext==')') goto error;
errno = 0;
- *mask = strtoul(pnext,&endp,0);
+ *mask = scanMaskValue(pnext, &endp);
if(errno) goto error;
/*next is timeout*/
pnext = endp;
- Replies:
- Re: Small patch for asynMask bitmask values Angus Gratton
- Re: Small patch for asynMask bitmask values Eric Norum
- Navigate by Date:
- Prev:
Re: Asyn and I/O intr scanning Eric Norum
- Next:
Re: Small patch for asynMask bitmask values Angus Gratton
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
<2010>
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
agenda for the October meeting is updated (you may be scheduled to give a ttalk ; ) ) Dalesio, Leo
- Next:
Re: Small patch for asynMask bitmask values Angus Gratton
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
<2010>
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|