Article View: comp.os.ms-windows.programmer.networks
Article #31Re: Re-active modem transmission in async. mode
From: Jiri Schacherl
Date: Fri, 30 Apr 1999 00:00
Date: Fri, 30 Apr 1999 00:00
51 lines
2308 bytes
2308 bytes
Try this:
set timeouts to 15,20,50,15,20
DWORD SendData(HANDLE Comm,void* Data,DWORD Size,DWORD Timeout)
{
DWORD BytesWritten=0;
OVERLAPPED op;
memset(&op,0,sizeof(op));
op.hEvent=CreateEvent(NULL,TRUE,FALSE,NULL);
WriteFile(Comm,Data,Size,&BytesWritten,&op);
if (Timeout && WaitForSingleObject(op.hEvent,Timeout)==WAIT_OBJECT_0)
GetOverlappedResult(Comm,&op,&BytesWritten,TRUE);
CloseHandle(op.hEvent);
return BytesWritten;
}
if this function returns less bytes send than you want then clear out buffer
PurgeComm(ModemFile, PURGE_TXABORT | PURGE_TXCLEAR);
and continue with sending data
Sachy
DONG wrote in message
>In my modem communication software, I use the async. I/O mode for data
>transmission. I defines an Overlap event and then pass it to the writefile
>call.
>
>Before each WriteFile call, I wait for the Overlap event turning to
>singaled state.
>
>But several minutes after the start of transmission, I found that the
>transmission is interrupted and the overlap event remains always
>non-signaled. So I try to restart the transmission with the following
>instructions:
>
> ClearCommError(ModemFile, &dwError,&dwStatus);
> PurgeComm(ModemFile, PURGE_TXABORT | PURGE_TXCLEAR);
> SetEvent(TxOverlap.hEvent);
>
>The modem transmission remains suspended. I have tried to add
>SetCommBreak(.) and ClearCommBreak(). No effect.
>
>Can anyone tell me what it is wrong and how to re-activate the modem
>transmission in such case?
>
>Thanks in advance.
>
>
>Lixin DONG
Technical Details
Message-ID:
<7gbthi$1l18$1@ns.felk.cvut.cz>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<01be929c$d060a260$ba4ee8c3@dong>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 113dfb,7a49e24e95184722 X-Google-Attributes: gid113dfb,public X-Google-Thread: 1053e6,7a49e24e95184722 X-Google-Attributes: gid1053e6,public X-Google-Thread: fa91f,7a49e24e95184722 X-Google-Attributes: gidfa91f,public From: "Jiri Schacherl" <Jiri.Schacherl@bcpraha.cz> Subject: Re: Re-active modem transmission in async. mode Date: 1999/04/30 Message-ID: <7gbthi$1l18$1@ns.felk.cvut.cz> X-Deja-AN: 472628986 References: <01be929c$d060a260$ba4ee8c3@dong> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4 Organization: Czech Technical University Newsgroups: comp.os.ms-windows.programmer.networks,comp.os.ms-windows.programmer.win32,fr.comp.os.ms-windows.programmation