How to Load the Physical Device Driver and Logical Device Driver: Tutorial

When testing using the console, all drivers need to be loaded directly. This tutorial describes how to load the drivers required for the Serial Communications Server.

Testing of communications software can be done using the Symbian platform console shell interface rather than a GUI interface. The console shell interface has advantages when testing since the console allows software to be tested in isolation. When testing with a GUI interface the testing can be difficult if other software in the GUI is attempting to access resources. If the device or the emulator is started with just the console, then only the kernel and file system are running. The tester can then load the software required for the test and ensure that no other software is using any resources. This avoids problems of other software interrupting the CPU or using and releasing memory or other hardware while a test is running.

Any test applications that have not been launched by the GUI should explicitly load the correct physical and logical device drivers. In most cases the bootloader will load the physical device driver. It is safe to load a device driver which has already been loaded, since the API will return KErrAlreadyExists

  1. Identify the names of the physical and logical device drivers required.

    The names of device drivers change since variations are created for different platforms: the ecuart and infra-red logical device driver is usually called ECOMM while the USB logical device driver is usually called EUSBC. For fast infra-red the logical device driver is usually called EFIR. For ecuart, infra-red and USB the physical device driver is usually called ECDRV on the emulator. For devices the physical device drivers have a variety of names. The euart and USB the physical device driver is usually called EUART or EUART with a number for each port from base 1, for example EUART1 and EUART2. For infra-red the physical device driver is usually called EUART2. For fast infra-red the physical device driver is usually called DIFIR for both emulator and devices.

  2. Call User::LoadPhysicalDevice to load the physical device driver and check the return code. A return code of KErrAlreadyExists can be ignored.
  3. Call User::LoadLogicalDevice to load the logical device driver and check the return code. A return code of KErrAlreadyExists can be ignored.
  4. Start the RootServer by calling StartC32(). The RootServer loads the Serial Communications Server.

Example

#if defined (__WINS__)
    #define PDD_NAME _L("ECDRV")
#else
    #define PDD_NAME _L("EUART1")
#endif
#define LDD_NAME _L("ECOMM")
TInt r = User::LoadPhysicalDevice (PDD_NAME);
if (r != KErrNone && r != KErrAlreadyExists) 
    {
    User::Leave(r);
    }
r = User::LoadLogicalDevice (LDD_NAME);
if (r != KErrNone && r != KErrAlreadyExists) 
    {
    User::Leave(r);
    }

r = StartC32(); 
User::LeaveIfError(r);

Related information