N73一打开红外就死机,请教!!

apartst 2007-10-25 09:35:46
symbian第二版时没有问题,升级到第三版后就不行了,贴出来代码大家看看是怎么回事,谢谢!
/////////////////////////////////////////////////////////////////////下面的代码是初始化串口/////////////////////////////////////////////////////////////////////////
   // Load device drivers
TBuf<32> aErrBuf;
TInt err = User::LoadPhysicalDevice(KPddName);//驱动程序名称 "EUART" 一般的资料中都是"EUART1",但实际上在N73中没有这个库
if ((err != KErrNone) && (err != KErrAlreadyExists))
{
//User::Leave(err);
aErrBuf=_L("LoadPhysicalDevice:");
iReporter.PrintInfo(aErrBuf,err);
}
err = User::LoadLogicalDevice(KLddName); //逻辑驱动 "ECOMM"
if ((err != KErrNone) && (err != KErrAlreadyExists))
{
//User::Leave(err);
aErrBuf=_L("LoadLogicalDevice:");
iReporter.PrintInfo(aErrBuf,err);
}
//
err=StartC32(); //启动服务
if (err != KErrNone)
{
aErrBuf=_L("StartC32():");
iReporter.PrintInfo(aErrBuf,err);
}
err =iCommServ.Connect();
if (err != KErrNone)
{
aErrBuf=_L("iCommServ.Connect():");
iReporter.PrintInfo(aErrBuf,err);
}

err = iCommServ.LoadCommModule(KRS232); "ECUART" 这个是定死的,要用串口必须这么写
//
// err = iCommServ.LoadCommModule(KIrDA);"IRCOMM" 这个是带协议的
if ((err != KErrNone) && (err != KErrAlreadyExists))
{
iCommServ.Close();
//User::Leave(err);
aErrBuf=_L("LoadCommModule:");
iReporter.PrintInfo(aErrBuf,err);
}
ChangeStatus(EServerConnected);

TInt numPorts; //下面的在代码是枚举所有串口信息
err = iCommServ.NumPorts (numPorts);
if(err)
{
aErrBuf=_L("NumPorts:");
iReporter.PrintInfo(aErrBuf,err);
return ;
}
TBuf16<12> infoname;
infoname.Format(_L("ports are %d"), numPorts);
iReporter.PrintInfo(_L("The number of"));
iReporter.PrintInfo(infoname);
//return ;
TSerialInfo portInfo;
TBuf16 <32> moduleName;

for (TInt index=0 ; index < numPorts ; index++)
{
err = iCommServ.GetPortInfo (index, moduleName, portInfo);
if(err)
{
aErrBuf=_L("GetPortInfo:");
iReporter.PrintInfo(aErrBuf,err);
return ;
}
infoname.Copy(moduleName);
iReporter.PrintInfo(_L("The module"));
iReporter.PrintInfo(infoname);

// iReporter.PrintInfo(_L("The description"));
// infoname.Copy(portInfo.iDescription);
// iReporter.PrintInfo(infoname);
//
iReporter.PrintInfo(_L("The portname"));
infoname.Copy(portInfo.iName);
iReporter.PrintInfo(infoname);

iReporter.PrintInfo(_L("The Lowunit"));
infoname.Format(_L("is %d"), portInfo.iLowUnit);
iReporter.PrintInfo(infoname);
//
iReporter.PrintInfo(_L("The Highunit"));
infoname.Format(_L("is %d"), portInfo.iHighUnit);
iReporter.PrintInfo(infoname);
}
//上面的输出

ports are 2
The module DATAPORT
The Portname DATAPORT
the Lowunit is 0 //最小索引
the Highunit is 3
The module Ecuart //就是串口
The Portname COMM
The Lowunit is 0
the Highunit is 0 //就是说只有一个可用


///////////////////////////////////////////下面的代码是打开串口////////////////////////////////////////////////

//KIRCommPort =="IRCOMM::0" 这个可以打开使用
//KCommPort0 =="COMM::0"

// TInt err = iComm.Open(iCommServ, KIRCommPort, ECommExclusive);//ECommShared
TInt err = iComm.Open(iCommServ, KCommPort0, ECommExclusive);
if (err)
{
TBuf<32> aErrBuf;
iCommServ.Close();
ChangeStatus(ENotConnected);
aErrBuf=_L("CIrScopeEngine:Open Err:");
iReporter.PrintInfo(aErrBuf,err);
//User::Leave(err);
return ;
}

输出结果为:CIrScopeEngine:Open Err: -4 (KErrNoMemory)
...全文
173 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
toann 2007-10-25
  • 打赏
  • 举报
回复
据我所知,RComm的Open,需要厂商能力。楼主看看是不是这里的问题
toann 2007-10-25
  • 打赏
  • 举报
回复
3rd,注意能力问题。
dyw 2007-10-25
  • 打赏
  • 举报
回复
anel 2007-10-25
  • 打赏
  • 举报
回复
用log来跟踪,看看哪不行

3,120

社区成员

发帖
与我相关
我的任务
社区描述
塞班系统(Symbian系统)是塞班公司为手机而设计的操作系统,它的前身是英国宝意昂公司的 EP ( Electronic Piece of cheese)操作系统。
社区管理员
  • Symbian社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧