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

Subject: Re: Reading an array of strings from a Waveform record
From: Andrew Johnson <[email protected]>
To: [email protected]
Cc: Simon Hoyle <[email protected]>
Date: Fri, 11 Dec 2009 10:08:23 -0600
Hi Simon,

On Thursday 10 December 2009 22:22:26 Simon Hoyle wrote:
>
> I'm attempting to use an asub  to read an array of
> strings from a waveform record with Epics 3.14.11

...

>   void loadETA(aSubRecord * asub)
>   {
>     int etaLen = *(short*)(asub->b);
>     char** etaIn = (char**)(asub->c);
>
>     for (int i = 0; i < etaLen; ++i)
>         printf("\t%s\n", *(etaIn++));
>   }

What's wrong is that with FTC=STRING asub->c is not a char**, it's actually a 
pointer to a char[MAX_STRING_SIZE][asub->noc] i.e. a single flat buffer of 
size NOC*MAX_STRING_SIZE.  The IOC code is very careful to avoid allocating 
and freeing memory buffers during record processing, which is why all our 
string fields are fixed length.

There is a typedef named epicsOldString which is useful in this case; if you 
change your subroutine code to this you'll have more success:

long loadETA(aSubRecord * asub)
{
    int etaLen = *(short*)(asub->b);
    epicsOldString *etaIn = (epicsOldString *)asub->c;
    int i;

    for (i = 0; i < etaLen; ++i)
        printf("\t%s\n", etaIn[i]);

    return 0;
}


tux% caput -a wf "*ignored*" Alas poor Yorik, I knew him Horatio.
Old : wf 10
New : wf 10 Alas poor Yorik, I knew him Horatio.

epics>  Alas
        poor
        Yorik,
        I
        knew
        him
        Horatio.

HTH,

- Andrew
-- 
The best FOSS code is written to be read by other humans -- Harald Welte


References:
Reading an array of strings from a Waveform record Simon Hoyle

Navigate by Date:
Prev: Re: EDM GUI disable/enable Ralph Lange
Next: Planned changes to ASYN drvAsynIPPort Eric Norum
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  <20092010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Reading an array of strings from a Waveform record Simon Hoyle
Next: EDM GUI disable/enable Steve Kinder
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  <20092010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 31 Jan 2014 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·