EPICS Home

Experimental Physics and Industrial Control System


 
1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Sequencer embedded C code question
From: "Jiro Fujita" <[email protected]>
To: [email protected], [email protected]
Date: Thu, 29 Jun 2006 20:25:52 -0400
Thank you very much for the code!
At first, I thought this might be something that I should make our
code to look like, then after a very careful observation, I realized
that this is the entire code to do what we wanted to do.
So, I compiled it, and it compiles without any issues what so ever.  I
told that to my students, and they are as amazed as I am.
We wanted to see how this actually work, so we all took an extra trip
back to the DAQ Room where the device is located at, and tried it out
for real.  It works as expected, and we could not be happier.  In
particular, the student who has been trying to write this code is
extremely happy that you took your time to write this code for us.  I
am sure that my boss will be very happy tomorrow when we tell him
that.
We have been rather frustrated with SNL in the last couple of days, as
there has not been very many documentations available on the topic for
us (outside of the SLAC pages and some examples elsewhere).  I know
what we are trying to do is very basic things and we lack in
programming skill in general.
However, having your code is a good asset for us.  My students and I
am  planning to spend some time carefully studying your code tomorrow
so that we will be able to generate  as good code as yours in the
future.
Thank you very much, again!

On 6/29/06, Pete Jemian <[email protected]> wrote:

Hrmph ... let me try again.


program snchygrometer

%%#include <ctype.h>
%%#include <stdlib.h>
%%#include <stdio.h>

 string roba;
 assign roba to "rawdata" ;
 monitor roba;
 evflag roba_mon;
 sync   roba roba_mon;

 float channel[5] ;
 assign channel[0] to "PV1";
 assign channel[1] to "PV2";
 assign channel[2] to "PV3";
 assign channel[3] to "PV4";
 assign channel[4] to "PV5";

 int chanNum;
 float value;

ss string_handler {
  state init {
    when () {
      efClear(roba_mon);
    } state convert_my_string
  }

  state convert_my_string {
    when (efTest(roba_mon)) {
      /* roba is the string received from the device:  "1+32.23" or
"2-50.01" */
      sscanf(roba, "%1d%f", &chanNum, &value);
      if ( (1 <= chanNum) && (chanNum <= 5) ) {
        channel[chanNum-1] = value;
        pvPut(channel[chanNum-1]);
      }
      efClear(roba_mon);
    } state convert_my_string
  }
}


Pete Jemian wrote: > > Something is not right with the fragment you sent. > You start an escaped C block with "%{" but that block is never closed. > So, the SNL compiler passes the rest of the code to the C compiler > which does not have a definition for roba. > > Try something like this: > > ss string_handler { > state stateN { > when () { > /* rob_pj is the string received from the device: "1+32.23" or > "2-50.01" */ > sscanf(rob_pj, "%d%f", &chanNum, &value); > if ( (1 <= chanNum) && (chanNum <= 5) ) { > channel[chanNum-1] = value; > pvPut(channel[chanNum-1]); > } > } state stateN > } > } > > > Pete > > Jiro Fujita wrote: >> Eric, >> Here is what the code looks like right now: >> >> program snchygrometer >> >> %%#include <ctype.h> >> %%#include <stdlib.h> >> %%#include <stdio.h> >> >> %%char rob[10] ; >> char *roba; >> assign roba to "rawdata" ; >> monitor roba ; >> float ch1 ; >> float ch2 ; >> float ch3 ; >> float ch4 ; >> float ch5 ; >> assign ch1 to "PV1"; >> assign ch2 to "PV2"; >> assign ch3 to "PV3"; >> assign ch4 to "PV4"; >> assign ch5 to "PV5"; >> >> %%int v ; >> %%int z ; >> %%extern char *wa1 ; >> %%char *sign="+-" ; >> >> %{ >> when() >> { >> rob=&roba; /*i dont know how to do this & wont work w/ roba as just >> rob*/ >> v=rob[0]; /*Get first char from string*/ >> wa1=strpbrk(rob, "+-"); /*Break string at +-,rest is wa1*/ >> z=(float)wa1; /*convert string to float z*/ >> >> ss ss1 { >> state state1 { >> when ( v==1) { >> ch1 = z; pvPut(ch1); >> } state state2 >> } >> state state2 { >> when ( v==2) { >> ch2 = z; pvPut(ch2); >> } state state3 >> } >> state state3 { >> when ( v==3) { >> ch3 = z; pvPut(ch3); >> } state state4 >> } >> state state4 { >> when ( v==4) { >> ch4 = z; pvPut(ch4); >> } state state5 >> } >> state state5 { >> when ( v==5) { >> ch5 = z; pvPut(ch5); >> } state state1 >> } >> } >> >> >> (This is the entire code). >> and here is the error we are getting: >> >> make[3]: Entering directory >> `/home/sysuser/epics3.14.8.2/hygrometerApp/hygrometerApp/src/O.linux-x86' >> >> /usr/bin/gcc -c -D_POSIX_C_SOURCE=199506L -D_POSIX_THREADS >> -D_XOPEN_SOURCE=500 -D_X86_ -DUNIX -D_BSD_SOURCE -Dlinux >> -D_REENTRANT -ansi -O3 -Wall -g -I. -I.. >> -I../../../include/os/Linux -I../../../include >> -I/home/sysuser/epics3.14.8.2/base-3.14.8.2/../modules/soft/seq-2.0.11/include/os/Linux >> >> -I/home/sysuser/epics3.14.8.2/base-3.14.8.2/../modules/soft/seq-2.0.11/include >> >> -I/home/sysuser/epics3.14.8.2/base-3.14.8.2/include/os/Linux >> -I/home/sysuser/epics3.14.8.2/base-3.14.8.2/include >> -I/home/sysuser/epics3.14.8.2/modules/soft/asyn/4-6/include/os/Linux >> -I/home/sysuser/epics3.14.8.2/modules/soft/asyn/4-6/include >> sncProgram.c >> ../sncExample.stt:35: warning: return type defaults to `int' >> ../sncExample.stt: In function `when': >> ../sncExample.stt:36: `roba' undeclared (first use in this function) >> ../sncExample.stt:36: (Each undeclared identifier is reported only once >> ../sncExample.stt:36: for each function it appears in.) >> ../sncExample.stt:39: pointer value used where a floating point value >> was expected >> make[3]: *** [sncProgram.o] Error 1 >> make[3]: Leaving directory >> `/home/sysuser/epics3.14.8.2/hygrometerApp/hygrometerApp/src/O.linux-x86' >> >> make[2]: *** [install.linux-x86] Error 2 >> make[2]: Leaving directory >> `/home/sysuser/epics3.14.8.2/hygrometerApp/hygrometerApp/src' >> make[1]: *** [src.install] Error 2 >> make[1]: Leaving directory >> `/home/sysuser/epics3.14.8.2/hygrometerApp/hygrometerApp' >> make: *** [hygrometerApp.install] Error 2 >> >> What we are wondering is, why does it think rob is defaulting to int, >> when we are setting it as char?? Obviously, there is something wrong >> with array vs pointer (this is what I have been telling to my >> students), but this seems to compile without any issues outside of >> EPICS (well, the original ones we started out did, anyway). >> >> On 6/29/06, Eric Norum <[email protected]> wrote: >>> >>> I'm not sure what you have changed, but the code you posted >>> originally seems >>> to be mixing up the notion of "array of characters" and "pointer to >>> character". See my comment below: >>> >>> program snchygrometer >>> >>> %%#include <ctype.h> >>> %%#include <stdlib.h> >>> %%#include <stdio.h> >>> >>> %%char rob[10] ; >>> char *roba; >>> assign roba to "rawdata" ; >>> monitor roba ; >>> float ch1 ; >>> float ch2 ; >>> float ch3 ; >>> float ch4 ; >>> float ch5 ; >>> assign ch1 to "PV1"; >>> assign ch2 to "PV2"; >>> assign ch3 to "PV3"; >>> assign ch4 to "PV4"; >>> assign ch5 to "PV5"; >>> >>> int v ; >>> float z ; >>> %%extern char *wa1 ; >>> %%char *sign="+-" ; >>> >>> %{ >>> rob=&roba <<<<<<<<<<<<< EVEN WITH A SEMICOLON AT >>> THE END >>> THIS LINE MAKES NO SENSE. >>> v=rob[0]; /*Get first char from string*/ >>> wa1=strpbrk(rob, "+-"); /*Break string at +-,rest is wa1*/ >>> z=(float)wa1; /*convert string to float z*/ >>> }% >>> >>> >>> >>> Perhaps you could mail me your latest code?? >>> >>> >>> -- >>> Eric Norum <[email protected]> >>> Advanced Photon Source >>> Argonne National Laboratory >>> (630) 252-4793 >>> >>> >

--

----------------------------------------------------------
  Pete R. Jemian, Ph.D.                <[email protected]>
  Beam line Controls and Data Acquisition, Group Leader
  Advanced Photon Source,   Argonne National Laboratory
  Argonne, IL  60439                   630 - 252 - 3189
-----------------------------------------------------------
      Education is the one thing for which people
         are willing to pay yet not receive.
-----------------------------------------------------------




References:
Re: Sequencer embedded C code question Jiro Fujita
RE: Sequencer embedded C code question Laznovsky, Michael
Re: Sequencer embedded C code question Jiro Fujita
Re: Sequencer embedded C code question Eric Norum
Re: Sequencer embedded C code question Jiro Fujita
Re: Sequencer embedded C code question Pete Jemian
Re: Sequencer embedded C code question Pete Jemian

Navigate by Date:
Prev: Re: Sequencer embedded C code question Pete Jemian
Next: error while loading shared libraries Bruins, Stefan
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Sequencer embedded C code question Pete Jemian
Next: Re: Sequencer embedded C code question Eric Norum
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024