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  2014  <20152016  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  2014  <20152016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: IOC without iocsh
From: Andrew Johnson <[email protected]>
To: <[email protected]>
Date: Fri, 26 Jun 2015 11:14:57 -0500
Hi Gennaro,

On 06/26/2015 09:29 AM, [email protected] wrote:
> I have developed for a Linux embedded board called uSOP various EPICS IOCs
> that publish different PVs for Belle2 environmental data (temperature,
> humidity);
> 
> to do these tasks I use makeBaseApp.pl scripts to start developing and
> the result is an IOC that provide an iocsh prompt;
> 
> now I have to add, for a new developing activity, some EPICS PVs to an
> exisiting application (not EPICS-enabled) and my question is how to do
> this in a simple and effective way...
> 
> just to be more clear, the application uses the stdin/stdout to control
> its states and I cannot use it for iocsh - how can I create an IOC
> "inside" my existing application ?

If you have another way to control the program you can embed an IOC
inside it, but bear in mind that sometimes the IOC code will write
status and/or error messages to the stdout and/or stderr streams. You
may be able to redirect them to other file descriptors in some cases,
but not necessarily in all.

When you create an IOC application directory, one of the source files in
the *App/src directory is a *Main.cpp file which is what starts
everything up. If you look at that source code you'll see it calls
iocsh() twice. The first time it is running the startup script, the
second time is when it gives the epics> prompt and waits for user input
on stdin. You can completely replace this main() routine with some other
way of starting up the IOC if you want to.

You might want to keep something like the first call to iocsh() to allow
your IOC to still make use of a st.cmd script to configure and start it
running, but even that could be replaced by C code if you prefer -- take
a look at the base/src/softIoc/softMain.cpp file for some ideas on doing
that.

To redirect the IOC's stdout and stderr streams there are some functions
epicsSetThreadStd{in|out|err}() declared in epicsStdio.h which set these
for the current thread but you can't change other threads, and the IOC
does start up many background threads. If your application could get
confused by spurious messages appearing on the stdout stream that might
be a problem; test it my setting the TPRO field on one or more of your
records to 1 and see how it behaves. Nothing normally reads from stdin
(other than iocsh() itself) so you generally won't need to redirect that.

HTH,

- Andrew
-- 
Light thinks it travels faster than anything but it is wrong.
No matter how fast light travels, it finds the darkness has
always got there first, and is waiting for it.
    -- Terry Pratchett, Reaper Man

References:
IOC without iocsh [email protected]

Navigate by Date:
Prev: Re: IOC without iocsh Michael Davidsaver
Next: Re: UCHAR to BitArray conversion ishita bhatia
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: IOC without iocsh Michael Davidsaver
Next: Re: UCHAR to BitArray conversion(binary-bits array) ishita bhatia
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 16 Dec 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·