| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 629 人关注过本帖
标题:关于串口通信
只看楼主 加入收藏
shi625628276
Rank: 1
等 级:新手上路
帖 子:26
专家分:9
注 册:2011-9-2
结帖率:75%
收藏
 问题点数:0 回复次数:3 
关于串口通信
在串口通信的接收使用了\r\n进行换行,但是在保存的时候怎么把\r\n消除掉?
搜索更多相关主题的帖子: 通信 
2011-09-06 15:54
shi625628276
Rank: 1
等 级:新手上路
帖 子:26
专家分:9
注 册:2011-9-2
收藏
得分:0 
void CCommWizardDlg::OnSavedata()
{
    // TODO: Add your control notification handler code here
     UpdateData(TRUE);
  int nLength;
nLength=m_strCurPath.GetLength();
for(int nCount=0;nCount<nLength;nCount++)
{
  if(m_strCurPath.GetAt(nCount)=='\\')
      CreateDirectory(m_strCurPath.Left(nCount+1),NULL);
}
CreateDirectory(m_strCurPath,NULL);
CFile m_nFile;
LPCSTR  lpszPath=m_strCurPath;
SetCurrentDirectory(lpszPath);
char buf[30];
for(int j=0;j<100;j++)
{
   sprintf(buf,"Rec%02d.txt",j);
}
if(!m_nFile.Open(buf,CFile::modeCreate|CFile::modeWrite))
{
  AfxMessageBox("创建记录文件失败");
  return;
}
CTime t=CTime::GetCurrentTime();//获取系统日期  
CString str=t.Format("%Y年%m月%d日%H时%M分%S秒\r\n");  
m_nFile.Write((LPCSTR)str,str.GetLength());
m_nFile.Write((LPCSTR)m_strReceive,m_strReceive.GetLength());
m_nFile.Flush();
m_nFile.Close();
}

void CCommWizardDlg::OnDirbrowser()
{
    // TODO: Add your control notification handler code here
    static char displayname[MAX_PATH];
    static char path[MAX_PATH];
    LPITEMIDLIST pidlBrowse;
    BROWSEINFO bi;
    bi.hwndOwner=this->m_hWnd;
    bi.pidlRoot=NULL;
    bi.pszDisplayName=displayname;
    bi.lpszTitle=("请选择要保存接收数据的文件夹");
    bi.ulFlags=BIF_EDITBOX;
    bi.lpfn=NULL;
    pidlBrowse=SHBrowseForFolder(&bi);
    if(pidlBrowse!=NULL)
    {
      SHGetPathFromIDList(pidlBrowse,path);
    }
    CString str=path;
    if(str.IsEmpty())return;
    m_strCurPath=str;
    UpdateData(false);
}
2011-09-06 16:20
lvduan
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2011-9-7
收藏
得分:0 
我根本就看不懂
2011-09-08 14:59
BeyondXX
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2013-5-10
收藏
得分:0 
内容好深奥啊,只能看懂个结构
2013-05-10 00:48
快速回复:关于串口通信
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015485 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved