RUsb Class Reference

class RUsb : public RSessionBase

The RUsb class implements the Symbian OS USB Management API RUsb

Inherits from

Public Member Functions
RUsb ()
~RUsb ()
IMPORT_C TInt BusClearError ()
IMPORT_C TInt BusDrop ()
IMPORT_C TInt BusRequest ()
IMPORT_C TInt BusRespondSrp ()
IMPORT_C TInt CancelInterest ( TUsbReqType )
IMPORT_C TInt ClassSupported ( TInt , TUid , TBool &)
IMPORT_C TInt Connect ()
IMPORT_C void DeviceStateNotification ( TUint , TUsbDeviceState &, TRequestStatus &)
IMPORT_C void DeviceStateNotificationCancel ()
IMPORT_C void DisableFunctionDriverLoading ()
IMPORT_C TInt EnableFunctionDriverLoading ()
IMPORT_C TInt GetCurrentPersonalityId ( TInt &)
IMPORT_C TInt GetCurrentState ( TUsbServiceState &)
IMPORT_C TInt GetDescription ( TInt , HBufC *&)
IMPORT_C TInt GetDetailedDescription ( TInt , HBufC *&)
IMPORT_C TInt GetDeviceState ( TUsbDeviceState &)
IMPORT_C TInt GetManufacturerStringDescriptor ( TUint , TUint , TName &)
IMPORT_C TInt GetOtgDescriptor ( TUint , TOtgDescriptor &)
IMPORT_C TInt GetPersonalityIds ( RArray < TInt > &)
IMPORT_C TInt GetPersonalityProperty ( TInt , TUint32 &)
IMPORT_C TInt GetProductStringDescriptor ( TUint , TUint , TName &)
IMPORT_C TInt GetServiceState ( TUsbServiceState &)
IMPORT_C TInt GetSupportedClasses ( TInt , RArray < TUid > &)
IMPORT_C TInt GetSupportedLanguages ( TUint , RArray < TUint > &)
IMPORT_C void HostEventNotification ( TRequestStatus &, TDeviceEventInformation &)
IMPORT_C void HostEventNotificationCancel ()
IMPORT_C void MessageNotification ( TRequestStatus &, TInt &)
IMPORT_C void MessageNotificationCancel ()
IMPORT_C TInt RequestSession ()
IMPORT_C void ServiceStateNotification ( TUsbServiceState &, TRequestStatus &)
IMPORT_C void ServiceStateNotificationCancel ()
IMPORT_C TInt SetCtlSessionMode ( TBool )
IMPORT_C void Start ( TRequestStatus &)
IMPORT_C void StartCancel ()
IMPORT_C void StateNotification ( TUint , TUsbDeviceState &, TRequestStatus &)
IMPORT_C void StateNotificationCancel ()
IMPORT_C void Stop ()
IMPORT_C void Stop ( TRequestStatus &)
IMPORT_C void StopCancel ()
IMPORT_C void TryStart ( TInt , TRequestStatus &)
IMPORT_C void TryStop ( TRequestStatus &)
IMPORT_C TVersion Version ()
IMPORT_C TInt __DbgAlloc ()
IMPORT_C TInt __DbgCheckHeap ( TInt )
IMPORT_C TInt __DbgFailNext ( TInt )
IMPORT_C TInt __DbgMarkEnd ( TInt )
IMPORT_C TInt __DbgMarkHeap ()
Inherited Functions
RHandleBase::Attributes()const
RHandleBase::BTraceId()const
RHandleBase::Close()
RHandleBase::DoExtendedClose()
RHandleBase::Duplicate(const RThread &,TOwnerType)
RHandleBase::FullName()const
RHandleBase::FullName(TDes &)const
RHandleBase::Handle()const
RHandleBase::HandleInfo(THandleInfo *)
RHandleBase::Name()const
RHandleBase::NotifyDestruction(TRequestStatus &)
RHandleBase::Open(const TFindHandleBase &,TOwnerType)
RHandleBase::OpenByName(const TDesC &,TOwnerType,TInt)
RHandleBase::RHandleBase()
RHandleBase::RHandleBase(TInt)
RHandleBase::SetHandle(TInt)
RHandleBase::SetHandleNC(TInt)
RSessionBase::CreateSession(RServer2,const TVersion &)
RSessionBase::CreateSession(RServer2,const TVersion &,TInt)
RSessionBase::CreateSession(RServer2,const TVersion &,TInt,TIpcSessionType,const TSecurityPolicy *,TRequestStatus *)
RSessionBase::CreateSession(const TDesC &,const TVersion &)
RSessionBase::CreateSession(const TDesC &,const TVersion &,TInt)
RSessionBase::CreateSession(const TDesC &,const TVersion &,TInt,TIpcSessionType,const TSecurityPolicy *,TRequestStatus *)
RSessionBase::CreateSession(const TDesC &,const TVersion &,TInt,TRequestStatus *)
RSessionBase::Open(RMessagePtr2,TInt,TOwnerType)
RSessionBase::Open(RMessagePtr2,TInt,const TSecurityPolicy &,TOwnerType)
RSessionBase::Open(TInt,TOwnerType)
RSessionBase::Open(TInt,const TSecurityPolicy &,TOwnerType)
RSessionBase::Send(TInt)const
RSessionBase::Send(TInt,const TIpcArgs &)const
RSessionBase::SendReceive(TInt)const
RSessionBase::SendReceive(TInt,TRequestStatus &)const
RSessionBase::SendReceive(TInt,const TIpcArgs &)const
RSessionBase::SendReceive(TInt,const TIpcArgs &,TRequestStatus &)const
RSessionBase::SetReturnedHandle(TInt)
RSessionBase::SetReturnedHandle(TInt,RHandleBase &)
RSessionBase::SetReturnedHandle(TInt,const TSecurityPolicy &)
RSessionBase::ShareAuto()
RSessionBase::ShareProtected()
Public Member Enumerations
enum TUsbReqType { EStart , EStop , ETryStart , ETryStop }
Inherited Enumerations
RHandleBase:TAttributes
RSessionBase:TAttachMode
Private Attributes
TPckg < TUint32 > iDeviceStatePkg
TPckg < TDeviceEventInformation > iHostPkg
TPckg < TUint32 > iMessagePkg
TPckg < TUint32 > iServiceStatePkg
Inherited Attributes
RHandleBase::iHandle

Constructor & Destructor Documentation

RUsb()

IMPORT_C RUsb ( )

Constructor

Since
7.0

~RUsb()

IMPORT_C ~RUsb ( )

Destructor

Since
7.0

Member Functions Documentation

BusClearError()

IMPORT_C TInt BusClearError ( )

Cable watcher wants to clear the Bus Error after A_VBUS_ERR Only works if ID-Pin is present (this is an A-Device) and there has already been a bus erorr. This will not result in any attempt to raise or drop VBus

capability
NetworkControl

BusDrop()

IMPORT_C TInt BusDrop ( )

Cable watcher wants to drop VBus. If ID-Pin is present this is an A-Device and this will result in stopping VBus power-up

capability
NetworkControl

BusRequest()

IMPORT_C TInt BusRequest ( )

Cable watcher wants to assert Bus_request. If ID-Pin is present this is an A-Device and this will result in an attempt to raise VBus. Second attempt to raise VBus causes KErrUsbOtgVbusAlreadyRaised error. If ID-Pin is absent this is a B-Device and this will result in an attempt to use SRP. Recently does nothing

When BusRequest() returns an error, VBus remains low until the errors are cleared by BusDrop() or BusClearErr() calls

capability
NetworkControl

BusRespondSrp()

IMPORT_C TInt BusRespondSrp ( )

Cable watcher wants to assert Bus_request after SRP. If ID-Pin is present this is an A-Device and this will result in an attempt to raise VBus

capability
NetworkControl

CancelInterest(TUsbReqType)

IMPORT_C TInt CancelInterest ( TUsbReqType aMessageId )

Cancels the interest of the pending operation of the device's USB service, either starting or stopping. The pending request will run to the completion. The caller of this function receives a status of KErrCancel.

Parameters

TUsbReqType aMessageId a message id to identify the request to be cancelled

ClassSupported(TInt, TUid, TBool &)

IMPORT_C TInt ClassSupported ( TInt aPersonalityId,
TUid aClassUid,
TBool & aSupported
)

Queries the USB manager to determine if a given class is supported

Parameters

TInt aPersonalityId a personality id
TUid aClassUid a class uid
TBool & aSupported set upon return

Connect()

IMPORT_C TInt Connect ( )

Connect the Handle to the Server Must be called before all other methods except Version()

Since
7.0

DeviceStateNotification(TUint, TUsbDeviceState &, TRequestStatus &)

IMPORT_C void DeviceStateNotification ( TUint aStateMask,
TUsbDeviceState & aState,
TRequestStatus & aStatus
)

Request to be notified of a change in state of the USB device.

Since
7.0s

Parameters

TUint aStateMask State mask of the states the client is interested in
TUsbDeviceState & aState State variable to be written to upon completion of the request
TRequestStatus & aStatus Status to complete when required state change occurs

DeviceStateNotificationCancel()

IMPORT_C void DeviceStateNotificationCancel ( )

Cancel the outstanding device state notification request.

Since
7.0s

DisableFunctionDriverLoading()

IMPORT_C void DisableFunctionDriverLoading ( )

Disable Function Driver Loading.

capability
NetworkControl

EnableFunctionDriverLoading()

IMPORT_C TInt EnableFunctionDriverLoading ( )

Enable Function Driver Loading.

capability
NetworkControl

GetCurrentPersonalityId(TInt &)

IMPORT_C TInt GetCurrentPersonalityId ( TInt & aPersonalityId )

Gets the current personality id of the device's USb service

Parameters

TInt & aPersonalityId set to the current personality of USB device

GetCurrentState(TUsbServiceState &)

IMPORT_C TInt GetCurrentState ( TUsbServiceState & aState )

Functions below this point are deprecated and should not be used. Get the current state of the device's USB service. This function is deprecated and has been replaced by the GetServiceState function from version 7.0s onwards.

Since
7.0

Parameters

TUsbServiceState & aState Set by the method to the current state of the USB service

GetDescription(TInt, HBufC *&)

IMPORT_C TInt GetDescription ( TInt aPersonalityId,
HBufC *& aLocalizedPersonalityDescriptor
)

Gets the textual description of the personality identified by the aPersonalityId. Caller is repsonsible for freeing up memories allocated to aLocalizedPersonalityDescriptor.

Parameters

TInt aPersonalityId a personality id
HBufC *& aLocalizedPersonalityDescriptor a localize text string

GetDetailedDescription(TInt, HBufC *&)

IMPORT_C TInt GetDetailedDescription ( TInt aPersonalityId,
HBufC *& aLocalizedPersonalityDescriptor
)

Gets the detailed textual description of the personality identified by the aPersonalityId. Caller is repsonsible for freeing up memories allocated to aLocalizedPersonalityDescriptor.

Parameters

TInt aPersonalityId a personality id
HBufC *& aLocalizedPersonalityDescriptor a localize text string

GetDeviceState(TUsbDeviceState &)

IMPORT_C TInt GetDeviceState ( TUsbDeviceState & aState )

Gets the current device state (eg. powered, configured...).

Since
7.0s

Parameters

TUsbDeviceState & aState Set by the method to the current state of the USB device

GetManufacturerStringDescriptor(TUint, TUint, TName &)

IMPORT_C TInt GetManufacturerStringDescriptor ( TUint aDeviceId,
TUint aLangId,
TName & aString
)

Get Manufacturer Descriptor

Parameters

TUint aDeviceId DeviceID of given device
TUint aLangId required language ID which is supplied by USB-IF and is different from standard Symbian TLanguage enumeration
TName & aString manufacturer descriptor value at output

GetOtgDescriptor(TUint, TOtgDescriptor &)

IMPORT_C TInt GetOtgDescriptor ( TUint aDeviceId,
TOtgDescriptor & aDescriptor
)
Retrieve Otg Descriptor for device which has given device Id. Currently TOtgDescriptor has following fields:
  • HNP supported

  • SRP supported An OTG device should support them both.

Parameters

TUint aDeviceId DeviceID of given device
TOtgDescriptor & aDescriptor OTG descriptor value at output

GetPersonalityIds(RArray< TInt > &)

IMPORT_C TInt GetPersonalityIds ( RArray < TInt > & aPersonalityIds )

Gets all supported personality ids of the device's USB service.

Parameters

RArray < TInt > & aPersonalityIds populated with all supported personality ids of the USB device

GetPersonalityProperty(TInt, TUint32 &)

IMPORT_C TInt GetPersonalityProperty ( TInt aPersonalityId,
TUint32 & aProperty
)

Gets the property of the personality identified by the aPersonalityId.

Parameters

TInt aPersonalityId a personality id
TUint32 & aProperty

GetProductStringDescriptor(TUint, TUint, TName &)

IMPORT_C TInt GetProductStringDescriptor ( TUint aDeviceId,
TUint aLangId,
TName & aString
)

Get Product Descriptor

Parameters

TUint aDeviceId DeviceID of given device
TUint aLangId required language ID which is supplied by USB-IF and is different from standard Symbian TLanguage enumeration
TName & aString product descriptor value at output

GetServiceState(TUsbServiceState &)

IMPORT_C TInt GetServiceState ( TUsbServiceState & aState )

Get the current state of the device's USB service.

Since
7.0s

Parameters

TUsbServiceState & aState Set by the method to the current state of the USB service

GetSupportedClasses(TInt, RArray< TUid > &)

IMPORT_C TInt GetSupportedClasses ( TInt aPersonalityId,
RArray < TUid > & aClassUids
)

Gets supported classes by the given personality identified by the aPersonalityId

Parameters

TInt aPersonalityId a personality id
RArray < TUid > & aClassUids an array of class uids

GetSupportedLanguages(TUint, RArray< TUint > &)

IMPORT_C TInt GetSupportedLanguages ( TUint aDeviceId,
RArray < TUint > & aLangIds
)

Get Supported Languages from USB Device

Parameters

TUint aDeviceId DeviceID of given device
RArray < TUint > & aLangIds an array of language IDs supported by given device. These language IDs are supplied by USB-IF and are different from standard Symbian TLanguage enumeration

HostEventNotification(TRequestStatus &, TDeviceEventInformation &)

IMPORT_C void HostEventNotification ( TRequestStatus & aStatus,
TDeviceEventInformation & aDeviceInformation
)

Register for Host Device Event notifications. The request only completes when the host event occurs. Calling this function the first time initializes Host Events queue

KErrNone - if successful KErrInUse - if there is another outstanding nofitication request for the same session otherwise an error code returned by FDF

Parameters

TRequestStatus & aStatus Status to complete when required event occurs
TDeviceEventInformation & aDeviceInformation device info to be written to upon completion of the request

HostEventNotificationCancel()

IMPORT_C void HostEventNotificationCancel ( )

Cancel the outstanding FDF Device Event notification request.

MessageNotification(TRequestStatus &, TInt &)

IMPORT_C void MessageNotification ( TRequestStatus & aStatus,
TInt & aMessage
)

Register for Messages notifications The request only completes when the new message arrives. Calling this function the first time initializes Messages queue

Parameters

TRequestStatus & aStatus Status to complete when required state change occurs KErrNone - if successful KErrInUse - if there is another outstanding nofitication request for the same session otherwise an error code returned by OTGDI or Host
TInt & aMessage UI Message variable to be written to upon completion of the request

MessageNotificationCancel()

IMPORT_C void MessageNotificationCancel ( )

Cancel the outstanding Messages notification request.

RequestSession()

IMPORT_C TInt RequestSession ( )

Informs USB Manager that the client would like to initialte USB session. On A-Device, it results in sending a notification to 'controller' application On B-Device, it may trigger either SRP or HNP sequence depending on the state of VBus

ServiceStateNotification(TUsbServiceState &, TRequestStatus &)

IMPORT_C void ServiceStateNotification ( TUsbServiceState & aState,
TRequestStatus & aStatus
)

Request to be notified of a change in service state of the USB device. The request only completes when the service state changes.

Since
7.0s

Parameters

TUsbServiceState & aState State variable to be written to upon completion of the request
TRequestStatus & aStatus Status to complete when required state change occurs

ServiceStateNotificationCancel()

IMPORT_C void ServiceStateNotificationCancel ( )

Cancel the outstanding service state notification request.

Since
7.0s

SetCtlSessionMode(TBool)

IMPORT_C TInt SetCtlSessionMode ( TBool aValue )

Set or reset the mode in which current RUsb session operates. Recent implementation assumes that there is the one and only application which controls USBMAN, all other clients act as listeners to notification requests. Only application which was previously granted 'control' mode is allowed to reset it at later stage. Any calls from other applications will generate an error.

capability
NetworkControl

Parameters

TBool aValue True to inform USBMAN that Application wants to 'control' USBMAN False otherwise

Start(TRequestStatus &)

IMPORT_C void Start ( TRequestStatus & aStatus )

Start the device's USB service. Should not be called if the USB services have already been started Note: Asynchonous Version, outcome returned when the status is completed

Since
7.0
capability
NetworkControl

Parameters

TRequestStatus & aStatus Status to complete once the start operation has completed

StartCancel()

IMPORT_C void StartCancel ( )

Cancels the pending start operation of the device's USB service.

Since
7.0
capability
NetworkControl

StateNotification(TUint, TUsbDeviceState &, TRequestStatus &)

IMPORT_C void StateNotification ( TUint aStateMask,
TUsbDeviceState & aState,
TRequestStatus & aStatus
)

Request to be notified of a change in state of the USB device. This function is deprecated and has been replaced by the DeviceStateNotification function from version 7.0s onwards.

Since
7.0

Parameters

TUint aStateMask State mask of the states the client is interested in
TUsbDeviceState & aState State variable to be written to upon completion of the request
TRequestStatus & aStatus Status to complete when required state change occurs

StateNotificationCancel()

IMPORT_C void StateNotificationCancel ( )

Cancel the outstanding device state notification request. This function is deprecated and has been replaced by the DeviceStateNotificationCancel function from version 7.0s onwards.

Since
7.0

Stop()

IMPORT_C void Stop ( )

Stops the device's USB service. Should not be called if the USB services have not been started. This is the synchronous variant of this function. This function is deprecated- use the asynchronous version.

Since
7.0
capability
NetworkControl

Stop(TRequestStatus &)

IMPORT_C void Stop ( TRequestStatus & aStatus )

Stops the device's USB service. Should not be called if the USB services have not been started. This is the asynchronous variant of this function.

Since
7.0s
capability
NetworkControl

Parameters

TRequestStatus & aStatus Status to complete once the stop operation has completed

StopCancel()

IMPORT_C void StopCancel ( )

Cancels the pending stop operation of the device's USB service.

Since
7.0s
capability
NetworkControl

TryStart(TInt, TRequestStatus &)

IMPORT_C void TryStart ( TInt aPersonalityId,
TRequestStatus & aStatus
)

Try to start the device's USB service. It starts the current personality only if the service is in the idle state. Calling this API while the server is in any other states has no any effect on the service state.

Note: Asynchonous version, outcome returned when the status is completed

capability
NetworkControl

Parameters

TInt aPersonalityId a personality id
TRequestStatus & aStatus Status to complete once the start operation has completed. It may be one of the following: KErrNotSupported KErrAccessDenied KErrServerBusy KErrAbort KErrNone

TryStop(TRequestStatus &)

IMPORT_C void TryStop ( TRequestStatus & aStatus )

Try to stop the device's USB service. It stops the service only if the serice is in the started state. Calling this API while the server is in the other states has no any effect on the service state.

Note: Asynchonous version, outcome returned when the status is completed

capability
NetworkControl

Parameters

TRequestStatus & aStatus Status to complete once the stop operation has completed. It may be one of the following: KErrNotSupported KErrAccessDenied KErrServerBusy KErrNone

Version()

IMPORT_C TVersion Version ( ) const

Extract the version of the server providing the RUsb API

Since
7.0

__DbgAlloc()

IMPORT_C TInt __DbgAlloc ( )

Simulates memory allocation in the USB Manager. This function is only defined in debug builds.

__DbgCheckHeap(TInt)

IMPORT_C TInt __DbgCheckHeap ( TInt aCount )

Checks that the number of allocated cells on the USB Manager's heap is correct. The USB Manager will be panicked if it is not. This function is only defined in debug builds.

Parameters

TInt aCount The expected number of heap cells allocated

__DbgFailNext(TInt)

IMPORT_C TInt __DbgFailNext ( TInt aCount )

Simulates memory allocation failure in the USB Manager. This function is only defined in debug builds.

Parameters

TInt aCount The number of allocations after which memory allocation should fail

__DbgMarkEnd(TInt)

IMPORT_C TInt __DbgMarkEnd ( TInt aCount )

Marks the end of heap cell checking for the USB Manager. Checks that the number of heap cells allocated since the last __DbgMarkHeap() is aCount; the most common value to pass here is zero. This function is only defined in debug builds.

Parameters

TInt aCount The expected number of heap cells allocated

__DbgMarkHeap()

IMPORT_C TInt __DbgMarkHeap ( )

Marks the start of heap cell checking for the USB Manager. This function is only defined in debug builds.

Member Enumerations Documentation

Enum TUsbReqType

Enumerators

EStart
EStop
ETryStart
ETryStop

Member Data Documentation

TPckg< TUint32 > iDeviceStatePkg

TPckg < TUint32 > iDeviceStatePkg [private]

Used to register device state notifications.

TPckg< TDeviceEventInformation > iHostPkg

TPckg < TDeviceEventInformation > iHostPkg [private]

Used to register Host state notifications.

TPckg< TUint32 > iMessagePkg

TPckg < TUint32 > iMessagePkg [private]

Used to register OTG/Host message notifications.

TPckg< TUint32 > iServiceStatePkg

TPckg < TUint32 > iServiceStatePkg [private]

Used to register service state notifications.