这个程序非常好,使用微软的Mscomm1控件进行串口通信。
但是这个程序没有串口助手里16进制显示功能,通过修改源码MSCommProDlg.cpp 241左右:
wsprintf(pCommStr, _T("%.2X"), str[0]&0xff); m_strReceive=m_strReceive+pCommStr+_T(" ");//添加回车换行 m_lineNum++; if (m_lineNum > 6) { m_strReceive += _T("\r\n"); m_lineNum = 0; }
其中,在这个函数开始处定义:wchar_t* pCommStr = new wchar_t[200];
并且在MSCommProDlg.h中定义类属性:
int m_lineNum;
在类的构造函数中进行初始化:
CMSCommProDlg::CMSCommProDlg(CWnd* pParent /*=NULL*/) : CDialog(CMSCommProDlg::IDD, pParent) , m_strReceive(_T("")) , m_strSend(_T("")) , m_time(0) , m_lineNum(0) {
......
谢谢! |