You Are Here:

Community: Wiki

This page was last modified on 3 November 2008, at 22:47.

TSS000601 - Serial communication over USB on S60 3rd Edition devices

From Forum Nokia Wiki


ID TSS000601 Creation date March 8, 2007
Platform S60 3rd Edition
S60 3rd Edition, FP1
Devices
Category Symbian C++ Subcategory Local connectivity, USB


Keywords (APIs, classes, methods, functions):

Overview

Serial communication over USB on S60 3rd Edition devices

Description

The RComm API can be used to transfer data over USB serial connection. On S60 3rd Edition, loading of physical (PDD) and logical (LDD) device drivers is not required. Only the CSY module ECACM should be loaded.
The port name available for USB communication is usually "ACM::1". Some devices may support multiple ACM ports. The first port (ACM::0) is reserved for fax/modem process, but ACM::1 and onwards can be used in other applications.
A simplified example for initializing the serial port:
    _LIT(CSYMOD, "ECACM");
    _LIT(KACMPort1, "ACM::1");
    // RComm is a client to the RCommServ Comms server
    // Start this service before any connections are made.
    TInt ret = StartC32();
    if ( ret != KErrNone && ret != KErrAlreadyExists )
        {
        User::Leave ( ret );
        }
    // Connect to CommServer
    RCommServ server;
    User::LeaveIfError( server.Connect() );
    // Load CSY Module
    User::LeaveIfError( server.LoadCommModule( CSYMOD ) );
    TBuf16<KMaxPortName> portName;
    portName.Copy( KACMPort1 );
    // Open the comm. port
    RComm commPort;
    User::LeaveIfError( commPort.Open( server, portName, ECommShared ) );
    // Verify capabilities of the port and configure it
    TCommCaps portCaps;
    commPort.Caps( portCaps );
    if (((portCaps().iRate & KCapsBps115200) == 0) |
        ((portCaps().iDataBits & KCapsData8) == 0) |
        ((portCaps().iStopBits & KCapsStop1) == 0) |
        ((portCaps().iParity & KCapsParityNone) == 0))
       {
       User::Leave( KErrNotSupported );
       }
    TCommConfig portCfg;
    commPort.Config( portCfg );
    portCfg().iRate     =   EBps115200;
    portCfg().iParity   =   EParityNone;
    portCfg().iDataBits =   EData8;
    portCfg().iStopBits =   EStop1;
    portCfg().iHandshake =  0;
    User::LeaveIfError( commPort.SetConfig( portCfg ) );
After this you can read from and write to the port. An application listening to the port should be running on the host (PC).

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia