NAME
Hardware::iButton - talk to DalSemi iButtons via a DS2480 serial widget
SYNOPSIS
use Hardware::iButton::Connection;
$c = new Hardware::iButton::Connection "/dev/ttyS0";
@b = $c->scan();
foreach $b (@b) {
print "family: ",$b->family(), "serial number: ", $b->serial(),"\n";
print "id: ",$b->id(),"\n"; # id = family . serial . crc
print "reg0: ",$b->readreg(0),"\n";
}
DESCRIPTION
This module talks to iButtons via the "active" serial interface (anything using the DS2480, including the DS1411k and the DS 9097U). It builds up a list of devices available, lets you read and write their registers, etc.
The connection object is an Hardware::iButton::Connection. The main user-visible purpose of it is to provide a list of Hardware::iButton::Device objects. These can be subclassed once their family codes are known to provide specialized methods unique to the capabilities of that device. Those devices will then be Hardware::iButton::Device::DS1920, etc.
iButtons and solder-mount Touch Memory devices are each identified with a unique 64-bit number. This is broken up into 8 bits of a "family code", which specifies the part number (and consequently the capabilities), then 48 bits of device ID (which Dallas insures is globally unique), then 8 bits of CRC. When you pass these IDs to and from this package, use hex strings like "0123456789ab".
AUTHOR
Brian Warner, warner@lothar.com
SEE ALSO
http://www.ibutton.com, http://sof.mit.edu/ibuttonpunks/
new
$c = new Hardware::iButton::Connection "/dev/ttyS0";
Creates a new Hardware::iButton::Connection object by opening the given serial port and attempting to communicate with a DS2480 chip.
reset
$status = $c->reset();
resets the One-Wire bus. Returns a status code: 0: bus shorted 1: presence pulse: at least one device is present on the bus 2: alarming presence pulse: at least one device is alarmed 3: no presence pulse: there are no devices on the bus
scan
@buttons = $c->scan();
@buttons = $c->scan($family_code);
$button = $c->scan($family_code, $serial);
scans the One-Wire bus with the ROM Search command and builds up a list of all devices present. Hardware::iButton::Device objects are created for each, and an array of these objects is returned. If a family code is given, the search is restricted to devices of that family type. If a serial number is given (which must be a 12 character string), then the bus is searched for that one particular device (family code plus id) and, if present, an object is returned for it.
If no buttons match the search criteria (or none are present), an empty list or undef is returned.
readrom
@id = $c->readrom(); # FIXME
Run a Read ROM command on the bus, and return the 8 bytes that result as a string of 16 hex chars. This command is only useful if there is exactly 1 device on the bus. This is rarely the case, since most containers of DS2480 chips have solder-mount touch memory devices already on the bus (the 1411k seems to have a DS2401 id-only device on it, and the DS9097U appears to have a DS2502 1k add-only eprom in it).