Name : perl-USB-Descriptor
| |
Version : 4
| Vendor : obs://build_opensuse_org/devel:languages:perl
|
Release : lp155.1.1
| Date : 2023-07-20 15:53:10
|
Group : Development/Libraries/Perl
| Source RPM : perl-USB-Descriptor-4-lp155.1.1.src.rpm
|
Size : 0.12 MB
| |
Packager : https://www_suse_com/
| |
Summary : USB Device Descriptor generation tools
|
Description :
the USB::Descriptor manpage provides a means of specifying a device\'s USB descriptors and then generating descriptor structures suitable for use in the device\'s firmware. However, the USB::Descriptor manpage only generates the bytes that comprise the structures, it does not handle generation of valid source code.
Any strings used in the descriptor set are automatically assigned indexes and collected into a set of string descriptors by the top level the USB::Descriptor::Device manpage object.
The easiest way to create a new descriptor set is to use the the USB::Descriptor::device() manpage factory method. It accepts a hash of arguments that happens to be the same hash expected by the USB::Descriptor::Device manpage and returns a reference to a new the USB::Descriptor::Device manpage object.
use USB::Descriptor;
my $device = USB::Descriptor::device( \'usb_version\' => \'2.0.0\', # Default \'max_packet_size\' => 64, # Full speed device \'vendorID\' => 0x1234, \'productID\' => 0x5678, \'manufacturer\' => \'Acme, Inc.\', \'product\' => \'Giant Catapult\', \'serial_number\' => \'007\', \'configurations\' => [{ \'description\' => \'Configuration 0\', \'remote_wakeup\' => 1, \'max_current\' => 100, # mA \'interfaces\' => [{ \'description\' => \'Interface 0\', \'endpoints\' => [{ \'direction\' => \'in\', \'number\' => 1, \'max_packet_size\' => 42, }], }], }, );
The code above generates a the USB::Descriptor::Device manpage object as well as a the USB::Descriptor::Configuration manpage, a the USB::Descriptor::Interface manpage and a single the USB::Descriptor::Endpoint manpage. Each descriptor object is configured using the provided arguments and added to the descriptor tree.
Values for the device descriptor structure can be obtained by calling \'$device->bytes\', or by using arrayification ( \'AATT{$device}\' ).
my AATTbytes = $device->bytes
or
my AATTbytes = AATT{$device};
A simple script can then be written to emit the device descriptor structure in whatever language is appropriate to the device\'s project. For example, to store the descriptor as an array of bytes for a *C* language project...
print \"uint8_t device_descriptor[] = {\", join(\', \', AATTbytes), \"};\ \";
Calling \'bytes\' on a the USB::Descriptor::Configuration manpage object, or arrayifying it, produces a similar result. However, the configuration object returns more than a configuration descriptor worth of values. It returns the concatenated set of configuration, interface and endpoint descriptors that is requested by a USB host during device enumeration. Generating suitable *C* source might be accomplished with:
my AATTconfigurations = AATT{$device->configurations}; foreach my $configuration ( AATTconfigurations ) { print \'uint8_t configuration[] = {\', join(\', \', AATT{$configuration->bytes} ), \"}\ \"; }
When calling \'bytes\', or arrayifying a the USB::Descriptor::Device manpage, all of the child objects are queried for their strings. The resulting strings are automatically assigned string indexes and assembled into a string descriptor set. The set of assembled strings can be retrieved as an array, in index order, by calling \'$device->strings\'. The first string in the array is the string that should be returned by the device in response to a request for string ID 1.
my AATTstrings = $device->strings
Suitable language-specific code can then be generated from the resulting array of strings.
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl:/CPAN-U/15.5/noarch |