From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,d0077c2a3f44fc09 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local1.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Tue, 07 Dec 2004 22:28:06 -0600 From: "Steve" Newsgroups: comp.lang.ada References: <1gr5159dmj2vk.5tkxiw6kxrmv.dlg@40tude.net> <1olbt9ia2fuuo$.qbyglb1cl3g8.dlg@40tude.net> Subject: Re: Port LPT + ADA (whta do I wrong?) Date: Tue, 7 Dec 2004 20:28:11 -0800 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Original Message-ID: NNTP-Posting-Host: 24.22.63.157 X-Trace: sv3-EsC7AdX1NIvxoqWRrp+jRBwDOFPeJSL4T/Z9msgONEIJ6tLq3F8SkGmFZmqINvuRcypS+6KvZYsQuIk!PNVF9whj9Voaj16/x1ynfQaNgEBqIERoEbMS5kXpNN9dD/s9BZvPZY/a7lMl X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.20 Xref: g2news1.google.com comp.lang.ada:6829 Date: 2004-12-07T20:28:11-08:00 List-Id: "Dmitry A. Kazakov" wrote in message news:1olbt9ia2fuuo$.qbyglb1cl3g8.dlg@40tude.net... > On Tue, 7 Dec 2004 19:13:52 +0100, Slawo - MIR wrote: [snip] > > Calm down, you'll get it! (:-)) > > 1. Do you really need overlapped I/O? This requires a lot of understanding > of how Windows works. Note that overlapped I/O is asynchronous to the > calling thread. It means that ReadFile will not wait for any data. It will > end immediately. After that you should periodically check the fields of > the > OVERLAPPED structure for the results. Alternatively you can provide an > event object and enter wait for I/O completion (see WaitForSingleObject). > Note also that overlapped I/O fails at the file end (i.e. whne nobody > writes into the port). Maybe that's the case. Carefully read what MSDN > tells about ReadFile and OVERLAPPED. Unless you're speaking about something specific to handling of the parallel port, I can say for certain that with serial I/O you must use OVERLAPPED I/O if you want to do full duplex communication. This is not obvious from the documentation, but if you dig far enough (and try it) you'll find that this is the case. Using overlapped I/O does NOT mean that ReadFile will not wait for any data before returning. It does mean that if ReadFile returns FALSE, then you'll have to call "WinBase.GetLastError" to get the error code, and if the error code is "ERROR_IO_PENDING" than you'll have to read again. In my serial driver I do exactly that. Before using OVERLAPPED operations I found the little ideosyncracy that if I had one thread waiting on a read, another thread couldn't do a write until the read finished. Using overlapped the write causes the read to wake up, the write does it's thing. When my code detects that the read hasn't finished, it goes back and reads again. A pain in the butt, but it works. I remember finding an article on Microsofts site describing overlapped I/O and how it was a new and special feature that they had implemented. That was news to me since I have written communications applications on other operating systems where you don't have to do anything special to have a read task and a write task work on the same communications port. This isn't really an Ada question, you should try searching microsoft's site for specific information regarding the parallel port. If you use google you can make your search something like: site:microsoft.com and it will restrict the search to the microsoft site. Sometimes this saves sifting through a bunch of garbage (sometimes not). I hope this helps, Steve (The Duck) > > 2. When a Windows API fails, you should query for the failure reason using > GetLastError. Do it! Further, apply FormatMessage to the result of > GetLastError. Then you will exactly know what's going on. > > Good luck! > > -- > Regards, > Dmitry A. Kazakov > http://www.dmitry-kazakov.de