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  <20082009  2010  2011  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  <20082009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: genSub
From: Andy Foster <[email protected]>
To: "Szalata, Zenon M." <[email protected]>
Cc: EPICS Techtalk <[email protected]>
Date: Wed, 12 Mar 2008 23:13:52 +0000 (GMT)
Hi Zen,

It's not a deliberate design feature but I can see it could happen.

The genSub allocates memory of:
sizeof(char) * Number of elements in A (NOA)

The genSub fetches the data across the link by calling:
"dbGetLink" requesting the number of elements you specified in
NOA. This call places these data into the memory allocated above.

So, if the strings vary in length, and nothing is done to that
memory inbetween the calls to "dbGetLink", I assume the data from
the first call will be overwritten only up to the length of the
second string.

Sounds like doing a memset is a good way to re-initialise the memory
inbetween the calls to "dbGetLink". Whether this should be done as part
of the genSub code itself (for char arrays), rather than in your user
routine, is another question.

Cheers,

Andy



On Wed, 12 Mar 2008, Szalata, Zenon M. wrote:

> In my soft IOC a waveform record reads a string of numeric data from an instrument in ASCII format separated by ','.  This string varies in length from one reading to the next.  I use genSub to convert the ASCII data to floating point data.  I bring the ASCII data into genSub via INPA, for which I set FTA="CHAR".
> I discovered that if a shorter string follows a longer string, in INPA the new string data is followed by the remainder of the previous string!  I fixed that by using memset() function after the string was converted.  Is this a design behavior of genSub? Is there a better way to get rid of leftover data from previous read than I am doing?
>
> My IOC is coded with asyn and streamdevice.  I suppose I should look at how to use stream device to convert the data.  I use genSub not only to convert the data but also to scale the data and correct for an offset, both of these are read from the instrument, prior to reading the waveform data.
> Thanks,
>
> Zen
>

--------------------------------------------------------------------
Observatory Sciences Limited    Email: [email protected]
William James House             Tel: 44 - (0)1223 - 508259
Cowley Road                     Fax: 44 - (0)1223 - 508258
Cambridge, CB4 0WX, UK          http://www.observatorysciences.co.uk


References:
genSub Szalata, Zenon M.

Navigate by Date:
Prev: genSub Szalata, Zenon M.
Next: problems with loading devLibOpt Yuriy Gorbunov
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  <20082009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: genSub Matthieu Bec
Next: problems with loading devLibOpt Yuriy Gorbunov
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  <20082009  2010  2011  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 ·