Device::USB::PanicButton - interface to USB Panic Button
use Device::USB::PanicButton; my $pbutton = Device::USB::PanicButton->new(); if(!$pbutton || $pbutton->error()) { printf(STDERR "FATAL: ". $pbutton->error() ."\n"); exit(-1); } while(1) { my $result = $pbutton->pressed(); if($result == 1) { printf("PANIC ;)\n"); } elsif($result < 0) { printf(STDERR "WARN: ". $pbutton->error() ."\n"); } sleep(1); }
This implements a basic interface to the toy USB Panic Button by reading out the button status.
http://www.firebox.com/product/1742/USB-Panic-Button
It has three methods - new(), error() and pressed().
new() returns always an object - you have to check for errors with error().
error() returns a scalar with an error message, if something hit an error.
pressed() returns:
-1, if something went wrong during reading the device. 0, if the button was not pressed. 1, if the button was pressed since last read process.
libusb -> http://libusb.sourceforge.net Device::USB -> http://search.cpan.org/search?query=Device-USB
see README for complete install instruction for Debian Etch.
Benjamin Kendinibilir <cpan at kendinibilir.de>
Copyright (C) 2008 by Benjamin Kendinibilir. All Rights Reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
Device::USB
To install Device::USB::PanicButton, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Device::USB::PanicButton
CPAN shell
perl -MCPAN -e shell install Device::USB::PanicButton
For more information on module installation, please visit the detailed CPAN module installation guide.