I would follow Colin suggestion:
do not tweak owserver, but deploy an in memory cache that acts like a buffer
between owserver and the clients.
I would suggest redis http://redis.io <http://redis.io/> (or memcached, but I
prefer redis).
A basic setup would be to have a daemon process that continuously polls
owserver and feeds data into the redis data store, while your clients fetch
data from redis. If you use python this approach will require just a few lines
of code.
Here is a minimalistic example (not production ready, just to get started.)
The updater code snippet:
from pyownet import protocol
import redis
EXPTIME = 60 # expiry time in seconds, to have stale data evicted from cache
owproxy = protocol.proxy(host="localhost", port=4304,
flags=protocol.FLG_UNCACHED)
rdb = redis.StrictRedis(host="localhost", port=6379, db=0)
while True:
for sensor in owproxy.dir("/", slash=False, bus=False):
temperature = owproxy.read(sensor + "/temperature")
rdb.set(sensor, temperature, ex=EXPTIME)
The client code snippet:
import redis
rdb = redis.StrictRedis(host='localhost', port=6379, db=0)
temperature = rdb.get('/28.67C6697351FF')
On my rpi2 the rdb.get call takes less than 1ms, but have a look on
http://redis.io/topics/benchmarks <http://redis.io/topics/benchmarks> to have
an idea on how fast redis can be. Installation is painless, python-side you
just “pip install pyownet redis”, while redis server is for sure already
packaged in CentOS.
Bye
Stefano
> On 23 Sep 2015, at 14:35, Alex R. Gibbs <agi...@lpl.arizona.edu
> <mailto:agi...@lpl.arizona.edu>> wrote:
>
> Hello,
>
> We have dozens of DS18B20 temperature sensors at 3 telescopes. I'd like to
> poll
> them and cache the results so that other programs can retrieve the latest
> temperatures with less than 50ms delay. It doesn't matter if the values are
> a
> few minutes old; just that clients don't have to wait for a response. I am
> using owserver 3.1p0 on CentOS 6.5 64bit with a LinkHub-E.
>
> Is it possible to configure owserver to continuously poll devices on it's
> own?
> The owserver cache works but of course once a value in the cache expires the
> next request for it forces a read of the device, making the client wait about
> 800ms. If owserver can be set to poll devices then I can set the expire time
> such that this usually never happens.
>
> I tried having a background program poll the uncached values in owserver more
> often than the volatile timeout so that the cached values are never
> considered
> expired. However, a client still has to wait for a cached value if it is
> currently being read out due to an uncached request, even if the cached value
> isn't expired. If that was changed I think this would work.
>
> Any suggestions on how to setup polling so that a client can always get a
> cached
> value immediately? I have a feeling I'll need to either modify owserver or
> write my own server wrapper.
>
> Thanks,
> Alex
>
> --
> Alex R. Gibbs - agi...@lpl.arizona.edu <mailto:agi...@lpl.arizona.edu>
> Principal Engineer - Catalina Sky Survey
> Lunar & Planetary Lab - University of Arizona
> --
>
> ------------------------------------------------------------------------------
> Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
> Get real-time metrics from all of your servers, apps and tools
> in one place.
> SourceForge users - Click here to start your Free Trial of Datadog now!
> http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
> <http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140>
> _______________________________________________
> Owfs-developers mailing list
> Owfs-developers@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/owfs-developers
------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
_______________________________________________
Owfs-developers mailing list
Owfs-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/owfs-developers