Experimental Physics and Industrial Control System
|
Thanks again for the help. I have found another issue, though, and I sincerely apologize if it is yet another fundamental C error. Can anybody shed any light on why Program 1 shown below does work while Program 2 does not even successfully compile? I have highlighted the only differences between the two programs with "***************".
Program 1:
/* Sample Program */ program sncExample
option +r; /* reentrant */
float i; ***********
float pv; assign pv to "testioc:magnet{mag}";
%{
void helloWorld(SS_ID ssId, struct UserVar *pVar) {
pVar->i = 1; **************** printf("Hello World! You have just called a C function, and the variable i is %5.1f \n", pVar->i); }
}%
ss ss1 {
state one {
when() { %% helloWorld(ssId, pVar); pv = 1; pvPut(pv); sleep(1); } state two }
state two { when () { %% helloWorld(ssId, pVar);
pv = 2; pvPut(pv); sleep(1); } state one }
}
Program 2:
/* Sample Program */ program sncExample
option +r; /* reentrant */
float i = 1; ****************
float pv; assign pv to "testioc:magnet{mag}";
%{
void helloWorld(SS_ID ssId, struct UserVar *pVar) { printf("Hello World! You have just called a C function, and the variable i is %5.1f \n", pVar->i);
}
}%
ss ss1 {
state one { when() { %% helloWorld(ssId, pVar); pv = 1; pvPut(pv); sleep(1); } state two }
state two {
when () { %% helloWorld(ssId, pVar); pv = 2; pvPut(pv); sleep(1); } state one }
}
The error message displayed upon compiling program 2 is :
./../sncExample.stt: In function ‘helloWorld’: ./../sncExample.stt:15: error: ‘struct UserVar’ has no member named ‘i’ ./../sncExample.stt: In function ‘A_ss1_one’: ./../sncExample.stt:24: error: ‘struct UserVar’ has no member named ‘pv’
./../sncExample.stt:26: warning: implicit declaration of function ‘sleep’ ./../sncExample.stt: In function ‘A_ss1_two’: ./../sncExample.stt:33: error: ‘struct UserVar’ has no member named ‘pv’ ./../sncExample.stt: At top level:
./../sncExample.stt:50: error: ‘struct UserVar’ has no member named ‘pv’
Thanks everybody!
Brad Pietrzak
On Mon, Sep 26, 2011 at 6:02 PM, J. Lewis Muir <[email protected]> wrote:
On 9/26/11 4:39 PM, Bradley Pietrzak wrote:
> Thank you again for your responses. Unfortunately, I have encountered
> another problem, this time involving code that has been escaped to C. The
> new version of my program is shown below. Without the re-entrant option,
> the code runs perfectly fine. With the re-entrant option, however, I am met
> with several errors. The SNL user's manual says that the SNC automatically
> refers to variables in the struct UserVar by running the code " pVar->xxx",
> but that such references have to be handled manually for escaped C code. How
> do I handle such situations manually?
Hi, Brad.
In your example, you would need to do:
%% helloWorld(pVar->i);
Or, if you are wanting to do more things within your helloWorld
function, you could call it like this:
%% helloWorld(ssId, pVar);
with the function changed to:
void helloWorld(SS_ID ssId, struct UserVar *pVar) {
printf("Hello World! You have just called a C function, "
"and the variable i is %5.1f \n", pVar->i);
}
Lewis
- Replies:
- Re: Combing Two State Sets into One Eric Norum
- References:
- Re: Combing Two State Sets into One Bradley Pietrzak
- Re: Combing Two State Sets into One Ned Arnold
- Re: Combing Two State Sets into One Bradley Pietrzak
- Re: Combing Two State Sets into One J. Lewis Muir
- Navigate by Date:
- Prev:
Re: Transform Record no_inlink test Tim Mooney
- Next:
Re: Combing Two State Sets into One Eric Norum
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
<2011>
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
Re: Combing Two State Sets into One J. Lewis Muir
- Next:
Re: Combing Two State Sets into One Eric Norum
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
<2011>
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|
ANJ, 18 Nov 2013 |
·
Home
·
News
·
About
·
Base
·
Modules
·
Extensions
·
Distributions
·
Download
·
·
Search
·
EPICS V4
·
IRMIS
·
Talk
·
Bugs
·
Documents
·
Links
·
Licensing
·
|