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 | 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 |
<== Date ==> | <== Thread ==> |
---|
Subject: | Re: Monitoring whether an IP device is connected or not |
From: | David Michel <[email protected]> |
To: | "J. Lewis Muir" <[email protected]> |
Cc: | [email protected] |
Date: | Thu, 27 Feb 2014 11:26:41 +0000 |
On 2/25/14, 11:20 AM, David Michel wrote:Hi, David.
>> Depending on what platform your IOC is running, you could potentially
>> execute the platform's ping program from your C function. This would
>> allow you to ping without running your IOC as root.
>
> That's exactly what I was doing. On Linux (Ubuntu).
>
>> if you can make a small change to your black box, is to run a simple
>> server on your black box that listens on a TCP or UDP port. You
>> could then use asyn or StreamDevice on your IOC to send a tiny
>> request to that server.
>
> Yes, that could be an option - Similarly, I was thinking I could
> perhaps run an "dummy" IOC with a "dummy" record that is queried from
> the other IOC. This way, I can use the builtin PVExistTest routine
> that will notify the IOC and my OPI rather quickly and without much
> development effort.
>
> What I'm not sure of with this approach is how to turn the
> "disconnected" information into say a bi record with 1 for connected
> and 0 for disconnected ??
If you're willing to install an IOC on your black box and your existing
IOC can communicate with it, then you could just have a record instance
on your existing IOC with a CA input link (i.e. Channel Access INLINK)
referencing a PV on your black box IOC. For example, if on your
black box IOC you had a longout record instance named "blackBox:id",
you could have a longin record instance on your existing IOC named
"exisiting:idOfBlackBox" with its INP field set to "blackBox:id CP
NMS". Now, if your existing IOC loses communication with the black box
IOC, the longin record instance's STAT and SEVR fields will go to some
value other than NO_ALARM, and you can detect this with another record
instance to make your bi record instance be 1 for connected and 0 for
disconnected. Or you could just make your OPI observe the STAT or SEVR
fields of "existing:idOfBlackBox" and react accordingly.
If you wanted to be fancier, you could make the black box IOC have a
record instance named "blackBox:heartbeat" which cycles periodically
between 0 and 1. Monitor that PV from your existing IOC and add logic
to detect when the black box heartbeat value does not change at the
expected interval.
If you want to stick with your approach of executing the ping program
from a C function, I suspect there's some way for the function to set
a value (e.g. 0 for disconnected and 1 for connected) of one of the
fields of the aSub record instance. I've never used the aSub record,
though, so I couldn't say for sure without looking at the aSub record or
documentation.
Another approach that would work with your C function approach would
be to call your C function from an EPICS SNL program [1]. Based on
the return status of the C function, you could set an EPICS PV in the
SNL program to 0 or 1 using the pvPut function. That would be pretty
straightforward.
Lewis
1. http://www-csr.bessy.de/control/SoftDist/sequencer/index.html