Re: Writing to Serial Port

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

From: Joseph M. Newcomer (newcomer_at_flounder.com)
Date: 03/01/05


Date: Tue, 01 Mar 2005 13:10:45 -0500

Yes. The only reason to wait is to simplify the programming. If you are doing multiple
WriteFile operations, you need to have multiple OVERLAPPED structures, and perhaps even
multiple events. These days, since I no longer have to run on obsolete technologies like
MS-DOS (Win9x/Me), I use I/O Completion Ports to handle completion notifications. If you
don't care about completion notifications, you can even ignore GetOverlappedResult,
although if there is an error with the port you would then be in trouble.

As already pointed out, the offset value in a serial port has no meaning, so there is no
reason to update it, or even care about it.
                                        joe

On Tue, 1 Mar 2005 17:47:25 +0100, "Øyvind Hansen" <oyvind@scantrol.no> wrote:

>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]
>>
>

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm



Relevant Pages

  • Re: Search for cut-price InterCity 125 upgrade
    ... Nope because, unlike the HST, they can work in multiple. ... Is there any reason that HST's can't work in multiple apart from the ... you can remotely control one power car it shouldn't be too difficult ... omission of the requisite control equipment there was no provision for the ...
    (uk.railway)
  • Re: MDI and headaches.
    ... Assuming your multiple page document was created in Word 2007, you can click on Office Button | Save As, save the file as a Word 97-2003 .doc file, and email that to your recipient. ... the format it prints to is MDI by default. ... For whatever reason, I can not get this tiffile to ...
    (microsoft.public.office.misc)
  • Re: Question about scanning negatives
    ... The reason is the smaller versions are going ... to be much easier to make multiple backups of. ... and good to have all of your massive images on one huge ... In many cases more then 95% of the real information in a photo ...
    (rec.photo.digital)
  • Re: Intel Inside!!!
    ... a multi-CPU set-up will help you run ... >other things at the same time, or multiple instances. ... And the main reason for that finally happening is that ... It's still possible for a program to hog a fast CPU, ...
    (uk.comp.sys.mac)