EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Small patch for asynMask bitmask values
From: Angus Gratton <[email protected]>
To: tech-talk <[email protected]>
Date: Fri, 20 Aug 2010 11:45:57 +1000
On Fri, 2010-08-20 at 11:31 +1000, Angus Gratton wrote:
> 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.

Blech, sorry. Updated version of the patch, removed some unnecessary bad
errno fiddling.

- 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,17 @@
     }
     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) {
+	     return strtoul(start+3,end,0);
+    }
+    return strtoul(start,end,0);
+}
+
 static asynStatus parseLinkMask(asynUser *pasynUser, DBLINK *plink, 
                    char **port, int *addr, epicsUInt32 *mask,char **userParam)
 {
@@ -196,7 +206,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;

References:
Small patch for asynMask bitmask values Angus Gratton

Navigate by Date:
Prev: Small patch for asynMask bitmask values Angus Gratton
Next: Re: Small patch for asynMask bitmask values Eric Norum
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Small patch for asynMask bitmask values Angus Gratton
Next: Re: Small patch for asynMask bitmask values Eric Norum
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 02 Sep 2010 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·