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  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: Andrew Johnson <[email protected]>
To: Eric Norum <[email protected]>
Cc: Tech-talk <[email protected]>
Date: Tue, 13 Nov 2012 18:48:10 -0500
Hi Eric,

On 2012-11-13 Eric Norum wrote:
> So how does the author of a client (aSub subroutine or anything else)
> determine the meaning of NORD with the proposed change in place? How does
> the author determine whether the the source of a an array of characters is
> something that appends a nil or something like a serial/network port that
> does not?   

Here's what my original statement said:

> I recommend (but we don't require) that anything generating a long string
> should add a Nil ('\0') terminator byte after the last character and count
> that in the number of elements reported for the array (e.g. when setting the
> waveform record's NORD field).
>
> However clients that read an array as a long string MUST be able to properly
> handle one that doesn't have a Nil terminator, and should not report an
> error in this case.  The simplest way to ensure proper termination is to
> check if the byte at [len-1] is zero and if not append one (making sure you
> reserved space in your buffer for it).  Maybe the source might even change
> at run time. 

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().

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.

> Mucking with the semantics of NORD is a BadIdea (™, IMHO).

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.

- Andrew
-- 
READ CAREFULLY. By reading this email, you agree, on behalf of your
employer, to release me from all obligations and waivers arising from
any and all NON-NEGOTIATED agreements, licenses, terms-of-service,
shrink-wrap, click-wrap, browse-wrap, confidentiality, non-disclosure,
non-compete and acceptable use policies ("BOGUS AGREEMENTS") that I
have entered into with your employer, its partners, licensors, agents
and assigns, in perpetuity, without prejudice to my ongoing rights
and privileges. You further represent that you have the authority to
release me from any BOGUS AGREEMENTS on behalf of your employer.


Replies:
Re: Long string support in CA clients and device support Eric Norum
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

Navigate by Date:
Prev: Re: Long string support in CA clients and device support Eric Norum
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 
Navigate by Thread:
Prev: Re: Long string support in CA clients and device support Eric Norum
Next: Re: Long string support in CA clients and device support Eric Norum
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 
ANJ, 18 Nov 2013 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·