NAME

USB::Descriptor::Device - USB Device Descriptor

VERSION

Version 1

SYNOPSIS

An object representation of a USB device descriptor.

use USB::Descriptor::Device;

my $device = USB::Descriptor::Device->new( product => 'My First Device' );
$device->vendorID(0x1234);
$device->productID(0x5678);
$device->configurations( [ USB::Descriptor::Configuration->new() ] );
...

DESCRIPTION

USB::Descriptor::Device represents a USB device descriptor. After creating and configuring an instanace of USB::Descriptor::Device, arrayification (or $device-bytes>) yeilds an array of all of the values that comprise the fields of a USB Device Descriptor structure given the configured settings. The resulting array can then be used to generate the structures (in Assembly or C or...) necessary for building the firmware of the described device.

After adding one or more USB::Descriptor::Configuration objects to an instance of USB::Descriptor::Device, it can be used to generate USB Configuration Descriptors. Arrayifying each child descriptor in the configurations array yields the appropriate descriptor bytes, including interfaces and endpoints.

Strings specificed for the device descriptor (manufacturer, product or serial number) as well as the strings for child descriptors (configuration, interface, etc) will be automatically indexed by USB::Descriptor::Device and the proper indexes embedded in the appropriate descriptors during arrayification.

After arrayifying the USB::Descriptor::Device and all child USB::Descriptor::Configurations, the generated set of strings can be retrieved (in index order) by calling the 'strings' method.

CONSTRUCTOR

$device = USB::Descriptor::Device->new(vendorID=>$vendorID, ...);

Constructs and returns a new USB::Descriptor::Device object using the passed options. Each option key is the name of an accessor method.

Arrayification

$device->bytes (or @{$device} )

Returns an array of bytes containing all of the fields in the device descriptor fields, but not including configuration descriptors.

ATTRIBUTES

$device->class

Get/Set the device class code (bDeviceClass).

$device->configurations

Get/Set the array of USB::Descriptor::Configuration objects.

$device->manufacturer

Get/Set the device's manufacturer string. A string descriptor index (iManufacturer) will be automatically assigned during arrayification.

$device->max_packet_size

Get/Set the maximum packet size for endpoint 0 (bMaxPacketSize). Valid values are 8, 16, 32, 64. Defaults to 8.

$device->product

Get/Set the device's product string. A string descriptor index (iProduct) will be automatically assigned during arrayification.

$device->productID

Get/Set the device's Product ID (idProduct).

$device->protocol

Get/Set the device's protocol (bDeviceProtocol).

$device->serial_number

Get/Set the device's serial number string. A string descriptor index (iSerialNumber) will be automatically assigned during arrayification.

$device->subclass

Get/Set the device's SubClass (bDeviceSubClass).

$device->usb_version

Get/Set the supported USB version (bcdUSB). The version is specified as a dotted string. eg. '1.2.3'. Defaults to '2.0.0'.

$device->vendorID

Get/Set the device's Vendor ID (idVendor).

$device->version

Get/Set the device's version number (bcdDevice). The version is specified as a dotted string. eg. '1.2.3'.

AUTHOR

Brandon Fosdick, <bfoz at bfoz.net>

BUGS

Please report any bugs or feature requests to bug-usb-descriptor-device at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=USB-Descriptor-Device. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc USB::Descriptor::Device

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright 2011 Brandon Fosdick.

This program is released under the terms of the BSD License.