Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 22:03, 2 January 2008.

Serial communication

From Forum Nokia Wiki

Serial communication is a low-level, point-to-point technology used to transfer data between two devices, typically at close range — S60 supports serial communication over infrared and Bluetooth. Central to the S60 implementation is the Serial Communications Server (also referred to as the Comms Server or C32). This uses the familiar Symbian OS Client/Server framework to provide access to serial hardware, and it is generic (in other words, the same API is used for both infrared and Bluetooth serial communication — note that other hardware can be supported by the addition of plug-ins) and shared (in other words, several client threads can safely use the same serial port concurrently).


Contents

All serial communication on S60 is implemented using the following basic steps:

  • Load the serial device drivers.
  • Start the Comms Server.
  • Connect to the Comms Server.
  • Load a comms module (otherwise known as a CSY) — this is the Comms Server plug-in that determines which type of serial port you wish to use (for example, infrared or Bluetooth).
  • Open a serial port.
  • Configure the serial port.
  • Write data to (and/or read data from) the port.
  • Finally, close the port.

An Example IR Serial Communication.

Important Classes involved:

RCommServ // serial comms

RComm // comm port

TBuf8<64> Data // data to transmit

Part 1

  • Load the physical and logical device drivers.
  • Connect to the Serial comms server.
  • Load the CSY module.


err = User::LoadPhysicalDevice(KPddName);
 if (err != KErrNone && err != KErrAlreadyExists)
 {
 User::Leave(err);
 }
// Load the logical device driver.
 err = User::LoadLogicalDevice(KLddName);
 if (err != KErrNone && err != KErrAlreadyExists)
 {
 User::Leave(err);
 }
// Start the comms server process
 err = StartC32();
 if (err != KErrNone && err != KErrAlreadyExists)
 {
 User::Leave(err);
 }
// Connect to the Serial comms server.
 User::LeaveIfError(iCommServer.Connect());
// Load the CSY module.
 User::LeaveIfError(iCommServer.LoadCommModule(KIrComm));
 }

Part 2

  • Open the serial port
  • Check port capabilities
  • Configure port
  • Set buffer size


//Open the serial port

User::LeaveIfError(iCommPort.Open(iCommServer, KPortName, ECommShared));

// Check port capabilities
 TCommCaps portCapabilities;
 iCommPort.Caps(portCapabilities);
if (((portCapabilities().iRate & KCapsBps19200) == 0) ||
 ((portCapabilities().iDataBits & KCapsData8) == 0) ||
 ((portCapabilities().iStopBits & KCapsStop1) == 0) ||
 ((portCapabilities().iParity & KCapsParityNone) == 0))
 User::Leave (KErrNotSupported);
// Configure port
 TCommConfig portSettings;
 iCommPort.Config(portSettings); // Get current configuration
// Set port characteristics
 portSettings().iRate = EBps19200;
 portSettings().iParity = EParityNone;
 portSettings().iDataBits = EData8;
 portSettings().iStopBits = EStop1;
 portSettings().iFifo = EFifoEnable;
 portSettings().iHandshake = KConfigObeyXoff|KConfigSendXoff; 
 portSettings().iTerminator[0] = 10; // line feed character
 portSettings().iTerminatorCount = 1;
User::LeaveIfError(iCommPort.SetConfig(portSettings));
// Turn on DTR and RTS
 iCommPort.SetSignals(KSignalDTR, 0);
 iCommPort.SetSignals(KSignalRTS, 0);
// Set buffer size
 const TInt KBufferLength = 4096;
 iCommPort.SetReceiveBufferLength(KBufferLength);
 }



Part 3

  • write to the serial port.




const TTimeIntervalMicroSeconds32 KTimeOut(4000000);
iCommPort.Write(iStatus, KTimeOut, Data);
Related Discussions
Thread Thread Starter Forum Replies Last Post
Serial port in 6310i rotopark Mobile Java General 1 2002-05-23 06:47
product serial number solojuve Graphics & Video & Streaming 12 2006-12-22 00:45
serial number nokia audio suite 2.0 el_web0n Audio 8 2008-05-30 19:53
Fbus connectivity to N-gage pierretouma General Discussion 2 2006-01-12 11:25
AT Commands james_m_sharp Mobile Java General 4 2004-09-22 02:52
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtopicQUqfnTopicZconnectivityQ
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX