S0S: 帮忙看看串口程序了!
帮忙看看了,为什么一发包程序就死
好像OVERLAPPED事件没返回
BOOL PutPacket(UINT8* pcData, UINT32 uwLength)
{
OVERLAPPED overlapped;
overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); /* create OVERLAPPED event */
if(uwLength > 0x0000) /* have packet to be send */
{
if( ! WriteFile( hCom, /* fail to complete sending packet */
poutPacket,
OutputLen,
&dwTransmissionLength,
&overlapped)
)
{
if (GetLastError() != ERROR_IO_PENDING) /* fail to write */
{
return FALSE;
}
else /* write is going on */
{
if (!GetOverlappedResult(hCom, &overlapped, &dwTransmissionLength, TRUE)) /* detech writing operation completion */
{
return FALSE;
}
}
}
}
free((UINT8 *)poutPacket); /* free data memory */
CloseHandle(overlapped.hEvent);
return TRUE;
}