EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024  Index 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: lsi record for more than 40 characters doesn't work
From: "Zimoch Dirk \(PSI\) via Core-talk" <[email protected]>
To: "[email protected]" <[email protected]>
Cc: "[email protected]" <[email protected]>, "[email protected]" <[email protected]>, "[email protected]" <[email protected]>
Date: Tue, 3 Dec 2019 14:07:00 +0000
On Mon, 2019-12-02 at 08:57 -0800, Eric Norum wrote:
> Hmm.  I stand corrected.
> 
> Has StreamDevice done this from the beginning?
> I’m pretty sure that I had a buffer overflow somewhere along the way.  Could have just been my bad code somewhere else, though.

StreamDevice always did this. 40 for stringin and stringout, NELM for waveform, aai, aao and now SIZV for the new lsi
and lso types.

But I think the problem here is something else.

I think that the lsi does indeed get the long string. But Channel Access cannot read transport strings longer than 40
chars. One has to read it as an array of CHARs. This can be done using the "$-trick":

caget -S RF:getString.VAL$

or short:
caget -S RF:getString.$



> 
> Thanks for the clarification.  Perhaps a note about limiting to NELM could be added to the documentation format converter descriptions?
> 
> > On Dec 2, 2019, at 8:41 AM, Zimoch Dirk (PSI) via Tech-talk <[email protected]> wrote:
> > 
> > On Mon, 2019-12-02 at 08:07 -0800, Eric Norum via Core-talk wrote:
> > > Others have dealt with the original question, but I’d like to add a followup.
> > > 
> > > Conversion strings like the one shown in the original message are unsafe and should never be used.  They can lead to buffer overflows and weird IOC behaviour.
> > > 
> > 
> > Have you tested that this leads to buffer overflows? I think I automatically limit the format to the buffer size (here
> > NELM).
> > 
> > Dirk
> > 
> > > The capacity of the destination buffer should always be specified.  Here, from the ASYN streamSCPI template, are the ’short’ and ‘long’ string versions of records to read SCPI identification strings:
> > > 
> > > > record(stringin, "$(P)$(R)IDN")
> > > > {
> > > >    field(DESC, "SCPI identification string")
> > > >    field(DTYP, "stream")
> > > >    field(INP,  "@dev_NAME_.proto getIDN(39) $(PORT) $(A)")
> > > >    field(PINI, "YES")
> > > > }
> > > > record(waveform, "$(P)$(R)IDNwf")
> > > > {
> > > >    field(DESC, "SCPI identification string")
> > > >    field(DTYP, "stream")
> > > >    field(INP,  "@dev_NAME_.proto getIDN(199) $(PORT) $(A)")
> > > >    field(PINI, "YES")
> > > >    field(FTVL, "CHAR")
> > > >    field(NELM, "200")
> > > > }
> > > > 
> > > > 
> > > > getIDN {
> > > >    out "*IDN?";
> > > >    in "%\$1[^\r\n]";
> > > >    ExtraInput = Ignore;
> > > > }
> > > 
> > > 
> > > > On Nov 29, 2019, at 12:11 PM, dmnr infn via Tech-talk <[email protected]> wrote:
> > > > 
> > > > Hi all,
> > > > I have a .db e .proto made in this way:
> > > > 
> > > > .db
> > > > record(lsi, "RF:getString")
> > > > {
> > > >    field(DESC, "String more than 40 chars")
> > > >    field(SIZV, "80")
> > > >    field(INP, "@MDO.proto getString L0")
> > > >    field(SCAN, ".2 second")
> > > > }
> > > > 
> > > > .proto
> > > > getString {
> > > >    out "STT?";
> > > >    in "%s";
> > > > }
> > > > 
> > > > I want to get a String that is more than 40 characters, and I use a lsi record but I got always 40 chars.
> > > > There is something wrong in my code?
> > > > Thank you
> > > > 
> > > 
> > > -- 
> > > Eric Norum
> > > [email protected]
> > > “Ah, the chance to be pedantic first thing on a Monday morning — what a great way to start the week."
> > > 
> 
> 

References:
Re: lsi record for more than 40 characters doesn't work Eric Norum via Core-talk
Re: lsi record for more than 40 characters doesn't work Zimoch Dirk (PSI) via Core-talk
Re: lsi record for more than 40 characters doesn't work Eric Norum via Core-talk

Navigate by Date:
Prev: Re: lsi record for more than 40 characters doesn't work Eric Norum via Core-talk
Next: Re: [Merge] ~anj/epics-base/+git/base-7.0:typed-dsets into epics-base:7.0 Ralph Lange via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: lsi record for more than 40 characters doesn't work Eric Norum via Core-talk
Next: Data Acquisition release of EPICS, parity example Hill, Jeff via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024 
ANJ, 04 Dec 2019 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·