EPICS Home

Experimental Physics and Industrial Control System


 
1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  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  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Long string support in CA clients and device support
From: Eric Norum <[email protected]>
To: Andrew Johnson <[email protected]>
Cc: Tech-talk <[email protected]>
Date: Tue, 13 Nov 2012 16:22:31 -0800
On Nov 13, 2012, at 3:48 PM, Andrew Johnson <[email protected]> wrote:

>> ……….
> 
> A generic client MUST properly handle an un-terminated string.
> 
> However someone writing a 1-off aSub subroutine for a 24-hour experiment to 
> run tomorrow who knows that their long string input value includes the Nil can 
> skip the additional step of terminating it and pass it straight to sprintf().

Right.
And with your proposed change just how is this author expected to know what kind of string to expect?

I think that it's a lot easier to say, "If you want to treat a long string waveform record as a C string you have to take care of adding the terminator yourself", rather than saying, "Well, if your long string waveform record INP source is an asyn portDriver parameter string then you can be assured the NORD includes the terminator, but if the source INP is an asyn IP port or TTY port or something else like that then NORD doesn't include the terminator".

> 
> I'm trying to make it so that someone who knows nothing about this whole topic 
> and assumes that long strings follow the C standard can write a subroutine 
> that Just Works™ more often than it doesn't.  Robust APIs are better than 
> brittle ones, and counting the Nil increases robustness.

The asynOctet drivers of which I'm aware set VAL[NORD] = '\0' if NORD < NELM to try and help out sloppy programmers.

But this won't help the sloppy programmer that you're hypothesizing since the copy of data from the waveform record to the aSub buffer will copy only NORD bytes.  (which of course is your point -- but too late now to fix, I think).

> 
> This doesn't change the semantics of NORD at all which still tells you how 
> many elements there are in the array.  I'm merely advocating that where the 
> data being put in the buffer is a Nil-terminated string, that the Nil byte 
> should be regarded as part of the string (following the C standard) and 
> included in the element count.

I disagree.
Consider Mark's example of a *IDN? reply.
NORD in this case does not include the terminator.    I think that it's way too late in the game to start requiring long string waveform records to change their semantics to include a nil in the NORD count.  


-- 
Eric Norum
[email protected]



References:
Long string support in CA clients and device support Andrew Johnson
Re: Long string support in CA clients and device support Andrew Johnson
Re: Long string support in CA clients and device support Eric Norum
Re: Long string support in CA clients and device support Andrew Johnson

Navigate by Date:
Prev: RE: Long string support in CA clients and device support Mark Rivers
Next: Re: Long string support in CA clients and device support Andrew Johnson
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Long string support in CA clients and device support Andrew Johnson
Next: RE: Long string support in CA clients and device support Mark Rivers
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024