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: problem passing string to aSub record parameter
From: "Jim Chen" <[email protected]>
To: "'Andrew Johnson'" <[email protected]>, <[email protected]>
Date: Fri, 28 Sep 2012 17:05:41 +0100
Right, I think I can nick the ONAM field to pass the string for the time being although this doesn't sound right. I don't use this field at any time though (hope it wouldn't upset the record itself as well?).

Just a thought, will it be possible to define a key similar to 'PP' to indicate that the string is a real string constant?

Jim

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Jim Chen
Sent: 28 September 2012 16:27
To: 'Andrew Johnson'; [email protected]
Subject: RE: problem passing string to aSub record parameter

Thanks Andrew and Mathias,

The problem is that I need to retrieve this string in the aSub Init routine, as it states here: field(INAM,"myfunctionInit"). At that point, the stringout record might not be processed yet. I suppose the PP key is to force the other record to be processed afterwards. Even when I set the stringout record PINI=1, and place it before my aSub record. This comes to another question, what is the order when the database records are read and initialised?

Jim

-----Original Message-----
From: Andrew Johnson [mailto:[email protected]]
Sent: 28 September 2012 16:15
To: [email protected]
Cc: Jim Chen
Subject: Re: problem passing string to aSub record parameter

Hi Jim,

On 2012-09-28 Jim Chen wrote:
> Can anybody help please -- passing STRING to aSub record parameter 
> field  doesn’t seem to work.
> 
> My aSub record
> 
> record(aSub,"TRANSMIT")
> {
>     field(INAM,"myfunctionInit")
>     ……
>     field(INPA,"Test string")
>     field(FTA,"STRING")
>     field(NOA,"20")
>     ……
> }
> 
> myfunctionInit(aSubRecord * pSub)
> {
> ……
>     char test[40];
>     strcpy(test, (char *)subr->a);
> 
>     printf("Text: %s\n", test);
>     ……
> }
> 
> The printf statement doesn’ t print anything. When I check the length 
> of the ‘test’ variable, it is always 0.

The problems here are mostly in the record definition rather than in your code.

First, these two settings
    field(FTA,"STRING")
    field(NOA,"20")
configure the record to be an array of 20 DBF_STRINGs.  Effectively they cause the record initialization code to do this:
    prec->a = calloc(20, MAX_STRING_SIZE);

I'm guessing that you probably only meant to request storage for a single string, so change the NOA setting to 1.

Second, this setting
    field(INPA,"Test string")
configures INPA to be a link to some PV called "Test"; in the likely event that there is no record with this name it will result in a request to Channel Access for a .  EPICS does not allow you to initialize a string field through an INP or DOL link using a constant string, because the IOC has no way to know that the string isn't a PV name.  The only reason this works for numbers is because the IOC checks whether the initialization string is accepted without error by either strtod() or strtol().

The simplest way to do this is to create a separate stringin (or stringout) record and initialize its VAL field to the constant string you want.  Then point the INPA link of your record to that new record (Mathias Steiner just posted that solution).

- Andrew
--
Never interrupt your enemy when he is making a mistake.
-- Napoleon Bonaparte







References:
problem passing string to aSub record parameter Jim Chen
Re: problem passing string to aSub record parameter Andrew Johnson
RE: problem passing string to aSub record parameter Jim Chen

Navigate by Date:
Prev: Re: Loading modbus waveform record from acalcout record (or caput) Tim Mooney
Next: Re: problem passing string to aSub record parameter 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: problem passing string to aSub record parameter Jim Chen
Next: Re: problem passing string to aSub record parameter 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 
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 ·