EasyUSB::Endpoint Class Reference

Represents a USB Data Endpoint. More...

Inheritance diagram for EasyUSB::Endpoint:

EasyUSB::Detail::IOControl EasyUSB::Detail::IO EasyUSB::Detail::IOBase EasyUSB::Detail::IOBase

Public Types

enum  Type { ISOCHRONOUS = 0x01, BULK = 0x02, INTERRUPT = 0x03, UNKNOWN = 0xFF }
 USB Endpoint Types. More...

Public Member Functions

 Endpoint (Device *pDevice, unsigned char Address) throw (Errors::ResourceError, Errors::DeviceLost)
 Default constructor.
AsyncIOFindPacket (unsigned short Status=0xFFF)
 Searches the PacketsDone queue for the next object.
void Flush () throw ()
 Cancels all outstanding requests.
unsigned char GetAddress () throw ()
 Gets the endpoint address.
unsigned int GetDefaultFlags () throw ()
 Gets the default flags for transferring data.
unsigned short GetIsoInterval ()
 Gets the ISO interval from the driver.
unsigned short GetMaxPacketSize ()
 Gets the maximum packet size for a one-packet-transfer.
unsigned long GetTimeout ()
 Gets the current timeout from the driver.
Endpoint::Type GetType () throw ()
 Gets the type of this endpoint.
bool IsINEndpoint () throw ()
 Check if this EP is an IN EP.
bool IsOUTEndpoint () throw ()
 Check if this EP is an OUT EP.
unsigned long NumPacketsDone () throw ()
 Gets the number of packets that have been completed.
unsigned long NumPacketsInProgress () throw ()
 Gets the number of packets currently in the active queue.
Data Read (unsigned long Length)
 Reads data synchronously.
AsyncIOReadAsync (unsigned long Length)
 Reads data asynchronously with default flags.
AsyncIOReadAsync (unsigned long Length, unsigned int Flags)
 Reads data asynchronously.
void RemovePacket (AsyncIO *pAIO)
 Removes the AsyncIO object from the PacketsDone queue.
AsyncIORetrievePacket (unsigned short Status=0xFFFF)
 This is a combined FindPacket and RetrievePacket function.
void RetrievePacket (AsyncIO *pAIO)
 Retrieves the packet from the PacketsDone queue.
void Run ()
 Lets the endpoint process running requests and calls registered callback functions.
void SetDefaultFlags (unsigned int Flags=0) throw ()
 Sets the default flags for transferring data.
void SetInterface (IEndpoint *pInterface) throw ()
 Sets an interface for asynchronous callbacks.
void SetIsoInterval (unsigned short Interval)
 Defines a new interval for delivering ISO packets.
void SetTimeout (unsigned long Timeout)
 Sets the time until the driver aborts its attempt to deliver the request.
AsyncIOWriteAsync (Data Data)
 Writes data asynchronously with default flags.
AsyncIOWriteAsync (Data Data, unsigned int Flags)
 Writes data asynchronously.
 ~Endpoint ()
 Default destructor.

Protected Attributes

unsigned char m_Address
 Endpoint address.
unsigned int m_DefaultFlags
 The default flags for transferring data.
Descriptors::Endpoint m_EPDesc
 Endpoint for this EP.
IEndpointm_pInterface
 The asynchronous callback interface.

Detailed Description

Represents a USB Data Endpoint.

Member Enumeration Documentation

USB Endpoint Types.

Enumerator:
ISOCHRONOUS  Isochronous EP, no error correction.
BULK  Bulk EP, data is resend on error.
INTERRUPT  Interrupt EP with constant data rate and error correction.
UNKNOWN  Unknown EP type.


Constructor & Destructor Documentation

EasyUSB::Endpoint::Endpoint ( Device pDevice,
unsigned char  Address 
) throw (Errors::ResourceError, Errors::DeviceLost)

Default constructor.

Parameters:
pDevice The parent device.
Address The endpoint address.
Exceptions:
ResourceError The endpoint could not be found or there was not enough memory for this operation.
- All exceptions thrown by IoControl

EasyUSB::Endpoint::~Endpoint (  ) 

Default destructor.


Member Function Documentation

AsyncIO* EasyUSB::Endpoint::FindPacket ( unsigned short  Status = 0xFFF  ) 

Searches the PacketsDone queue for the next object.

This function does NOT grant you ownership of the object.

Parameters:
Status If specified, only a packet with the given status is returned.
Returns:
A pointer to an AsyncIO object or 0 if no packet with the specified status could be found.
See also:
RetrievePacket

void EasyUSB::Endpoint::Flush (  )  throw ()

Cancels all outstanding requests.

Exceptions:
- Although this function uses IoControl it will never throw any exception.
Note:
All AsyncIO requests are cancelled and deleted. User application should no longer use AsyncIO pointers.

unsigned char EasyUSB::Endpoint::GetAddress (  )  throw ()

Gets the endpoint address.

Returns:
Endpoint address.

unsigned int EasyUSB::Endpoint::GetDefaultFlags (  )  throw ()

Gets the default flags for transferring data.

Returns:
The default flags.

unsigned short EasyUSB::Endpoint::GetIsoInterval (  ) 

Gets the ISO interval from the driver.

Exceptions:
- Any exception thrown by IoControl.
Returns:
The interval in ms.

unsigned short EasyUSB::Endpoint::GetMaxPacketSize (  ) 

Gets the maximum packet size for a one-packet-transfer.

Returns:
The maximum packet size in bytes.

unsigned long EasyUSB::Endpoint::GetTimeout (  ) 

Gets the current timeout from the driver.

Returns:
The timeout in ms.
Exceptions:
- Any exception thrown by IoControl.

Endpoint::Type EasyUSB::Endpoint::GetType (  )  throw ()

Gets the type of this endpoint.

Returns:
Endpoint type.

bool EasyUSB::Endpoint::IsINEndpoint (  )  throw ()

Check if this EP is an IN EP.

Returns:
true if this EP receives data from the device.

bool EasyUSB::Endpoint::IsOUTEndpoint (  )  throw ()

Check if this EP is an OUT EP.

Returns:
true if this EP sends data to the device.

unsigned long EasyUSB::Endpoint::NumPacketsDone (  )  throw ()

Gets the number of packets that have been completed.

Returns:
The number of packets done.
Note:
Packets with the AsyncIO::Flags::FIRE_AND_FORGET flag will never get in this queue.

unsigned long EasyUSB::Endpoint::NumPacketsInProgress (  )  throw ()

Gets the number of packets currently in the active queue.

Returns:
The number of packets.

Data EasyUSB::Endpoint::Read ( unsigned long  Length  )  [virtual]

Reads data synchronously.

Parameters:
Length The number of bytes to read from the endpoint.
Returns:
A Data object representing the bytes read.
Exceptions:
DeviceLost The device is not connected.
UnknownError An unknown (windows) error occured.
InvalidParameter Most likely the length was not a multiple of the endpoint max size.
Note:
The actual bytes read can be less than specified.
See also:
Data::GetLength()

Reimplemented from EasyUSB::Detail::IO.

AsyncIO* EasyUSB::Endpoint::ReadAsync ( unsigned long  Length  ) 

Reads data asynchronously with default flags.

Parameters:
Length The number of bytes to read from the endpoint.
Returns:
A pointer to a AsyncIO object, representing the transfer.
Exceptions:
- Same as WriteAsync.
InvalidParameter Most likely the length was not a multiple of the endpoint max size.
Note:
This function uses the default flags.
The actual bytes read can be less than specified.
See also:
WriteAsync(Data Data, unsigned int Flags), Data::GetLength(), SetDefaultFlags

AsyncIO* EasyUSB::Endpoint::ReadAsync ( unsigned long  Length,
unsigned int  Flags 
) [virtual]

Reads data asynchronously.

Parameters:
Length The number of bytes to read from the endpoint.
Flags Asynchronous send options.
Returns:
A pointer to a AsyncIO object, representing the transfer.
Exceptions:
- Same as WriteAsync.
InvalidParameter Most likely the length was not a multiple of the endpoint max size.
Note:
The actual bytes read can be less than specified.
See also:
WriteAsync(Data Data, unsigned int Flags), Data::GetLength(), AsyncIO::Flags

Reimplemented from EasyUSB::Detail::IO.

void EasyUSB::Endpoint::RemovePacket ( AsyncIO pAIO  ) 

Removes the AsyncIO object from the PacketsDone queue.

All resources used by the object are freed.

Parameters:
pAIO The AsyncIO object to delete.

AsyncIO* EasyUSB::Endpoint::RetrievePacket ( unsigned short  Status = 0xFFFF  ) 

This is a combined FindPacket and RetrievePacket function.

It searches an AsyncIO object with the specified status and grants you ownership of it.

Parameters:
Status If specified, only a packet with the given status is returned.
Returns:
A pointer to an AsyncIO object or 0 if no packet with the specified status could be found.

void EasyUSB::Endpoint::RetrievePacket ( AsyncIO pAIO  ) 

Retrieves the packet from the PacketsDone queue.

This grants you ownership of the AsyncIO object. You are now responsible of destroying it after usage.

Parameters:
pAIO The AsyncIO object to be retrieved.
See also:
FindPacket

void EasyUSB::Endpoint::Run (  ) 

Lets the endpoint process running requests and calls registered callback functions.

void EasyUSB::Endpoint::SetDefaultFlags ( unsigned int  Flags = 0  )  throw ()

Sets the default flags for transferring data.

Parameters:
Flags The new default flags.

void EasyUSB::Endpoint::SetInterface ( IEndpoint pInterface  )  throw ()

Sets an interface for asynchronous callbacks.

Parameters:
pInterface A pointer to the new interface.
See also:
IEndpoint

void EasyUSB::Endpoint::SetIsoInterval ( unsigned short  Interval  ) 

Defines a new interval for delivering ISO packets.

Parameters:
Interval The new interval in ms.
Exceptions:
- Any exception thrown by IoControl.
Note:
Isochronous transfers are a relatively complex topic. This interval defines the starting point for every new packet. This does not change the starting point for already sent packets. Refer to the documentation for more information.

void EasyUSB::Endpoint::SetTimeout ( unsigned long  Timeout  ) 

Sets the time until the driver aborts its attempt to deliver the request.

Parameters:
Timeout The new timeout in ms.
Exceptions:
- Any exception thrown by IoControl.
Note:
The following rules apply to timeouts:
  • Interrupt reads do never timeout.
  • For bulk read/write and interrupt write this specifies the time between driver and device. Your request may reside in the internal IO queue for a longer time than specified.
  • This value has no effect on isochronous read/write.

AsyncIO* EasyUSB::Endpoint::WriteAsync ( Data  Data  ) 

Writes data asynchronously with default flags.

Parameters:
Data The Data to send.
Returns:
A pointer to a AsyncIO object, representing the transfer.
Exceptions:
- Same as WriteAsync.
Note:
This function uses the default flags.
See also:
WriteAsync(Data Data, unsigned int Flags)

AsyncIO* EasyUSB::Endpoint::WriteAsync ( Data  Data,
unsigned int  Flags 
) [virtual]

Writes data asynchronously.

Parameters:
Data The Data to send.
Flags Asynchronous send options.
Returns:
A pointer to a AsyncIO object, representing the transfer.
Exceptions:
NotEnoughMemory Not enough memory to complete the operation.
DeviceLost The device is not connected.
UnknownError An unknown (windows) error occured.
See also:
AsyncIO::Flags

Reimplemented from EasyUSB::Detail::IO.


Field Documentation

unsigned char EasyUSB::Endpoint::m_Address [protected]

Endpoint address.

unsigned int EasyUSB::Endpoint::m_DefaultFlags [protected]

The default flags for transferring data.

Endpoint for this EP.

The asynchronous callback interface.


Generated on Tue Nov 4 22:13:26 2008 for EasyUSB Connect by  doxygen 1.5.6