Re: Writing to Serial Port

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Øyvind Hansen (oyvind_at_scantrol.no)
Date: 03/01/05


Date: Tue, 1 Mar 2005 17:47:25 +0100

In other words it is not necessary to Wait forSingleObject() when using
ovelapped I/O.
I can run WriteFile() and allow my program to run without waiting for the
data being transmitted?

Oyvind

"Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp> skrev i melding
news:eqG9gPmHFHA.3208@TK2MSFTNGP10.phx.gbl...
> Oyvind Hansen wrote:
> > For transm,itting data on a serialport i am opening the port for
overlapped
> > operation and I am using the WriteFile() function for writing to the
port.
> > This works well, however i found an example in "Visual C++ Bible" where
the
> > author is using WaitForSingleObject() before running
GetOverlappedResult()
> > and setting.offset of the OVERLAPPED structure. This will block the
> > transmittdata function, and I can not really see a good reason for why
doing
> > that. Appreciate if someone could explain this...
> >
>
> This is overlapped I/O. One reason for doing it is that it is necessary
> to use overlapped I/O with a serial port if one wants full duplex (send
> while receive) operation. Another (possible) reason for doing it is so
> the code can do something else (such as read from socket or file) while
> the WriteFile is in progress. It is not necessary to increment the
> .Offset member.
>
> --
> Scott McPhillips [VC++ MVP]
>



Relevant Pages

  • Re: WriteFile()
    ... whether the I/O is synchronous or asynchronous doesn't change anything. ... With a direct-access storage device file, one can expect that WriteFile ... The ReadFile() analogy was poor and finally, ... >> documentation on the expected behavior of Read/WriteFile. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: WriteFile()
    ... whether the I/O is synchronous or asynchronous doesn't change anything. ... With a direct-access storage device file, one can expect that WriteFile ... Again, when a timeout concept is NOT part of the design, a BLOCK call can ... let's apply your argument to ReadFile. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Palatable Windows IO using Ada
    ... This is a higher level protocol. ... So the communication item becomes one byte. ... In my opinion it is overkill to use overlapped I/O for serial ... overlapped I/O and asynchronous system trap could nicely fit to Ada's ...
    (comp.lang.ada)
  • Re: How to kill a worker thread
    ... How does the loop catch the event being trigered when WriteFile never comes ... you have not gained anything by using the worker thread. ... > send message to worker thread to initiate I/O ... > worker thread terminate received: ...
    (microsoft.public.vc.mfc)
  • Re: WriteFile()
    ... > If you design a I/O application with the concrete design criteria that ... > be no timeout and no overlapped I/O, then the I/O is basically working in ... no timeout whether that means the device is known to have no ... > values when WriteFile returns TRUE. ...
    (microsoft.public.win32.programmer.kernel)