Contents Up Previous Next

HiPi::Device::OneWire

This module currently provides a front end to the w1 Kernel device driver. Currently only a simple read function is implemented. Enough to support reading the output of temperature devices.

See : W1 Device Driver

The connected devices on your One Wire bus can be seen in the HiPi Control GUI if you are using the kernel driver.

The following interface module uses HiPi::Device::OneWire as a backend and may contain code that helps with your own usage.

HiPi::Interface::DS18X20

Class Methods

HiPi::Device::OneWire->load_modules( $forceunload );
    Loads the kernel device driver modules for w1 support
    wire
    w1_gpio
    w1_therm

    When $forceunload is true, unloads the kernel modules
    first if they are loaded (effectively forces a reload)

    spidev is loaded with the current bufsiz

    Of course, the user the script is running as must have
    root permissions to load and unload kernel modules.
HiPi::Device::OneWire->unload_modules();
    Unloads the kernel device driver modules for SPI
    wire
    w1_gpio
    w1_therm

    Of course, the user the script is running as must have
    root permissions to load and unload kernel modules.
HiPi::Device::OneWire->list_slaves();
    Returns an array of hash references providing details
    of the connected 1 wire devices.

    the four hash keys are

    id           e.g. 28-00000400bed1
    family       e.g. 28
    name         e.g. 18B20
    description  e.g. programmable resolution digital thermometer

    my @devices = HiPi::Device::OneWire->list_slaves();
    for my $w1 ( @devices ) {
        for ( qw( id family name description ) ) {
	    print qq($_ = $w1->{$_}n); 
        }
    }
HiPi::Device::OneWire->id_exists( $id );
    Returns true or false according to whether the specified
    $id is connected to the kernel device.
HiPi::Device::OneWire->read_data( $id );
    Returns the content of the file
    /sys/bus/w1/devices/$id/w1_slave

    It is up to the caller to parse the content 




Contents Up Previous Next


HiPi Modules Copyright © 2013 Mark Dootson