Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



How to open ports

There are a number of distinct steps which it is necessary to take before using a serial port. While the first three of these steps will usually have been taken before any communication software loads up, they are all listed here for completeness to avoid any appearance of complexity in the example code.

  1. Load the physical device driver, which interacts directly with the hardware at the lowest level.

  2. Load the logical device driver, which provides the comms server with a consistent interface to the hardware. You should note that both these drivers have automatic .PDD and .LDD file extensions added by their respective loaders, which automatically search the /System/Libs directories on all drives.

  3. Since RComm is to be a client to the RCommServ comms server, start this service before any attempt is made to connect to it. Note that it is only after the device drivers are both in place that it makes sense to start the comms server.

  4. Connect the RComm client to the server. This, and both the following steps, must usually be taken by all software which instantiates an RComm object.

  5. Ask the server to use a specific comms module by name. These .CSY files are protocol modules that let the server know how it should handle the port. For instance, sample terminal code uses a standard RS232 module called ECUART, while infra-red code uses a completely different IrDA module called IrCOMM.

  6. Finally, open the comms port by name using RComm:Open(). You must specify the name of the port, since there is no reason why a machine with suitable hardware can’t have more than one serial port open at a time.

#define PDD_NAME _L("EUART1")
#define LDD_NAME _L("ECOMM")
User::LoadPhysicalDevice (PDD_NAME); // step 1
User::LoadLogicalDevice (LDD_NAME); // step 2
StartC32 (); // step 3
RCommServ server;
server.Connect (); // step 4
server.LoadCommModule (_L ("ECUART")); // step 5
RComm commPort;
commPort.Open (server, _L ("COMM::0"), ECommExclusive); // step 6


Note

[Top]


See also

Client Server.