Public Types | |
enum | USBDevState { StateStreaming , StateSuspending , StateSuspended , StateResuming } |
enum | usbdev_suspend_phase_t { kSuspendPhaseSuspend = 0u , kSuspendPhaseSleepResume , kSuspendPhaseSleepReset , kSuspendPhaseSleepDisconnect , kSuspendPhaseDeepResume , kSuspendPhaseDeepReset , kSuspendPhaseDeepDisconnect , kSuspendPhaseShutdown } |
Test phases; named according to the event that we are expecting to occur. More... | |
enum | usb_testutils_test_number { kUsbTestNumberSmoke = 0 , kUsbTestNumberStreams , kUsbTestNumberIso , kUsbTestNumberMixed , kUsbTestNumberSuspend , kUsbTestNumberExc } |
enum | usbdev_stream_flags_t { kUsbdevStreamFlagID = 0x0FU , kUsbdevStreamFlagRetrieve = 0x10U , kUsbdevStreamFlagCheck = 0x20U , kUsbdevStreamFlagRetry = 0x40U , kUsbdevStreamFlagSend = 0x80U , kUsbdevStreamFlagsDefault } |
typedef enum USBDevice::usb_testutils_test_number | usb_testutils_test_number_t |
Public Member Functions | |
USBDevice (bool verbose=false, bool manual=false) | |
bool | Init (uint16_t productID, uint16_t vendorID, uint8_t devAddress=0u, uint8_t busNumber=0u) |
Initialize USB device before test; called once at startup. More... | |
bool | Fin () |
Finalize USB device before completing test. More... | |
bool | Open () |
(Re)open the device. More... | |
bool | Close () |
Close the device, if open. More... | |
bool | Service () |
Service the device; keep libusb transfers being processed. More... | |
bool | ManualControl () const |
Is test progress being directed/controlled manually? | |
usbdev_suspend_phase_t | TestPhase () const |
Returns the current phase of the test. | |
bool | Delay (uint32_t time_us, bool with_traffic=true) |
Delay for at least the requested number of microseconds (wall time); this is important in ensuring the appropriate time intervals (eg. More... | |
bool | ReadTestDesc () |
Read Test Descriptor from the DUT using a Vendor-Specific command. More... | |
uint8_t | TestNumber () const |
Return the test number from the test descriptor. More... | |
uint8_t | TestArg (unsigned arg) const |
Return the specified test argument from the test descriptor. More... | |
bool | Reset () |
Reset and Reconfigure the DUT. More... | |
bool | Suspend () |
Suspend device. More... | |
bool | Resume () |
Resume operation of suspended device. | |
bool | Connect () |
Connect device to the USB. More... | |
bool | Disconnect () |
Disconnect device from the USB. More... | |
USBDevState | CurrentState () const |
Returns the current state of the device. More... | |
void | SetState (USBDevState state) |
Sets the current state of the device in the Suspend/Resume signaling. More... | |
Static Public Member Functions | |
static uint32_t | TimeFrames (unsigned frames) |
Returns microseconds corresponding to the given number of bus frame delays. | |
static const char * | PhaseName (usbdev_suspend_phase_t phase) |
Return the textual name of the specified test phase. More... | |
Definition at line 15 of file usb_device.h.
Definition at line 95 of file usb_device.h.
Test phases; named according to the event that we are expecting to occur.
Definition at line 43 of file usb_device.h.
bool USBDevice::Close | ( | ) |
Close the device, if open.
If the device is already closed, this function just returns immediately.
Definition at line 218 of file usb_device.cc.
bool USBDevice::Connect | ( | ) |
Connect device to the USB.
true | iff the operation was succesful. |
Definition at line 522 of file usb_device.cc.
|
inline |
Returns the current state of the device.
Definition at line 383 of file usb_device.h.
bool USBDevice::Delay | ( | uint32_t | time_us, |
bool | with_traffic = true |
||
) |
Delay for at least the requested number of microseconds (wall time); this is important in ensuring the appropriate time intervals (eg.
Resume Signaling) are met.
For verbose reporting, the also indicates whether traffic is expected, and may be visually paired up with any device-side logging or logic analyzer traces.
time_us | Minimum time delay, in microseconds. |
with_traffic | Indicates whether USB traffic is expected during this time. |
Definition at line 339 of file usb_device.cc.
bool USBDevice::Disconnect | ( | ) |
Disconnect device from the USB.
true | iff the operation was succesful. |
Definition at line 553 of file usb_device.cc.
bool USBDevice::Fin | ( | ) |
Finalize USB device before completing test.
Definition at line 43 of file usb_device.cc.
bool USBDevice::Init | ( | uint16_t | productID, |
uint16_t | vendorID, | ||
uint8_t | devAddress = 0u , |
||
uint8_t | busNumber = 0u |
||
) |
Initialize USB device before test; called once at startup.
vendorID | Vendor ID code of the USB device. |
productID | Product ID code of the USB device. |
devAddress | Device address (0 for first accessible device). |
busNumber | Bus number (if devAddress non-zero). |
Definition at line 21 of file usb_device.cc.
bool USBDevice::Open | ( | ) |
(Re)open the device.
If the device is already open, this function just returns immediately.
Definition at line 56 of file usb_device.cc.
|
static |
Return the textual name of the specified test phase.
phase | Test phase. |
Definition at line 242 of file usb_device.cc.
bool USBDevice::ReadTestDesc | ( | ) |
Read Test Descriptor from the DUT using a Vendor-Specific command.
Definition at line 265 of file usb_device.cc.
bool USBDevice::Reset | ( | ) |
Reset and Reconfigure the DUT.
Definition at line 357 of file usb_device.cc.
bool USBDevice::Service | ( | ) |
Service the device; keep libusb transfers being processed.
Definition at line 230 of file usb_device.cc.
|
inline |
Sets the current state of the device in the Suspend/Resume signaling.
state | The current state of the device. |
Definition at line 389 of file usb_device.h.
bool USBDevice::Suspend | ( | ) |
Suspend device.
Definition at line 397 of file usb_device.cc.
|
inline |
Return the specified test argument from the test descriptor.
arg | Argument number. |
Definition at line 339 of file usb_device.h.
|
inline |
Return the test number from the test descriptor.
Definition at line 332 of file usb_device.h.