上位机笔记

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/bigtree_mfc/article/details/52278405

BOOL g_Comstate = false;

int port = 1;
CString c_return = "";
void OnConnect();
void OnBreack();

afx_msg LONG OnCommunication(WPARAM ch, LPARAM port);

ON_MESSAGE(WM_COMM_RXCHAR, OnCommunication)

LONG CPortView::OnCommunication(WPARAM ch, LPARAM port)

1、

if(!g_Comstate)

m_Commport.InitPort(this,port,9600,'n',8,1,EV_RXCHAR|EV_CTS,1024)
m_Commport.StartMonitoring();
m_Commport.WriteToPort((char *)(LPCTSTR)"(01X)");

2、

19200

3、

if(ch=='(')c_return="(";
else c_return+=(char)ch;
if(c_return == "(01helloa)");
return 0;

注:单击联机,监听返回,判断断开

展开阅读全文

没有更多推荐了,返回首页