OWNET(1)

πŸ’… OWNET β€” the manual, but make it cute

okay so bestie, this whole page is OWNET(1), living under the One-Wire File System umbrella. It's about ownet and (libownet) β€” your easy C-language 1-wire interface to the owserver protocol. Slay. Let's go. πŸŽ€


✨ NAME ✨

ownet , (libownet) β€” the easy C-language 1-wire interface to the owserver protocol. That's the whole vibe. πŸ’–


🌸 SYNOPSIS 🌸

libownet library to link with your program. Just. Link it. That's it. 🫢

πŸŽ€ Handle

  • OWNET_HANDLE β€” your handle to each owserver connection. One handle per connection, like one group chat per friend group. iykyk.

πŸŽ€ Initialization

  • OWNET_HANDLE OWNET_init( const char * owserver_tcp_address_and_port ) β€” associate an owserver (1) tcp/ip address with a handle. It's giving "here's where my server lives, pls remember it". ✨

πŸŽ€ 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. It's literally a lil roll call. πŸ“‹
  • int OWNET_dirprocess( OWNET_HANDLE owserver_handle , const char * onewire_path , void (* dirfunc ) (void *, const char *), void * passed_on_value ) β€” apply a function to each directory element. And it comes with a buddy signature:
    • void dirfunc ( void * passed_on_value , const char * directory_element ) β€” this is the function that gets run on each element, along with an arbitrary passed_on_value. Main character energy for every single entry. πŸ‘‘

πŸŽ€ 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. Fancy version, we love her. πŸ’…
  • int OWNET_present( OWNET_HANDLE owserver_handle , const char * onewire_path ) β€” check if a 1-wire device is present. Vibe check, but for hardware. πŸ”

πŸŽ€ 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. Random access but make it a glow-up. 🌟

πŸŽ€ Close

  • void OWNET_close( OWNET_HANDLE owserver_handle ) β€” close the connection to a particular owserver. Bye bestie, it was real. πŸ‘‹
  • void OWNET_closeall( void ) β€” close all open owserver connections. Group exit. πŸšͺ
  • void OWNET_finish( void ) β€” close all open owserver connections and free all memory. The full clean-up, no crumbs left. 🧹

πŸŽ€ 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. One setting to rule them all. 🌑️

πŸŽ€ 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. Same energy, but for serial numbers. πŸ”’


πŸ”₯ FUNCTIONS πŸ”₯

πŸ¦‹ OW_init

OW_init_string offers the full flexibility of the owfs (1) and owhttpd (1) command line. Like, the whole menu. 🍽️

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) for full syntax.

Returns

0 for success. -1 on error and errno will be set. OW_finish does not need to be called if OW_init fails. (no cap, that's a real caveat) ⚠️

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 offers the full flexibility of the owfs (1) and owhttpd (1) command line. Same icon, different fit. ✨

Arguments

One or more device names (includes tcp, serial, usb...) and command line switches. See owfs (1) for full syntax. Unlike OW_init_string the arguments are in argv/argc format.

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

One of the init functions must be called before accessing the 1-wire bus. OW_finish is optional.

πŸ¦‹ OW_get

OW_get is used to get directory listings and file contents. The results are put in a dynamically allocated buffer. It's giving "I brought you a gift and you have to throw away the wrapping yourself". 🎁

Arguments

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

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

Sequence

One of the init functions must be called before accessing the 1-wire bus. OW_finish is optional.

Important note

buffer is allocated ( with malloc ) by OW_get but must be freed in your program. See malloc (3) and free (3).

🚨 bestie this is the part where you don't forget to free it. memory leaks are NOT the vibe. 😭

πŸ¦‹ 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

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

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

Sequence

One of the init functions must be called before accessing the 1-wire bus. OW_finish is optional.

πŸ¦‹ OW_put

OW_put is an easy way to write to 1-wire chips. Low effort, high reward. πŸ’«

Arguments

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

One of the init functions must be called before accessing the 1-wire bus. OW_finish is optional.

πŸ¦‹ 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. They're a duo, fr fr. πŸ«‚

Arguments

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

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

Sequence

One of the init functions must be called before accessing the 1-wire bus. OW_finish is optional.

πŸ¦‹ OW_finish

OW_finish cleans up the OWFS 1-wire routines, releases devices and memory. The responsible queen behaviour. πŸ‘‘

Arguments

None.

Returns

None

Sequence

OW_finish is optional since cleanup is automatic on program exit.


πŸ’œ DESCRIPTION πŸ’œ

🌈 1-Wire

1-wire is a wiring protocol and series of devices designed and manufactured by Dallas Semiconductor, Inc. The bus is a low-power low-speed low-connector scheme where the data line can also provide power. Yes, the data line is also the power line. Overachiever. ⚑

Each device is uniquely and unalterably numbered during manufacture. There are a wide variety of devices, including memory, sensors (humidity, temperature, voltage, contact, current), switches, timers and data loggers. More complex devices (like thermocouple sensors) can be built with these basic devices. There are also 1-wire devices that have encryption included. πŸ”

The 1-wire scheme uses a single bus master and multiple slaves on the same wire. The bus master initiates all communication. The slaves can be individually discovered and addressed using their unique ID.

Bus masters come in a variety of configurations including serial, parallel, i2c, network or USB adapters. So many fits. πŸ§₯

🌈 OWFS design

OWFS is a suite of programs that designed to make the 1-wire bus and its devices easily accessible. The underlying principle is to create a virtual filesystem, with the unique ID being the directory, and the individual properties of the device are represented as simple files that can be read and written. It's a filesystem but for vibes and sensors. πŸ—‚οΈ

Details of the individual slave or master design are hidden behind a consistent interface. The goal is to provide an easy set of tools for a software designer to create monitoring or control applications. There are some performance enhancements in the implementation, including data caching, parallel access to bus masters, and aggregation of device communication. Still the fundamental goal has been ease of use, flexibility and correctness rather than speed. Correctness over clout. πŸ’―

🌈 libowcapi

libowcapi (1) is an encapsulation of the full libow library for C programs.

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 β€” libowcapi
  • perl β€” owperl
  • php β€” owphp
  • python β€” owpython
  • tcl β€” owtcl

pick your fighter πŸ’…


πŸ“ EXAMPLE πŸ“

/* Simple directory listing -- no error checking */
#include <ownetapi.h>
char * buf;
size_t s ;
OWNET_init("localhost:4304");
OWNET_dirlist("/",&buf,&s) ;
printf("Directory %s0,buf);
free(buf);
OWNET_finish() ;

look at her go πŸ₯Ή


πŸ‘‘ SEE ALSO πŸ‘‘

πŸŽ€ Programs

  • owfs (1)
  • owhttpd (1)
  • owftpd (1)
  • owserver (1)
  • owdir (1)
  • owread (1)
  • owwrite (1)
  • owpresent (1)
  • owtap (1)

πŸŽ€ Configuration and testing

  • owfs (5)
  • owtap (1)
  • owmon (1)

πŸŽ€ Language bindings

  • owtcl (3)
  • owperl (3)
  • owcapi (3)

πŸŽ€ Clocks

  • DS1427 (3)
  • DS1904 (3)
  • DS1994 (3)
  • DS2404 (3)
  • DS2404S (3)
  • DS2415 (3)
  • DS2417 (3)

πŸŽ€ ID

  • DS2401 (3)
  • DS2411 (3)
  • DS1990A (3)

πŸŽ€ Memory

  • DS1982 (3)
  • DS1985 (3)
  • DS1986 (3)
  • DS1991 (3)
  • DS1992 (3)
  • DS1993 (3)
  • DS1995 (3)
  • DS1996 (3)
  • DS2430A (3)
  • DS2431 (3)
  • DS2433 (3)
  • DS2502 (3)
  • DS2506 (3)
  • DS28E04 (3)
  • DS28EC20 (3)

πŸŽ€ Switches

  • DS2405 (3)
  • DS2406 (3)
  • DS2408 (3)
  • DS2409 (3)
  • DS2413 (3)
  • DS28EA00 (3)

πŸŽ€ Temperature

  • DS1822 (3)
  • DS1825 (3)
  • DS1820 (3)
  • DS18B20 (3)
  • DS18S20 (3)
  • DS1920 (3)
  • DS1921 (3)
  • DS1821 (3)
  • DS28EA00 (3)
  • DS28E04 (3)

πŸŽ€ Humidity

  • DS1922 (3)

πŸŽ€ Voltage

  • DS2450 (3)

πŸŽ€ Resistance

  • DS2890 (3)

πŸŽ€ Multifunction (current, voltage, temperature)

  • DS2436 (3)
  • DS2437 (3)
  • DS2438 (3)
  • DS2751 (3)
  • DS2755 (3)
  • DS2756 (3)
  • DS2760 (3)
  • DS2770 (3)
  • DS2780 (3)
  • DS2781 (3)
  • DS2788 (3)
  • DS2784 (3)

πŸŽ€ Counter

  • DS2423 (3)

πŸŽ€ LCD Screen

  • LCD (3)
  • DS2408 (3)

πŸŽ€ Crypto

  • DS1977 (3)

πŸŽ€ Pressure

  • DS2406 (3) -- TAI8570

🌟 AVAILABILITY 🌟

http://www.owfs.org β€” go visit, she's iconic. 🌐


πŸ’– AUTHOR πŸ’–

Paul Alfille (paul.alfille@gmail.com) β€” the legend herself. πŸ‘‘


okay that's the whole page bestie, you're officially literate in OWNET(1) now 🧚✨ this edition came from the OWFS Manpage, 2008 and honestly? it ate. mwah πŸ’‹