Serial communication is a low level point-to-point technique for transmitting data between two devices (typically a relatively close distance). SERIES60 supports serial communication on infrared and Bluetooth. The center of the SERIES60 implementation is the serial Communication Server (serial communication Server, also known as comms servers or C32). It uses the Symbian OS client/server framework to provide access to serial hardware and is common and shared. Universal refers to the use of the same API for infrared and Bluetooth serial communications, which means that multiple client threads can safely and concurrently use the same serial port.
All serial communications in SERIES60 are implemented using the following basic steps:
1. Loading serial device drives
2. Start Comms server
3. Connect to Comms server
4. Mount a Comms module (also known as Csy: "Comms SYstem")----the plug-in for the COMMS server, which will determine which type of serial port to use (infrared or Bluetooth)
5. Open a serial port
6. Configure this serial port
7. Read and write data from the port
8. Finally close the port
There are several important classes involved in the communication process, which are briefly described below:
1.RCommServ
Serial Communication Server Session class. It describes the session with the comms server. Provides a connection to a server function, load/unload different comms module functions, query valid port names and quantity functions, and so on.
Sessions between the same comms servers are not shared. This class cannot be inherited. Inherited from Rsessionbase.
Members
Defined in RCommServ:
Connect(), CreateThreadInCommProc(), GetPortInfo(), LoadCommModule(), NumPorts(), RCommServ(), UnloadCommModule(), Version(), __DbgCheckHeap(), __DbgFailNext(), __DbgMarkEnd(), __DbgMarkHeap(), __DbgSetTraceMask()
Inherited from RHandleBase:
Attributes(), Close(), Duplicate(), FullName(), Handle(), HandleInfo(), Name(), SetHandle(), SetHandleNC(), iHandle
Inherited from RSessionBase:
CreateSession(), EAutoAttach, EExplicitAttach, Open(), Send(), SendReceive(), SetReturnedHandle(), ShareAuto(), ShareProtected(), TAttachMode
2.RComm
Inherits from Rsubsessionbase, describes a child session, communicates with a C32 server using one of the ports. The functions provided communicate through the operation ports, including opening, closing, reading and writing, port configuration and performance detection. Once you have used a port to communicate, you cannot change this port again.
The following is a detailed breakdown of the serial communication steps:
1. Loading serial device drives
There are two parts that need to be loaded: a physical drive (directly interacting with the hardware) and a logical drive (providing APIs on the physical drive). Their names are fixed and are globally defined here. Note that the physical device drives used for emulator generation (WINS) are different from those used for target generation.
// Physical device driver names
#if defined (__WINS__)
_LIT (KPddName, "ECDRV");
#else
_LIT (KPddName, "EUART1");
#endif
// Logical device driver names
_LIT (KLddName, "ECOMM");