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  2012  2013  <20142015  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  2012  2013  <20142015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Problems with Dynamic Array population
From: Eric Norum <[email protected]>
To: "Brown, David L." <[email protected]>
Cc: EPICS mailing list <[email protected]>
Date: Fri, 7 Nov 2014 09:15:42 -0800
double foo[7];
size_t s = sizeof foo;

An almost any machine architecture now in use it is expected that s would be 56 — 7 elements, 8 bytes each.

Also — is the code below an accurate copy?  The if statement contains an assignment, not a conditional.


> On Nov 7, 2014, at 9:02 AM, Brown, David L. <[email protected]> wrote:
> 
> Hi, all,
> 
> I got around the problem.  I don’t know why this is, but when one defines
> an array size of 7 elements (like as seen below), assigns them to an array
> of three elements outside the state machine, and then reassigns the
> elements inside the state machine, there is no core dump.  I also looked
> at the size of the array MPS and it said that my array was a size of 56 as
> opposed to the 7 elements I defined.  I have convinced myself that this
> was a memory allocation problem as the array size (as interpreted by the
> state machine) was different than what I expected it to be.  Perhaps I
> have a fundamental misunderstanding of how to initially assign variables
> in C?  Thank you all for your help and tips.  Here is the working code I
> referenced above (still needs testing, but core dumps don’t happen):
> 
> char fcoutpreamble[40];
> char fcokpreamble[40];
> 
> char blah[40];
> int i;
> double MPS[7];
> assign
> {
> 	“PV1”,
> 	“PV2”,
> 	“PV3”
> }
> 
> Monitor MPS;
> 
> SS Machine
> {
> 	state Start
> 	{
> 		when()
> 		{
> 			if( PV1 = TRUE)
> 			{
> 				/* set arguments here*/
> 				i = sprintf(blah, “%s_input\n”,fcoutpreamble);
> 				assert( i <= sizeof(blah));
> 				pvAssign (MPS[2],blah);
> 				i = sprintf(blah, “%s_raw\n”,fcoutpreamble);
> 				assert( i <= sizeof(blah));
> 				pvAssign (MPS[3],blah);
> 				i = sprintf(blah, “%s_input\n”,fcokpreamble);
> 				assert( i <= sizeof(blah));
> 				pvAssign (MPS[4],blah);
> 				i = sprintf(blah, “%s_raw\n”,fcokpreamble);
> 				assert( i <= sizeof(blah));
> 				pvAssign (MPS[5],blah);
> 				i = sprintf(blah, “PV3”);
> 				assert( i <= sizeof(blah));
> 				pvAssign (MPS[6],blah);
> 			}
> 
> 			else
> 			{
> 				/* set arguments here*/
> 			}
> 		}state Idle
> 	}
> }
> 
> Dave				
> 

-- 
Eric Norum
[email protected]






Replies:
Re: Problems with Dynamic Array population Brown, David L.
References:
Problems with Dynamic Array population Brown, David L.
Re: Problems with Dynamic Array population Benjamin Franksen
Re: Problems with Dynamic Array population Brown, David L.

Navigate by Date:
Prev: Re: Problems with Dynamic Array population Brown, David L.
Next: Re: Permissible in C to call CA I/O functions from callback? J. Lewis Muir
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Problems with Dynamic Array population Brown, David L.
Next: Re: Problems with Dynamic Array population Brown, David L.
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 17 Dec 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·