.\" Automatically generated by Pod::Man 2.1801 (Pod::Simple 3.05) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "OWNet 3" .TH OWNet 3 "2010-06-15" "perl v5.10.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" OWNet \- Light weight access to \fBowserver\fR .SH "SYNOPSIS" .IX Header "SYNOPSIS" OWNet is an easy way to access \fBowserver\fR and thence the 1\-wire bus. .PP Dallas Semiconductor's 1\-wire system uses simple wiring and unique addresses for its interesting devices. The \fBOne Wire File System (\s-1OWFS\s0)\fR is a suite of programs that hide 1\-wire details behind a file system metaphor. \fBowserver\fR connects to the 1\-wire bus and provides network access. .PP \&\fBOWNet\fR is a perl module that connects to \fBowserver\fR and allows reading, writing and listing the 1\-wire bus. .PP Example perl program that prints the temperature: .PP .Vb 2 \& use OWNet ; \& print OWNet::read( "localhost:4304" , "/10.67C6697351FF/temperature" ) ."\en" ; .Ve .PP There is the alternative object oriented form: .PP .Vb 3 \& use OWNet ; \& my $owserver = OWNet\->new( "localhost:4304" ) ; \& print $owserver\->read( "/10.67C6697351FF/temperature" ) ."\en" ; .Ve .SH "SYNTAX" .IX Header "SYNTAX" .SS "methods" .IX Subsection "methods" .IP "\fBnew\fR" 4 .IX Item "new" .Vb 1 \& my $owserver = OWNet \-> new( address ) ; .Ve .IP "\fBread\fR" 4 .IX Item "read" .Vb 2 \& OWNet::read( address, path [,size [,offset]] ) \& $owserver \-> read( path [,size [,offset]] ) .Ve .IP "\fBwrite\fR" 4 .IX Item "write" .Vb 2 \& OWNet::write( address, path, value [,offset] ) \& $owserver \-> write( path, value [,offset] ) .Ve .IP "\fBdir\fR" 4 .IX Item "dir" .Vb 2 \& OWNet::dir( address, path ) \& $owserver \-> dir( path ) .Ve .SS "\fIaddress\fP" .IX Subsection "address" \&\s-1TCP/IP\s0 \fIaddress\fR of \fBowserver\fR. Valid forms: .IP "\fIname\fR test.owfs.net:4304" 4 .IX Item "name test.owfs.net:4304" .PD 0 .IP "\fIquad\fR number: 123.231.312.213:4304" 4 .IX Item "quad number: 123.231.312.213:4304" .IP "\fIhost\fR localhost:4304" 4 .IX Item "host localhost:4304" .IP "\fIport\fR 4304" 4 .IX Item "port 4304" .PD .SS "\fIadditional arguments\fP" .IX Subsection "additional arguments" Additional arguments to add to address .PP Temperature scale can also be specified in the \fIaddress\fR. Same syntax as the other \s-1OWFS\s0 programs: .IP "\-C Celsius (Centigrade)" 4 .IX Item "-C Celsius (Centigrade)" .PD 0 .IP "\-F Fahrenheit" 4 .IX Item "-F Fahrenheit" .IP "\-K Kelvin" 4 .IX Item "-K Kelvin" .IP "\-R Rankine" 4 .IX Item "-R Rankine" .PD .PP Pressure scale can also be specified in the \fIaddress\fR. Same syntax as the other \s-1OWFS\s0 programs: .IP "\-\-mbar millibar (default)" 4 .IX Item "--mbar millibar (default)" .PD 0 .IP "\-\-atm atmosphere" 4 .IX Item "--atm atmosphere" .IP "\-\-mmHg mm Mercury" 4 .IX Item "--mmHg mm Mercury" .IP "\-\-inHg inch Mercury" 4 .IX Item "--inHg inch Mercury" .IP "\-\-psi pounds per inch^2" 4 .IX Item "--psi pounds per inch^2" .IP "\-\-Pa pascal" 4 .IX Item "--Pa pascal" .PD .PP Device display format (1\-wire unique address) can also be specified in the \fIaddress\fR, with the general form of \-ff[.]i[[.]c] (\fIf\fRamily \fIi\fRd \fIc\fRrc): .IP "\-ff.i /10.67C6697351FF (default)" 4 .IX Item "-ff.i /10.67C6697351FF (default)" .PD 0 .IP "\-ffi /1067C6697351FF" 4 .IX Item "-ffi /1067C6697351FF" .IP "\-ff.i.c /10.67C6697351FF.8D" 4 .IX Item "-ff.i.c /10.67C6697351FF.8D" .IP "\-ff.ic /10.67C6697351FF8D" 4 .IX Item "-ff.ic /10.67C6697351FF8D" .IP "\-ffi.c /1067C6697351FF.8D" 4 .IX Item "-ffi.c /1067C6697351FF.8D" .IP "\-ffic /1067C6697351FF8D" 4 .IX Item "-ffic /1067C6697351FF8D" .PD .PP Show directories that are themselves directories with a '/' suffix ( e.g. /10.67C6697351FF/ ) .IP "\-slash show directory elements" 4 .IX Item "-slash show directory elements" .PP Warning messages will only be displayed if verbose flag is specified in \fIaddress\fR .IP "\-v verbose" 4 .IX Item "-v verbose" .SS "\fIpath\fP" .IX Subsection "path" \&\fBowfs\fR\-type \fIpath\fR to an item on the 1\-wire bus. Valid forms: .IP "main directories" 4 .IX Item "main directories" Used for the \fIdir\fR method. E.g. \*(L"/\*(R" \*(L"/uncached\*(R" \*(L"/1F.321432320000/main\*(R" .IP "device directory" 4 .IX Item "device directory" Used for the \fIdir\fR and \fIpresent\fR method. E.g. \*(L"/10.4300AC220000\*(R" \*(L"/statistics\*(R" .IP "device properties" 4 .IX Item "device properties" Used to \fIread\fR, \fIwrite\fR. E.g. \*(L"/10.4300AC220000/temperature\*(R" .SS "\fIvalue\fP" .IX Subsection "value" New \fIvalue\fR for a device property. Used by \fIwrite\fR. .SH "METHODS" .IX Header "METHODS" .IP "\fBnew\fR" 4 .IX Item "new" Object-oriented (only): .Sp \&\fBOWNet::new\fR( \fIaddress\fR ) .Sp Create a new OWNet object \*(-- corresponds to an \fBowserver\fR. .Sp Error (and undef return value) if: .RS 4 .IP "1 Badly formed tcp/ip \fIaddress\fR" 4 .IX Item "1 Badly formed tcp/ip address" .PD 0 .IP "2 No \fBowserver\fR at \fIaddress\fR" 4 .IX Item "2 No owserver at address" .IP "" 4 .RE .RS 4 .RE .IP "\fBread\fR" 4 .IX Item "read" .RS 4 .IP "Non object-oriented:" 4 .IX Item "Non object-oriented:" .PD \&\fBOWNet::read\fR( \fIaddress\fR , \fIpath\fR [ , \fIsize\fR [ , \fIoffset\fR ] ] ) .IP "Object-oriented:" 4 .IX Item "Object-oriented:" \&\f(CW$ownet\fR\->\fBread\fR( \fIpath\fR [ , \fIsize\fR [ , \fIoffset\fR ] ] ) .RE .RS 4 .Sp Read the value of a 1\-wire device property. Returns the (scalar string) value of the property. .Sp \&\fIsize\fR (number of bytes to read) is optional .Sp \&\fIoffset\fR (number of bytes from start of field to start write) is optional .Sp Error (and undef return value) if: .IP "1 (Non object) No \fBowserver\fR at \fIaddress\fR" 4 .IX Item "1 (Non object) No owserver at address" .PD 0 .IP "2 (Object form) Not called with a valid OWNet object" 4 .IX Item "2 (Object form) Not called with a valid OWNet object" .IP "3 Bad \fIpath\fR" 4 .IX Item "3 Bad path" .IP "4 \fIpath\fR not a readable device property" 4 .IX Item "4 path not a readable device property" .IP "" 4 .RE .RS 4 .RE .IP "\fBwrite\fR" 4 .IX Item "write" .RS 4 .IP "Non object-oriented:" 4 .IX Item "Non object-oriented:" .PD \&\fBOWNet::write\fR( \fIaddress\fR , \fIpath\fR , \fIvalue\fR [ , \fIoffset\fR ] ) .IP "Object-oriented:" 4 .IX Item "Object-oriented:" \&\f(CW$ownet\fR\->\fBwrite\fR( \fIpath\fR , \fIvalue\fR [ , \fIoffset\fR ] ) .RE .RS 4 .Sp Set the value of a 1\-wire device property. Returns \*(L"1\*(R" on success. .Sp \&\fIoffset\fR (number of bytes from start of field to start write) is optional .Sp Error (and undef return value) if: .IP "1 (Non object) No \fBowserver\fR at \fIaddress\fR" 4 .IX Item "1 (Non object) No owserver at address" .PD 0 .IP "2 (Object form) Not called with a valid OWNet object" 4 .IX Item "2 (Object form) Not called with a valid OWNet object" .IP "3 Bad \fIpath\fR" 4 .IX Item "3 Bad path" .IP "4 \fIpath\fR not a writable device property" 4 .IX Item "4 path not a writable device property" .IP "5 \fIvalue\fR incorrect size or format" 4 .IX Item "5 value incorrect size or format" .IP "" 4 .RE .RS 4 .RE .IP "\fBdir\fR" 4 .IX Item "dir" .RS 4 .IP "Non object-oriented:" 4 .IX Item "Non object-oriented:" .PD \&\fBOWNet::dir\fR( \fIaddress\fR , \fIpath\fR ) .IP "Object-oriented:" 4 .IX Item "Object-oriented:" \&\f(CW$ownet\fR\->\fBdir\fR( \fIpath\fR ) .RE .RS 4 .Sp Return a comma-separated list of the entries in \fIpath\fR. Entries are equivalent to \*(L"fully qualified names\*(R" \*(-- full path names. .Sp Error (and undef return value) if: .IP "1 (Non object) No \fBowserver\fR at \fIaddress\fR" 4 .IX Item "1 (Non object) No owserver at address" .PD 0 .IP "2 (Object form) Not called with a valid OWNet object" 4 .IX Item "2 (Object form) Not called with a valid OWNet object" .IP "3 Bad \fIpath\fR" 4 .IX Item "3 Bad path" .IP "4 \fIpath\fR not a directory" 4 .IX Item "4 path not a directory" .IP "" 4 .RE .RS 4 .RE .IP "\fBpresent\fR (deprecated)" 4 .IX Item "present (deprecated)" .RS 4 .IP "Non object-oriented:" 4 .IX Item "Non object-oriented:" .PD \&\fBOWNet::present\fR( \fIaddress\fR , \fIpath\fR ) .IP "Object-oriented:" 4 .IX Item "Object-oriented:" \&\f(CW$ownet\fR\->\fBpresent\fR( \fIpath\fR ) .RE .RS 4 .Sp Test if a 1\-wire device exists. .Sp Error (and undef return value) if: .IP "1 (Non object) No \fBowserver\fR at \fIaddress\fR" 4 .IX Item "1 (Non object) No owserver at address" .PD 0 .IP "2 (Object form) Not called with a valid OWNet object" 4 .IX Item "2 (Object form) Not called with a valid OWNet object" .IP "3 Bad \fIpath\fR" 4 .IX Item "3 Bad path" .IP "4 \fIpath\fR not a device" 4 .IX Item "4 path not a device" .IP "" 4 .RE .RS 4 .RE .PD .SH "DESCRIPTION" .IX Header "DESCRIPTION" .SS "\s-1OWFS\s0" .IX Subsection "OWFS" \&\fI\s-1OWFS\s0\fR is a suite of programs that allows easy access to \fIDallas Semiconductor\fR's 1\-wire bus and devices. \&\fI\s-1OWFS\s0\fR provides a consistent naming scheme, safe multplexing of 1\-wire traffice, multiple methods of access and display, and network access. The basic \fI\s-1OWFS\s0\fR metaphor is a file-system, with the bus beinng the root directory, each device a subdirectory, and the the device properties (e.g. voltage, temperature, memory) a file. .SS "1\-Wire" .IX Subsection "1-Wire" \&\fI1\-wire\fR is a protocol allowing simple connection of inexpensive devices. Each device has a unique \s-1ID\s0 number (used in its \s-1OWFS\s0 address) and is individually addressable. The bus itself is extremely simple \*(-- a data line and a ground. The data line also provides power. 1\-wire devices come in a variety of packages \*(-- chips, commercial boxes, and iButtons (stainless steel cans). 1\-wire devices have a variety of capabilities, from simple \s-1ID\s0 to complex voltage, temperature, current measurements, memory, and switch control. .SS "Programs" .IX Subsection "Programs" Connection to the 1\-wire bus is either done by bit-banging a digital pin on the processor, or by using a bus master \*(-- \s-1USB\s0, serial, i2c, parallel. The heavy-weight \fI\s-1OWFS\s0\fR programs: \fBowserver\fR \fBowfs\fR \fBowhttpd\fR \fBowftpd\fR and the heavy-weight perl module \fB\s-1OW\s0\fR all link in the full \fI\s-1OWFS\s0\fR library and can connect directly to the bus master(s) and/or to \fBowserver\fR. .PP \&\fBOWNet\fR is a light-weight module. It connects only to an \fBowserver\fR, does not link in the \fI\s-1OWFS\s0\fR library, and should be more portable.. .SS "Object-oriented" .IX Subsection "Object-oriented" \&\fBOWNet\fR can be used in either a classical (non-object-oriented) manner, or with objects. The object stored the ip address of the \fBowserver\fR and a network socket to communicate. \&\fBOWNet\fR will use persistent tcp connections for the object form \*(-- potentially a performance boost over a slow network. .SH "EXAMPLES" .IX Header "EXAMPLES" .SS "owserver" .IX Subsection "owserver" \&\fBowserver\fR is a separate process that must be accessible on the network. It allows multiple clients, and can connect to many physical 1\-wire adapters and 1\-wire devices. It's address must be discoverable \*(-- either set on the command line, or at it's default location, or by using Bonjour (zeroconf) service discovery. .PP An example owserver invocation for a serial adapter and explicitly chooses the default port: .PP .Vb 1 \& owserver \-d /dev/ttyS0 \-p 4304 .Ve .SS "OWNet" .IX Subsection "OWNet" .Vb 1 \& use OWNet ; \& \& # Create owserver object \& my $owserver = OWNet\->new(\*(Aqlocalhost:4304 \-v \-F\*(Aq) ; #default location, verbose errors, Fahrenheit degrees \& # my $owserver = OWNet\->new() ; #simpler, again default location, no error messages, default Celsius \& \& #print directory \& print $owserver\->dir(\*(Aq/\*(Aq) ; \& \& #print temperature from known device (DS18S20, ID: 10.13224366A280) \& print "Temperature: ".$owserver\->read(\*(Aq/uncached/10.13224366A280/temperature\*(Aq) ; \& \& # Now for some fun \-\- a tree of everything: \& sub Tree($$) { \& my $ow = shift ; \& my $path = shift ; \& \& print "$path\et" ; \& \& # first try to read \& my $value = $ow\->read($path) ; \& if ( defined($value) ) { \& print "$value\en"; \& return ; \& } \& \& # not readable, try as directory \& my $dirstring = $ow\->dir($path) ; \& if ( defined($dirstring) ) { \& print "\en" ; \& my @dir = split /,/ , $ow\->dir($path) ; \& foreach (@dir) { \& Tree($ow,$_) ; \& } \& return ; \& } \& \& # can\*(Aqt read, not directory \& print "\en" ; \& return ; \& } \& \& Tree( $owserver, \*(Aq/\*(Aq ) ; .Ve .SH "INTERNALS" .IX Header "INTERNALS" .SS "Object properties (All private)" .IX Subsection "Object properties (All private)" .IP "\s-1ADDR\s0" 4 .IX Item "ADDR" literal sting for the \s-1IP\s0 address, in dotted-quad or host format. This property is also used to indicate a substantiated object. .IP "\s-1PORT\s0" 4 .IX Item "PORT" string for the port number (or service name). Service name must be specified as :owserver or the like. .IP "\s-1SG\s0" 4 .IX Item "SG" Flag sent to server, and returned, that encodes temperature scale and display format. Persistence is also encoded in this word in the actual tcp message, but kept separately in the object. .IP "\s-1VERBOSE\s0" 4 .IX Item "VERBOSE" Print error messages? Set by \*(L"\-v\*(R" in object invocation. .IP "\s-1SLASH\s0" 4 .IX Item "SLASH" Add \*(L"/\*(R" to the end of directory entries. Set by \*(L"\-slash\*(R" in object invocation. .IP "\s-1SOCK\s0" 4 .IX Item "SOCK" Socket address (object) for communication. Stays defined for persistent connections, else deleted between calls. .IP "\s-1PERSIST\s0" 4 .IX Item "PERSIST" State of socket connection (persistent means the same socket is used which speeds network communication). .IP "\s-1VER\s0" 4 .IX Item "VER" owprotocol version number (currently 0) .SS "Private methods" .IX Subsection "Private methods" .IP "_self" 4 .IX Item "_self" Takes either the implicit object reference (if called on an object) or the ip address in non-object format. In either case a socket is created, the persistence bit is properly set, and the address parsed. Returns the object reference, or undef on error. Called by each external method (read,write,dir) on the first parameter. .IP "_new" 4 .IX Item "_new" Takes command line invocation parameters (for an object or not) and properly parses and sets up the properties in a hash array. .IP "_Sock" 4 .IX Item "_Sock" Socket processing, including tests for persistence and opening. If no host is specified, localhost (127.0.0.1) is used. If no port is specified, uses the \s-1IANA\s0 allocated well known port (4304) for owserver. First looks in /etc/services, then just tries 4304. .IP "_ToServer" 4 .IX Item "_ToServer" Sends a message to owserver. Formats in owserver protocol. If a persistent socket fails, retries after new socket created. .IP "_FromServerBinaryParse" 4 .IX Item "_FromServerBinaryParse" Reads a specified length from server .IP "_FromServer" 4 .IX Item "_FromServer" Reads whole packet from server, using _FromServerBinaryParse (first for header, then payload). Discards ping packets silently. .IP "_BonjourLookup" 4 .IX Item "_BonjourLookup" Uses the mDNS service discovery protocol to find an available owserver. Employs NET::Rendezvous (an earlier name or Apple's Bonjour) This module is loaded only if available. (Uses the method of http://sial.org/blog/2006/12/optional_perl_module_loading.html) .SH "AUTHOR" .IX Header "AUTHOR" Paul H Alfille paul.alfille@gmail.com .SH "BUGS" .IX Header "BUGS" Support for proper timeout using the \*(L"select\*(R" function seems broken in perl. This might leave the routines vulnerable to network timing errors. .SH "SEE ALSO" .IX Header "SEE ALSO" .IP "http://www.owfs.org" 4 .IX Item "http://www.owfs.org" Documentation for the full \fBowfs\fR program suite, including man pages for each of the supported 1\-wire devices, and more extensive explanatation of owfs components. .IP "http://owfs.sourceforge.net/projects/owfs" 4 .IX Item "http://owfs.sourceforge.net/projects/owfs" Location where source code is hosted. .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (c) 2007 Paul H Alfille. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.