OWFS SF.net project page New OWFS Website! by Paul H Alfille SourceForge.net Logo
OWFS Design
overview
components
naming
cache
arrays
performance

OWFS Features
cache
statistics

OWFS Software
Install instructions
Bootable CD
Filesystem (owfs)
Web Server (owhttpd)
Backend Server (owserver)
Perl bindings (owperl)
Python bindings (owpython)
PHP bindings (owphp)
Tcl bindings (owtcl)
Download
Daily Configured Package
CVS -- newest
CVS Statistics
FAQ
Examples & Usage
1-wire wireless
1-Wire Hardware
OWFS Project

Shell hints

How to use the command line and OWFS together.


There are more code examples on the statistics page.
  • Show the BUS structure.

    Use the tree command.
    tree -a /mnt/1wire
    1wire/
    |-- 09.F05C88010000
    | |-- address
    | |-- crc8
    | |-- family
    | |-- id
    | |-- memory
    | |-- page.0
    | |-- page.1
    | |-- page.2
    | |-- page.3
    | |-- present
    | `-- type
    |-- 10.D11846000800
    | |-- address
    | |-- crc8
    | |-- family
    | |-- id
    | |-- present
    | |-- scratchpad
    | |-- temperature
    | `-- type
    |-- 24.50AC02000000
    | |-- address
    | |-- counter
    | |-- crc8
    | |-- date
    | |-- family
    | |-- flags
    | |-- id
    | |-- present
    | |-- running
    | `-- type
    |-- 26.3D3A15000000
    | |-- VAD
    | |-- VDD
    | |-- address
    | |-- crc8
    | |-- family
    | |-- humidity
    | |-- id
    | |-- page.0
    | |-- page.1
    | |-- page.2
    | |-- page.3
    | |-- page.4
    | |-- page.5
    | |-- page.6
    | |-- page.7
    | |-- present
    | |-- temperature
    | `-- type
    |-- 26.804215000000
    | |-- VAD
    | |-- VDD
    | |-- address
    | |-- crc8
    | |-- family
    | |-- humidity
    | |-- id
    | |-- page.0
    | |-- page.1
    | |-- page.2
    | |-- page.3
    | |-- page.4
    | |-- page.5
    | |-- page.6
    | |-- page.7
    | |-- present
    | |-- temperature
    | `-- type
    `-- DS9097U
    |-- address
    |-- port
    `-- version

  • Show the name of all files of a certain type.

    Use ls
    for example to see all the temperature files:
    ls -1 1wire/*/temp*
    1wire/10.D11846000800/temperature
    1wire/26.3D3A15000000/temperature
    1wire/26.804215000000/temperature

  • Show the name and value of all files of a certain type.

    Use grep '.'
    for example to see all the types:
    grep '.' 1wire/*/type
    1wire/09.F05C88010000/type:DS2502
    1wire/10.D11846000800/type:DS1820
    1wire/24.50AC02000000/type:DS2415
    1wire/26.3D3A15000000/type:DS2438
    1wire/26.804215000000/type:DS2438
    to see all the temperatures:
     grep '.' 1wire/*/temperature
    1wire/10.D11846000800/temperature: 19.8125
    1wire/26.3D3A15000000/temperature: 19.4062
    1wire/26.804215000000/temperature: 19.4062

  • More controlled display of information.

    Use a bash 'for' loop on a file list. Note the use of various form of sub-command execution : deprecated back-ticks `command` and easier to match $(command).
    An example to show addresses and corresponding temperatures:
    X=$(ls 1wire/*/temperature); for f in $X; do d=$(dirname $f); echo "$(cat $d/address): $(cat $f)C"; done
    10D11846000800D5: 20.0000C
    263D3A1500000046: 19.6250C
    2680421500000058: 19.7188C
    Lets break it down:
    First the file list.
    X=`ls 1wire/*/temperature`; echo $X
    1wire/10.D11846000800/temperature 1wire/26.3D3A15000000/temperature 1wire/26.804215000000/temperature
    Now loop through that list, applying dirname to get the device directory.
    for f in $X; do echo "$f -> $(dirname $f)"; done
    1wire/10.D11846000800/temperature -> 1wire/10.D11846000800
    1wire/26.3D3A15000000/temperature -> 1wire/26.3D3A15000000
    1wire/26.804215000000/temperature -> 1wire/26.804215000000

  • Turn on a switch in the DS2406.

    Write to the PIO file
    (Display the value before and after).
    cat 1wire/12.C4DF1F000000/PIO_A
    echo "1" > 1wire/12.C4DF1F000000/PIO_A
    cat 1wire/12.C4DF1F000000/PIO_A
    01

  • Playing with the LCD.

    Turn on the LCD (all of them)
    Show some text.
    Then flash the backlight 3 times.
    echo "1" > 1wire/FF*/LCDon
    echo "OWFS test program" > 1wire/FF*/screen16

    OWFS test program
    Turn on the backlight
    echo "1" > /1wire/FF.3D0100000100/backlight

    Flash the backlight 3 tiimes
    for x in {1 0 1 0 1 0} do echo $x > > /1wire/FF.3D0100000100/backlight ; sleep 1 ; done

    Turn on the backlight
    echo "1" > /1wire/FF.3D0100000100/backlight

    Show the date on the LCD:
    date> 1wire/FF*/screen16
    Date in an LCD screen
    Now, let's be really fancy! Loop through the temp and date:
    (Take advantage of the slow temperature conversion to show the date
    or temperature longer.)
    while `true` ; do \
     x=`ls 1wire/*/temperature` ; \
     for f  in $x ; do \
      t=`cat $f`C ; \
      echo "0" > 1wire/FF.3D0100000100/backlight ; \
      echo "Temperature" > 1wire/FF.3D0100000100/line16.0 ; \
      echo $t > 1wire/FF.3D0100000100/line16.1 ; \
      echo "1" > 1wire/FF.3D0100000100\/backlight ; \
     done ; \
     sleep 1 ; \
     echo "0" > 1wire/FF.3D0100000100/backlight ; \
     date > 1wire/FF.3D0100000100/screen16 ; \
     echo "1" > 1wire/FF.3D0100000100/backlight ; \
    done

    Temperature in an LCD screen

© 2003 Paul H. Alfille and The owfs Team
$Id: shell_hints.html,v 1.12 2004/10/14 01:44:10 alfille Exp $