USB::Device Class Reference
Class representing a Device on the Bus. More...
#include <usbpp.h>
Inherits list.
Public Member Functions | |
std::string | fileName (void) |
OS representation of filename for this device. | |
u_int16_t | idVendor (void) |
The vendor ID number, as provided by the device. | |
u_int16_t | idProduct (void) |
The product ID number, as provided by the device. | |
u_int16_t | idRevision (void) |
The product's revision ID, as provided by the device. | |
u_int8_t | devClass (void) |
The device's USB class, as provided by the device. | |
u_int8_t | devSubClass (void) |
The device's USB subclass, as provided by the device. | |
u_int8_t | devProtocol (void) |
The device's USB protocol, as provided by the device. | |
std::string | Vendor (void) |
The vendor name string, as provided by the device. | |
std::string | Product (void) |
The product name string, as provided by the device. | |
std::string | SerialNumber (void) |
The serial number string, as provided by the device. | |
u_int8_t | numConfigurations (void) |
Number of Configurations that this device has. | |
int | string (std::string &buf, int index, u_int16_t lang=0) |
fetch an arbitrary string from the device | |
Configuration * | firstConfiguration (void) |
First Configuration for the Device. | |
Configuration * | nextConfiguration (void) |
Next Configuration for the Device. | |
Configuration * | lastConfiguration (void) |
Last Configuration for the Device. | |
int | controlTransfer (u_int8_t requestType, u_int8_t request, u_int16_t value, u_int16_t index, u_int16_t length, unsigned char *payload, int timeout=100) |
USB control transfer. | |
Friends | |
class | Busses |
Busses is a friend because it fills in the descriptor type information on initialisation and rescan. | |
class | Interface |
Interface is a friend because it needs the handle() function to perform claim(), release(). | |
class | Endpoint |
Endpoint is a friend because it needs the handle() function to perform reads, writes, and other transactions. |
Detailed Description
Class representing a Device on the Bus.The Device class represents a single device attached to a Universal Serial Bus.
Definition at line 407 of file usbpp.h.
Member Function Documentation
std::string USB::Device::fileName | ( | void | ) |
OS representation of filename for this device.
libusb++ provides a uniform way of accessing USB devices irrespective of the underlying Operation System representation. If you want to map the libusb++ representation to the Operating System representation, you can do this with filename().
On Linux, the filename is usually something like 002, which represents the second device (usually the first real device, after the root hub pseudo-device) on the bus.
- See also:
- Bus::directoryName()
u_int16_t USB::Device::idVendor | ( | void | ) |
The vendor ID number, as provided by the device.
This method returns a number containing the vendor (manufacturer) identification number. These are allocated by the USB Implementers Forum, and you can construct a lookup based on the number to get the manufacturer's name, even if the device does not contain a vendor string.
- See also:
- Vendor()
Definition at line 233 of file usbpp.cpp.
Referenced by USB::Busses::match().
u_int16_t USB::Device::idProduct | ( | void | ) |
The product ID number, as provided by the device.
This method returns a number containing the product identification number. These are allocated by the manufacturer, and should be different on each device.
- See also:
- Product()
Definition at line 238 of file usbpp.cpp.
Referenced by USB::Busses::match().
u_int16_t USB::Device::idRevision | ( | void | ) |
The product's revision ID, as provided by the device.
This method returns a number containing the product's revision. This revision level is nominally binary coded decimal, but hexadecimal revision levels are not uncommon. The binary coded decimal version nominally has a major version in the high byte, and a minor version in the low byte.
u_int8_t USB::Device::devClass | ( | void | ) |
The device's USB class, as provided by the device.
This method returns a number containing the device's class. These are defined by the USB Implementer's Forum.
A code of Zero is special (and common) - it means that the class is found in the Interface descriptor, rather than in the Device descriptor.
A code of 0xFF is also special (and far too common) - it means that the manufacturer didn't conform to one of the defined class specifications, and chose to implement a vendor specified protocol.
Definition at line 248 of file usbpp.cpp.
Referenced by USB::Busses::match().
u_int8_t USB::Device::devSubClass | ( | void | ) |
u_int8_t USB::Device::devProtocol | ( | void | ) |
std::string USB::Device::Vendor | ( | void | ) |
The vendor name string, as provided by the device.
This method returns a string containing the name of the device's vendor (manufacturer), as encoded into the device.
Note that not all devices contain a vendor name, and also that under some operating systems you may not be able to read the vendor name without elevated privledges (typically root privledges).
- See also:
- idVendor()
std::string USB::Device::Product | ( | void | ) |
The product name string, as provided by the device.
This method returns a string containing the name of the device's product name, as encoded into the device.
Note that not all devices contain a product name, and also that under some operating systems you may not be able to read the vendor name without elevated privledges (typically root privledges).
- See also:
- idProduct()
std::string USB::Device::SerialNumber | ( | void | ) |
The serial number string, as provided by the device.
This method returns a string containing a serial number for the device, as encoded into the device.
Note that few devices contain a serial number string, and also that under some operating systems you may not be able to read the serial number without elevated privledges (typically root privledges). The USB specification requires that serial numbers are unique if they are provided, but adherence to this requirement by manufacturers is not universal.
u_int8_t USB::Device::numConfigurations | ( | void | ) |
Number of Configurations that this device has.
This is a simple accessor method that specifies the number configurations that this device has.
Definition at line 298 of file usbpp.cpp.
Referenced by USB::Busses::rescan().
int USB::Device::string | ( | std::string & | buf, | |
int | index, | |||
u_int16_t | lang = 0 | |||
) |
fetch an arbitrary string from the device
- Parameters:
-
string the string from the device. You can typically pass in an empty string for this. index the index of the string required lang the language ID to use. Defaults to using the first language ID.
- Returns:
- length of string, or 0 on error.
Definition at line 179 of file usbpp.cpp.
Referenced by USB::Busses::rescan().
Configuration * USB::Device::firstConfiguration | ( | void | ) |
First Configuration for the Device.
This method returns a pointer to the first Configuration for the Device.
See nextConfiguration() for an example of how it might be used.
Configuration * USB::Device::nextConfiguration | ( | void | ) |
Next Configuration for the Device.
This method returns a pointer to the next Configuration for the Device.
If you want to iterate through each Configuration on a device, you can use something like the following:
USB::Configuration *this_Configuration; this_Configuration = device->firstConfiguration(); for (i=0; i < device->numConfigurations(); i++) { // do something with this_Configuration this_Configuration->nextConfiguration(); }
Configuration * USB::Device::lastConfiguration | ( | void | ) |
Last Configuration for the Device.
This method returns a pointer to the last Configuration for the Device.
int USB::Device::controlTransfer | ( | u_int8_t | requestType, | |
u_int8_t | request, | |||
u_int16_t | value, | |||
u_int16_t | index, | |||
u_int16_t | length, | |||
unsigned char * | payload, | |||
int | timeout = 100 | |||
) |
USB control transfer.
This method performs a standard control transfer to the default endpoint. See the USB specification for more details on this.
- Parameters:
-
requestType corresponds to the bmRequestType field in the transfer request corresponds to the bRequest field in the transfer value corresponds to the wValue field in the transfer index corresponds to the wIndex field in the transfer length corresponds to the wLength field in the transfer payload corresponds to the data phase of a control transfer timeout is the timeout period for the control transfer, in milliseconds
- Returns:
- number of bytes sent or received, or a negative number in case of error.
Friends And Related Function Documentation
friend class Busses [friend] |
friend class Interface [friend] |
friend class Endpoint [friend] |
The documentation for this class was generated from the following files: