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: "Brown, David L." <[email protected]>
To: Eric Norum <[email protected]>
Cc: EPICS mailing list <[email protected]>
Date: Fri, 7 Nov 2014 17:24:41 +0000
True 56 bytes is expected if I were defining a char or string, but I
thought I was assigning a number of elements in an array in this case and
not the size of the array in bytes.  Code below should read PV1 == TRUE,
sorry.  

Dave

On 11/7/14, 12:15 PM, "Eric Norum" <[email protected]> wrote:

>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]
>
>
>
>



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.
Re: Problems with Dynamic Array population Eric Norum

Navigate by Date:
Prev: Re: Permissible in C to call CA I/O functions from callback? J. Lewis Muir
Next: Polling CA client library in nonpreemptive mode at less than 10 Hz 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 Eric Norum
Next: Re: Problems with Dynamic Array population Benjamin Franksen
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 ·