_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 ) );

創作者介紹
創作者 shadow 的頭像
shadow

資訊園

shadow 發表在 痞客邦 留言(0) 人氣()