#include "PCOMM.H" //百度下载"PCOMM.DLL"
int Port = 1; //COM号
if (SIO_OK == sio_open(Port))
{
sio_ioctl(Port, B9600, BIT_8 | STOP_1 | P_NONE);
sio_cnt_irq(Port, CntIrq, 1); //注册回调事件函数
// str.Format(L"%d", Port);
// UpdateEvent(L"通信初始化完成");
}
else
{
//UpdateEvent(L"串口打开失败");
}
void CALLBACK CAutoVisionDlg::CntIrq(int lParam)
{
//BYTE rxdata[1024];
//memset(rxdata, 0, 1024);
//int ch;
//ch = sio_getch(lParam);
char buf[8];
sio_read(lParam, buf, 1);
if (buf[0] == 40)
{
Sleep(10);
sio_read(lParam, buf, 7);
if (buf[5] == 41)
{
//m_SendCom = true;
time_b = timeGetTime() - time_a; //计算通信时间
MyDlg->BianHao = buf[0];
// MyDlg->StrCom[1] = MyDlg->BianHao;
sio_write(MyDlg->Port, MyDlg->StrCom, 8);
time_a = timeGetTime();
}
sio_flush(lParam, 2);
}
//sio_flush(lParam, 2);
}