OWFS Design
OWFS Features
OWFS Software
Examples & Usage
|
::BOH
$Id: owpython.html,v 1.4 2005/02/07 19:45:21 peterk Exp $
$HeadURL: http://subversion/stuff/svn/owfs/trunk/ow/__init__.py $
Copyright (c) 2004, 2005 Peter Kropf. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
::EOH
1-wire sensor network interface.
OWFS is an open source project developed by Paul Alfille and hosted at
http://owfs.sourceforge.net.
Classes |
| | |
- exceptions.Exception
-
- exError
-
- exErrorValue
- exNoController
- exNotInitialized
- __builtin__.object
-
- Sensor
class Sensor(__builtin__.object) |
| |
A Sensor is the basic component of a 1-wire network. It represents
a individual 1-wire element as it exists on the network. |
| |
Methods defined here:
- __eq__(self, other)
- Two sensors are considered equal if their paths are
equal. This is done by comparing their _path attributes so
that cached and uncached Sensors compare equal.
Examples:
>>> Sensor( '/' ) == Sensor( '/1F.440701000000' )
False
>>> Sensor( '/' ) == Sensor( '/uncached' )
True
- __getattr__(self, name)
- Retreive an attribute from the sensor. __getattr__ is called
only if the named item doesn't exist in the Sensor's
namespace. If it's not in the namespace, look for the attribute
on the physical sensor.
Usage:
s = ow.Sensor( '/1F.5D0B01000000' )
print s.family, s.PIO_0
will result in the family and PIO.0 values being read from the
sensor and printed. In this example, the family would be 1F
and thr PIO.0 might be 1.
- __init__(self, path)
- Create a new Sensor as it exists at the specified path.
- __repr__(self)
- Print a representation of the Sensor in the form of:
Sensor( path )
Example:
>>> Sensor( '/' )
Sensor("/")
- __setattr__(self, name, value)
- Set the value of a sensor attribute. This is accomplished by
first determining if the physical sensor has the named
attribute. If it does, then the value is written to the
name. Otherwise, the Sensor's dictionary is updated with the
name and value.
Usage:
s = ow.Sensor( '/1F.5D0B01000000' )
s.PIO_1 = '1'
will set the value of PIO.1 to 1.
- __str__(self)
- Print a string representation of the Sensor in the form of:
path - type
Example:
>>> print Sensor( '/' )
/ - DS9490
- entries(self)
- Generator which yields the attributes of a sensor.
- entryList(self)
- List of the sensor's attributes.
Example:
>>> Sensor("/10.B7B64D000800").entryList( )
['address', 'crc8', 'die', 'family', 'id', 'power',
'present', 'temperature', 'temphigh', 'templow',
'trim', 'trimblanket', 'trimvalid', 'type']
- find(self, **keywords)
- Generator which yields all the sensors whose attributes match
those past in. By default, any matched attribute will yield a
sensor. If the parameter all is passed to the find call, then
all the supplied attributes must match to yield a sensor.
Usage:
for s in Sensor( '/' ).find( type = 'DS2408' ):
print s
will print all the sensors whose type is DS2408.
root = Sensor( '/' )
print len( [ s for s in root.find( all = True,
family = '1F',
type = 'DS2409' ) ] )
will print the count of sensors whose family is 1F and whose
type is DS2409.
- sensorList(self, names=['main', 'aux'])
- List of all the sensors that are associated with the current
sensor.
In the event that the current sensor is the adapter (such as a
DS9490 USB adapter) the list of sensors directly attached to
the 1-wire network will be yielded.
In the event that the current sensor is a microlan controller
(such as a DS2409) the list of directories found in the names
list parameter will be searched and any sensors found will be
yielded. The names parameter defaults to [ 'main', 'aux' ].
Example:
>>> Sensor("/1F.440701000000").sensorList( )
[Sensor("/1F.440701000000/main/29.400900000000")]
- sensors(self, names=['main', 'aux'])
- Generator which yields all the sensors that are associated
with the current sensor.
In the event that the current sensor is the adapter (such as a
DS9490 USB adapter) the list of sensors directly attached to
the 1-wire network will be yielded.
In the event that the current sensor is a microlan controller
(such as a DS2409) the list of directories found in the names
list parameter will be searched and any sensors found will be
yielded. The names parameter defaults to [ 'main', 'aux' ].
- useCache(self, use_cache)
- Set the sensor to use the underlying owfs cache (or not)
depending on the use_cache parameter.
Usage:
s = ow.Sensor( '/1F.5D0B01000000' )
s.useCache( False )
will set the internal sensor path to /uncached/1F.5D0B01000000.
Also:
s = ow.Sensor( '/uncached/1F.5D0B01000000' )
s.useCache( True )
will set the internal sensor path to /1F.5D0B01000000.
Data and other attributes defined here:
- __dict__ = <dictproxy object>
- dictionary for instance variables (if defined)
- __weakref__ = <attribute '__weakref__' of 'Sensor' objects>
- list of weak references to the object (if defined)
|
|
Functions |
| | |
- finish()
- Cleanup the OWFS library, freeing any used resources.
- init(iface)
- Initialize the OWFS library by specifying the interface mechanism
to be used for communications to the 1-wire network.
Examples:
ow.init( 'u' )
Will initialize the 1-wire interface to use the USB controller.
ow.init( '/dev/ttyS0' )
Will initialize the 1-wire interface to use the /dev/ttyS0 serial
port.
ow.init( 'remote_system:3003' )
Will initialize the 1-wire interface to use the owserver running
on remote_system on port 3003.
- log_get(path)
- Write the _OW.get call details out to the log file.
- log_put(path, value)
- Write the _OW.put call details out to the log file.
- owfs_get = get(...)
- owfs_put = put(...)
|
Data |
| | |
__author__ = 'Peter Kropf'
__email__ = 'peterk at bayarea dot net'
__version__ = '2.0p0RC-1.6'
initialized = False
use_logging = False |
|