OWNET(1) One-Wire File System OWNET(1)

# [NAME](#NAME)

**ownet** , **(libownet)** - easy C-language 1-wire interface to the owserver protocol

# [SYNOPSIS](#SYNOPSIS)

**libownet** library to link with your program

## [Handle](#Handle)

**OWNET\_HANDLE**  
Handle to each owserver connection

## [Initialization](#Initialization)

**OWNET\_HANDLE OWNET\_init( const char \*** *owserver\_tcp\_address\_and\_port* **)**  
Associate an [**owserver (1)**](/man/os/owfs/owserver.1) tcp/ip address with a handle.

## [Directory listing](#Directory_listing)

**int OWNET\_dirlist( OWNET\_HANDLE** *owserver\_handle* **, const char \*** *onewire\_path* **, char \*\*** *comma\_separated\_list* **)**  
Create a comma-separated list of directory elements.

**int OWNET\_dirprocess( OWNET\_HANDLE** *owserver\_handle* **, const char \*** *onewire\_path* **, void (\*** *dirfunc* **) (void \*, const char \*), void \*** *passed\_on\_value* **)**  
**void** *dirfunc* **( void \*** *passed\_on\_value* **, const char \*** *directory\_element* **)**  
Apply function *dirfunc* to each directory element, along with an arbitrary passed\_on\_value.

## [Get data](#Get_data)

**int OWNET\_read( OWNET\_HANDLE** *owserver\_handle* **, const char \*** *onewire\_path* **, const char \*\*** *return\_string* **)**  
Read a value (of specified size) from a 1-wire device.

**int OWNET\_lread( OWNET\_HANDLE** *owserver\_handle* **, const char \*** *onewire\_path* **, const char \*\*** *return\_string* **, size\_t** *size* **, off\_t** *offset* **)**  
Read a value (of specified size and offset) from a 1-wire device.

**int OWNET\_present( OWNET\_HANDLE** *owserver\_handle* **, const char \*** *onewire\_path* **)**  
Check if a 1-wire device is present.

## [Set data](#Set_data)

**int OWNET\_put( OWNET\_HANDLE** *owserver\_handle* **, const char \*** *onewire\_path* **, const char \*** *value\_string* **, size\_t** *size* **)**  
Write a value (of specified size) to a 1-wire device.

**int OWNET\_lwrite( OWNET\_HANDLE** *owserver\_handle* **, const char \*** *onewire\_path* **, const char \*** *value\_string* **, size\_t** *size* **, off\_t** *offset* **)**  
Write a value (of specified size and offset) to a 1-wire device.

## [Close](#Close)

**void OWNET\_close( OWNET\_HANDLE** *owserver\_handle* **)**  
Close the connection to a particular owserver.

**void OWNET\_closeall( void )**  
Close all open owserver connections.

**void OWNET\_finish( void )**  
Close all open owserver connections and free all memory.

## [Temperature scale](#Temperature_scale)

**void OWNET\_set\_temperature\_scale( char** *temperature\_scale* **)**  
**char OWNET\_get\_temperature\_scale( void )**  
Set and retrieve the temperature scale used for all communications.

## [Device format](#Device_format)

**void OWNET\_set\_device\_format( const char \*** *device\_format* **)**  
**const char * OWNET\_get\_device\_format( void )**  
Set and retrieve the 1-wire device serial number format used for all communications.

# [FUNCTIONS](#FUNCTIONS)

## [OW\_init](#OW_init)

*OW\_init\_string* offers the full flexibility of the **owfs (1)** and [**owhttpd (1)**](/man/os/owfs/owhttpd.1) command line.

[*Arguments*](#Arguments)

Can be as simple as jus the device name, a full parameter specification. One or more device names (includes tcp, serial, usb...) and command line switches. See [**owfs (1)**](/man/os/owfs/owfs.1) for full syntax.

[*Returns*](#Returns)

0 for success. -1 on error and *errno* will be set. *OW\_finish* does not need to be called if *OW\_init* fails.

[*Sequence*](#Sequence)

One of the *init* functions must be called before accessing the 1-wire bus. *OW\_finish* is optional.

## [OW\_init\_args](#OW_init_args)

*OW\_init\_args* offers the full flexibility of the **owfs (1)** and [**owhttpd (1)**](/man/os/owfs/owhttpd.1) command line.

[*Arguments*](#Arguments~2)

One or more device names (includes tcp, serial, usb...) and command line switches. See [**owfs (1)**](/man/os/owfs/owfs.1) for full syntax. Unlike *OW\_init\_string* the arguments are in argv/argc format.

[*Returns*](#Returns~2)

0 for success. -1 on error and *errno* will be set. *OW\_finish* does not need to be called if *OW\_init* fails.

[*Sequence*](#Sequence~2)

One of the *init* functions must be called before accessing the 1-wire bus. *OW\_finish* is optional.

## [OW\_get](#OW_get)

*OW\_get* is used to get directory listings and file contents. The results are put in a dynamically allocated buffer.

[*Arguments*](#Arguments~3)

*path* is the path to the directory or file (property). *\*buffer* returns a pointer to a buffer containing the directory (comma separated) or value. *buffer\_length* returns the length of the value/string in *buffer*

[*Returns*](#Returns~3)

number of bytes on success. -1 on error (and *errno* is set).

[*Sequence*](#Sequence~3)

One of the *init* functions must be called before accessing the 1-wire bus. *OW\_finish* is optional.

[*Important note*](#Important)

*buffer* is allocated ( with malloc ) by *OW\_get* but must be freed in your program. See [**malloc (3)**](/man/os/owfs/malloc.3) and [**free (3)**](/man/os/owfs/free.3)

## [OW\_lread](#OW_lread)

*OW\_lread* is used to read 1-wire memory chips. Think of it as a combination of *lseek* and *read* It allows random-access to the memory, specifying location and length. Unlike *OW\_get* directories cannot be obtained and the buffer must be pre-allocated rather than allocated by the routine. *buffer* must be at least *size* length.

[*Arguments*](#Arguments~4)

*path* is the path to the file (property). *buffer* is the (pre-allocated) memory area where the value will be placed. *size* is the length of bytes requested. *offset* is the position in file to start reading.

[*Returns*](#Returns~4)

number of bytes on success. -1 on error (and *errno* is set).

[*Sequence*](#Sequence~4)

One of the *init* functions must be called before accessing the 1-wire bus. *OW\_finish* is optional.

## [OW\_put](#OW_put)

*OW\_put* is an easy way to write to 1-wire chips.

[*Arguments*](#Arguments~5)

*path* is the path to the file (property). *buffer* is the value to be written. *buffer\_length* is the length of the value *buffer.* *Returns* number of bytes on success. -1 on error (and *errno* is set).

[*Sequence*](#Sequence~5)

One of the *init* functions must be called before accessing the 1-wire bus. *OW\_finish* is optional.

## [OW\_lwrite](#OW_lwrite)

*OW\_lwrite* is the companion of *OW\_lread.* It allows writing to arbitrary positions in 1-wire memory. Think of it as a combination of *lseek* and *write.* *buffer* must be at least *size* length.

[*Arguments*](#Arguments~6)

*path* is the path to the file (property). *buffer* is the data to be written. *size* is the length of bytes to be written. *offset* is the position in file to start writing.

[*Returns*](#Returns~5)

number of bytes on success. -1 on error (and *errno* is set).

[*Sequence*](#Sequence~6)

One of the *init* functions must be called before accessing the 1-wire bus. *OW\_finish* is optional.

## [OW\_finish](#OW_finish)

*OW\_finish* cleans up the *OWFS* 1-wire routines, releases devices and memory.

[*Arguments*](#Arguments~7)

None.

[*Returns*](#Returns~6)

None

[*Sequence*](#Sequence~7)

*OW\_finish* is optional since cleanup is automatic on program exit.

# [DESCRIPTION](#DESCRIPTION)

See the file man1/description.1so.

## [libowcapi](#libowcapi)

[**libowcapi (1)**](/man/os/owfs/libowcapi.1) is an encapsulation of the full **libow** library for C programs.

[**libowcapi (1)**](/man/os/owfs/libowcapi.1) allows a C program to use *OWFS* principles (consistent naming scheme, multiple adapters, devices, and compatibility) directly from a C program. There are analogous modules for other programming languages:

[*C*](#C)

libowcapi

[*perl*](#perl)

owperl

[*php*](#php)

owphp

[*python*](#python)

owpython

[*tcl*](#tcl)

owtcl

# [EXAMPLE](#EXAMPLE)

/* Simple directory listing -- no error checking \*/  
#include &lt;ownetapi.h&gt;  
char * buf;  
size\_t s ;  
OWNET\_init("localhost:4304");  
OWNET\_dirlist("/",&buf,&s) ;  
printf("Directory %s0,buf);  
free(buf);  
OWNET\_finish() ;

# [SEE ALSO](#SEE_ALSO)

See the file man1/seealso.1so.

# [AVAILABILITY](#AVAILABILITY)

http://www.owfs.org

# [AUTHOR](#AUTHOR)

Paul Alfille (paul.alfille@gmail.com)

2008 OWFS Manpage

---

Document: ownetapi(1) from owfs 3.2.4-r9 (Chainguard OS)
Source: https://github.com/owfs/owfs
