device::usb::pcsensor::hidtemper(3pm) [debian man page]
Device::USB::PCSensor::HidTEMPer(3pm) User Contributed Perl Documentation Device::USB::PCSensor::HidTEMPer(3pm)NAME
Device::USB::PCSensor::HidTEMPer - Device overview
VERSION
Version 0.02
SYNOPSIS
Shared code:
use Device::USB::PCSensor::HidTEMPer;
my $pcsensor = Device::USB::PCSensor::HidTEMPer->new();
Single-device systems:
my $device = $pcsensor->device();
print $device->external()->fahrenheit() if defined $device->external();
Multi-device systems:
my @devices = $pcsensor->list_devices();
foreach my $device ( @devices ){
print $device->internal()->celsius() if defined $device->internal();
}
DESCRIPTION
This module is a simplified interface to the HidTEMPer thermometers created by PCSensor. It hides any problems recognizing the correct
objects to initialize and the dependency on Device::USB. Use of the connected thermometers can be done by either creating a array of
objects if multiple devices are connected, or the function device() if only one device is present.
One example of its usage can be found in the Linux Journal August 2010, "Cool Projects edition" page 32-34.
CONSTANTS
The following constants are declared
o PRODUCT_ID
Contains the hex value of the product id on the usb chip, in this case 0x660c
o VENDOR_ID
Contains the hex value representing the manufacturer of the chip, in this case "Tenx Technology, Inc."
o SUPPORTED_DEVICES
Contains the mapping between name and identifiers for all supported thermometers.
Hex value Product Internal sensor External sensor
0x5b HidTEMPerNTC Yes Yes
0x58 HidTEMPer Yes No
METHODS
o new()
Initialize the system, and the USB-connection to be used.
o device()
Return a single thermometer instance. ONLY to be used in systems using a single thermometer device. Returns undef if no devices was
found.
o list_devices()
Returns an array of recognized thermometer instances if an array value is expected, otherwise it returns a scalar with the number of
devices found.
DEPENDENCIES
This module internally includes and takes use of the following packages:
use Device::USB;
use Device::USB::PCSensor::HidTEMPer::Device;
use Device::USB::PCSensor::HidTEMPer::NTC;
use Device::USB::PCSensor::HidTEMPer::TEMPer;
This module uses the strict and warning pragmas.
BUGS
Please report any bugs or missing features using the CPAN RT tool.
FOR MORE INFORMATION
None
AUTHOR
Magnus Sulland < msulland@cpan.org >
ACKNOWLEDGEMENTS
None
COPYRIGHT & LICENSE
Copyright (c) 2010 Magnus Sulland
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.10.1 2010-07-24 Device::USB::PCSensor::HidTEMPer(3pm)
Check Out this Related Man Page
Device::USB(3pm) User Contributed Perl Documentation Device::USB(3pm)NAME
Device::USB - Use libusb to access USB devices.
VERSION
Version 0.35
SYNOPSIS
Device::USB provides a Perl wrapper around the libusb library. This supports Perl code controlling and accessing USB devices.
use Device::USB;
my $usb = Device::USB->new();
my $dev = $usb->find_device( $VENDOR, $PRODUCT );
printf "Device: %04X:%04X
", $dev->idVendor(), $dev->idProduct();
$dev->open();
print "Manufactured by ", $dev->manufacturer(), "
",
" Product: ", $dev->product(), "
";
$dev->set_configuration( $CFG );
$dev->control_msg( @params );
...
See the libusb manual for more information about most of the methods. The functionality is generally the same as the libusb function whose
name is the method name prepended with "usb_".
DESCRIPTION
This module provides a Perl interface to the C library libusb. This library supports a relatively full set of functionality to access a USB
device. In addition to the libusb, functioality, Device::USB provides a few convenience features that are intended to produce a more Perl-
ish interface.
These features include:
o Using the library initializes it, no need to call the underlying usb_init function.
o Object interface reduces namespace pollution and provides a better interface to the library.
o The find_device method finds the device associated with a vendor id and product id and creates an appropriate Device::USB::Device
object to manipulate the USB device.
o Object interfaces to the bus and device data structures allowing read access to information about each.
Device::USB
This class provides an interface to the non-bus and non-device specific functions of the libusb library. In particular, it provides
interfaces to find busses and devices. It also provides convenience methods that simplify some of the tasks above.
CONSTANTS
This class provides a set of constants for the defined device classes. The constants defined at this time are:
o CLASS_PER_INSTANCE
o CLASS_AUDIO
o CLASS_COMM
o CLASS_HID
o CLASS_PRINTER
o CLASS_MASS_STORAGE
o CLASS_HUB
o CLASS_DATA
o CLASS_VENDOR_SPEC
FUNCTIONS
new Create a new Device::USB object for accessing the library.
debug_mode
This class method enables low-level debugging messages from the library interface code.
level
0 disables debugging, 1 enables some debug messages, and 2 enables verbose debug messages
Any other values are forced to the nearest endpoint.
find_busses
Returns the number of changes since previous call to the function: the number of busses added or removed.
find_devices
Returns the number of changes since previous call to the function: the number of devices added or removed. Should be called after
find_busses.
find_device
Find a particular USB device based on the vendor and product ids. If more than one device has the same product id from the same vendor,
the first one found is returned.
vendor
the vendor id
product
product id for that vendor
returns a device reference or undef if none was found.
find_device_if
Find a particular USB device based on the supplied predicate coderef. If more than one device would satisfy the predicate, the first
one found is returned.
pred
the predicate used to select a device
returns a device reference or undef if none was found.
list_devices
Find all devices matching a vendor id and optional product id. If called with no parameters, returns a list of all devices. If no
product id is given, returns all devices found with the supplied vendor id. If a product id is given, returns all devices matching both
the vendor id and product id.
vendor
the optional vendor id
product
optional product id for that vendor
returns a list of devices matching the supplied criteria or a reference to that array in scalar context
list_devices_if
This method provides a more flexible interface for finding devices. It takes a single coderef parameter that is used to test each
discovered device. If the coderef returns a true value, the device is returned in the list of matching devices, otherwise it is not.
pred
coderef to test devices.
For example,
my @devices = $usb->list_devices_if(
sub { Device::USB::CLASS_HUB == $_->bDeviceClass() }
);
Returns all USB hubs found. The device to test is available to the coderef in the $_ variable for simplicity.
list_busses
Return the complete list of information after finding busses and devices.
By using this function, you do not need to do the find_* calls yourself.
returns a reference to an array of busses.
get_busses
Return the complete list of information after finding busses and devices.
Before calling this function, remember to call find_busses and find_devices.
returns a reference to an array of busses.
DIAGNOSTICS
This is an explanation of the diagnostic and error messages this module can generate.
DEPENDENCIES
This module depends on the Carp, Inline and Inline::C modules, as well as the strict and warnings pragmas. Obviously, libusb must be
available since that is the entire reason for the module's existence.
AUTHOR
G. Wade Johnson (wade at anomaly dot org) Paul Archer (paul at paularcher dot org)
Houston Perl Mongers Group
Original author: David Davis
BUGS
Please report any bugs or feature requests to "bug-device-usb@rt.cpan.org", or through the web interface at
<http://rt.cpan.org/NoAuth/ReportBug.html?Device::USB>. I will be notified, and then you'll automatically be notified of progress on your
bug as I make changes.
FOR MORE INFORMATION
The project is hosted at Google Code http://code.google.com/p/perl-device-usb/ <http://code.google.com/p/perl-device-usb/>. More
information on the project, including installation help is available on the Wiki.
LIMITATIONS
So far, this module has only been tested on Linux. It should work on any OS that supports the libusb library. Several people have reported
problems compiling the module on Windows. In theory, it should be possible to make the library work with LibUsb-Win32
http://libusb-win32.sourceforge.net/ <http://libusb-win32.sourceforge.net/>. Without access to a Windows development system, I can't make
those changes.
The Interfaces and Endpoints are not yet proper objects. The code to extract this information is not yet written.
ACKNOWLEDGEMENTS
Thanks go to various members of the Houston Perl Mongers group for input on the module. But thanks mostly go to Paul Archer who proposed
the project and helped with the development.
Thanks to Josep MonA~Xs Teixidor for fixing the "bInterfaceClass" bug.
Thanks to Mike McCauley for support of "usb_get_driver_np" and "usb_detach_kernel_driver_np".
Thanks to Vadim Mikhailov for fixing a compile problem with VC6 on Windows and then chipping in again for VS 2005 on Windows, and yet again
to fix warnings on C99-compliant compilers.
Thanks to John R. Hogheruis for information about modifying the Inline parameters for compiling with Strawberry Perl on Windows.
Thanks to Tony Shadwick for helping me resolve a problem with bulk_read and interrupt_read.
COPYRIGHT & LICENSE
Copyright 2006-2009 Houston Perl Mongers
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.14.2 2011-11-15 Device::USB(3pm)