Hi
I am trying to Read Write Data on Ports in Symbian S60 3RD EDITION FP1
BUT THE CODE LEAVE WITH ERROR CODE -4 WHEN I TRY TO OPEN THE PORT....
PLEASE HELP..
THANKS IN ADVANCE
GAURAV GUPTA
void CRWPorts::testPorts()
{
// KillFaxModemProcess();
_LIT(CSYMOD, "ECACM");
_LIT(KACMPort1, "ACM::1");
TInt ret = StartC32();
if ( ret != KErrNone && ret != KErrAlreadyExists )
{
console->Printf(_L("RET\n"));
User::Leave ( ret );
console->Printf(_L("after RET\n"));
}
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 ) ); // CODE LEAVES HERE
// 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 ) );
commPort.Write(aStatus,_L8("Hello World"));
console->Printf(_L("DAta sent"));
User::After(3000000);
TBuf8<20> iData;
commPort.ReadOneOrMore(aStatus,iData);
TBuf<20>iPrintData;
iPrintData.Copy(iData);
console->Printf(_L("data : %S"),&iPrintData);
}

Reply With Quote


