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