cnComm
DCB* pDcb = m_SerialCnCom.GetState();
pDcb->BaudRate = 115200 ;
pDcb->ByteSize = 8 ;
pDcb->StopBits = 0;
pDcb->Parity = 0 ;
唤醒读卡器:
void CNFCReaderDlg::OnBtnWakeReader()
{
// TODO: Add your control notification handler code here
unsigned char WakeCode[]={
0x55,0x55,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0xFF,0x03,0xFD,0xD4,
0x14,0x01,0x17,0
};
if(m_bSerialCnComOpened){
m_SerialCnCom.WritePort(WakeCode,sizeof(WakeCode));
}
}
返回数据:
00 00 FF 00 FF 00 00 00 FF 02 FE D5 15 16 00
00 00 ff 00 ff 00 00 00 ff 02 fe d5 15 16 00
Wait
len =15
00 00 FF 00 FF 00 00 00 FF 02 FE D5 15 16 00
代码: VC 控制台程序
// TestCnmmSerial.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "CnComm.h"
class HelloComm : public CnComm
{ //! \sa CnComm::OnReceive()
void OnReceive()
{
char buffer[1024];
int len = Read(buffer,1023);
printf("len =%d\r\n",len);
for(int i=0;i <len;i++){
printf("%.2X ",(unsigned char)buffer[i]);
}
}
};
int _tmain(int argc, _TCHAR* argv[])
{
unsigned char WakeCode[]={
0x55,0x55,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0xFF,0x03,0xFD,0xD4,
0x14,0x01,0x17,0
};
HelloComm Com;//! 默认模式 重叠IO 监视线程
Com.Open(12, 115200);
Com.WritePort(WakeCode,sizeof(WakeCode));
printf("Wait\r\n");
getchar();
printf("Exit\r\n");
return 0;
}
备忘 ,有空完善一下