龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 软件开发 > VC开发 >

用VC实现多串口多线程工业控制(4)

时间:2009-12-30 15:42来源:未知 作者:admin 点击:
分享到:
void CMy11View::ResetBuffVal() { for(int i=0;i1000;i++) m_RecBuff[i] = 0; } 至此,基本的通讯外围程序基本完成,如果我们要扩充多个串口多线程的话,我们可以做如下修

void CMy11View::ResetBuffVal()
{
 for(int i=0;i<1000;i++)
  m_RecBuff[i] = 0;
}

  至此,基本的通讯外围程序基本完成,如果我们要扩充多个串口多线程的话,我们可以做如下修改:

CSerialPort m_Ports[20];
BYTE m_RecBuff[20][1000];
BYTE m_SendBuff[5][1000];
int nColts[20];
int nZBKType[24];
int nWrongCount[20][20];
int nColtAddr[20];
HANDLE m_pThread;

//Protect Device
if(this->m_Ports[0].InitPort(this,2,9600,'N',8,1,EV_RXCHAR|EV_RXFLAG,1024))
{
 this->m_Ports[0].StartMonitoring();
 SetComBufferVal(0);
}
//Diandu Device
if(this->m_Ports[1].InitPort(this,4,1200,'E',8,1,EV_RXCHAR|EV_RXFLAG,1024))
{
 this->m_Ports[1].StartMonitoring();
 SetComBufferVal(1);

  我们对各种发送命令函数进行载入形参的方法来解决。

精彩图集

赞助商链接