User-side Creation

This document describes user-side creation of asynchronous requests.

Asynchronous requests are commonly initiated by a call to RBusLogicalChannel::DoRequest(). The user making an asynchronous request creates a TRequestStatus object and passes it along with the request type to the DoRequest() call. The request status is changed to KRequestPending by the Kernel before sending the message to the driver. The user may then either wait on the request using User::WaitForRequest(), or it may queue one or more requests and then wait. It may have an active object handler to receive the request complete notifications.

// Request status object for transmit. This object will be used to 
// read the status of asynchronous requests after the notification of 
// request completion
//
 TRequestStatus txStatus;
     
// Call the LDD interface TransmitData() API with test data descriptor 
// and TRequestStatus object as parameters. Here TransmitData() is a
// wrapper over a DoRequest() call.
//
r = ldd.TransmitData(txStatus, KTestSendData);
test(r==KErrNone);
            
// Wait till the request is complete on txStatus. The user thread is 
// blocked with this call, till it is notified about the request 
// completion.
//
User::WaitForRequest(txStatus);
     
// txStatus holds the request completion. TRequestStatus::Int() 
// returns the completion code. It will be KErrNone in case of 
// successful completion.
//
r = txStatus.Int();
test(r==KErrNone);