此帖出自嵌入式系统论坛
最新回复
结贴了
忽略了 CE是不支持重叠方式的 WriteFile(hcom,buffer,2,&pt,NULL);最后一个参数应该为NULL
代码如下:供大家参考 谢谢各位
void SendData(LPCSTR buffer,int count)
{
HANDLE hComm=INVALID_HANDLE_VALUE;
COMMTIMEOUTS CommTimeOuts;
RECT rect={20,20,60,60};
hComm=CreateFile(_T("COM1:"),GENERIC_WRITE|GENERIC_READ,0,0,OPEN_EXISTING,0,0);
if(hcom==INVALID_HANDLE_VALUE)
{
DrawText(hdc,L"open com fail",14,&rect,DT_CENTER);
return;
}
GetCommState(hComm,&dcb);
dcb.BaudRate=CBR_9600;
dcb.fBinary=TRUE;
dcb.fParity=FALSE;
dcb.ByteSize=8;
dcb.Parity=NOPARITY;
dcb.StopBits=ONESTOPBIT;
dcb.fRtsControl=0;
dcb.fDtrControl=0;
SetCommMask(hComm,EV_RXCHAR);
SetupComm(hComm,16384,16384);
SetCommState(hcom,&cc.dcb);
PurgeComm(hComm,PURGE_TXCLEAR|PURGE_RXCLEAR);
WriteFile(hComm,buffer,count,&pt,NULL);
}
详情
回复
发表于 2010-4-20 09:40
| ||
|
||
此帖出自嵌入式系统论坛
| ||
|
||
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
此帖出自嵌入式系统论坛
| ||
|
||
此帖出自嵌入式系统论坛
| ||
|
||
| |
|
|
此帖出自嵌入式系统论坛
| ||
|
||
| |
|
|
| |
|
|
此帖出自嵌入式系统论坛
| ||
|
||
| |
|
|
| |
|
|
此帖出自嵌入式系统论坛
| ||
|
||
EEWorld Datasheet 技术支持