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 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!news1.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Port LPT + ADA (whta do I wrong?) Date: Tue, 7 Dec 2004 21:55:20 +0100 Organization: cbb software GmbH Message-ID: <1olbt9ia2fuuo$.qbyglb1cl3g8.dlg@40tude.net> References: <1gr5159dmj2vk.5tkxiw6kxrmv.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: individual.net bNL0G8fEEWYtsTE9hXopJQlrJZWDFXXaNPISvk5tGd0aPX0vo= User-Agent: 40tude_Dialog/2.0.12.1 Xref: g2news1.google.com comp.lang.ada:6822 Date: 2004-12-07T21:55:20+01:00 List-Id: On Tue, 7 Dec 2004 19:13:52 +0100, Slawo - MIR wrote: > O.K., but it still doesn't read :| > I did it all you wrote, and now the LPT_Error is raised :-(, and nothing is > read from LPT port :( This is another error. Unlike the previous one it has nothing to do with Ada. Refer Windows API for the error reason. > struktura: aliased Win32.Winbase.OVERLAPPED; > > struktura.Offset := 16#01#; > > if > Win32.Winbase.Readfile(hLPT,st'address,Dword(1),read'access,struktura'access > ) = Win32.False then > > Put_Line ("Nie udalo sie odczytac z LPT"); > > raise LPT_Error; --this exception is raised > > end if; > > stan := st; > > I try to assingn to variable (field of record) "struktura.Offset" and to > "struktura.OffsetHigh" some different values - 16#379# (address of input > register), 16#01#... and it didn't work :( > > Help, someone ! :( 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. 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