comp.lang.ada
 help / color / mirror / Atom feed
From: dennison@telepath.com
Subject: Re: Win NT + Object Ada: serial port I/O
Date: 1999/02/04
Date: 1999-02-04T00:00:00+00:00	[thread overview]
Message-ID: <79cu2a$4iu$1@nnrp1.dejanews.com> (raw)
In-Reply-To: 79952r$2t$1@nnrp1.dejanews.com

In article <79952r$2t$1@nnrp1.dejanews.com>,
  lynch@cci.de wrote:
> Does anyone have any information/experience programming serial ports in Ada on
> a Windows platform? I can think of two ways to do this:

If you mean a win32 platform, I have done that. I wrote a program to
communicate with another machine via a com port on an NT 3.5 machine using
the old vads Ada83.


> 1) Use the standard Ada.*.IO routines on the file "COM1:". I tested this with
>    a) It seems the port needs to be "initialized" by calling MODE COM1: in a
>       console window, even though the settings are exactly the same as those
>       in the windows control panel.

There's a Win32 system call to do this for you. Check your documentation.

>    b) I need a timeout capability for the reply from the LCD/Terminal.
>       Using Get or Get_Immediate without "Available" blocks indefinitely,
>       all attempts to use Get_Immediate with loops and timers have failed.
>       (Available seems to be _always_ false!?)
>
> 2) Use the Win32Ada binding with CreateFile, SetCommTimeouts etc. however the
>  help file provided with Object Ada is utterly useless. I have yet to find

I created my *own* Win32 bindings to do the job, but those are the routines I
used.

> Are there any alternative (higher-level) "COM-Port"-Bindings available?
> All I need to do is write a stream of ASCII characters and read characters
> with a timeout after x ms, in case somebody pulled the plug or whatever.

Its not quite that simple. Your serial settings have to match the settings the
machine on the other end is using. Since there's no way for a "higer-level"
binding to know that information ahead of time. You *have* to have the mode
call.

As for the writing and reading, the system calls available seem quite adequate
for the purpose.

> If anyone has some sample code that accesses a COM-port using Object Ada
> I would be most grateful for a quick peek at it! (This is my second-ever
> MS-Windows project, I hope it will be my last...)

Unfortunately, I don't have access to that code anymore, and can't transcribe
it from memory. I can tell you that I had horrible problems trying to get
good data from the port at first. The settings on both ends have to be just
right, and of course the cable has to be wired just right. You also have to
make sure no other device is using the port's IRQ (that seems to happen a lot
w/ Win95). Once it works though, its pretty clear sailing.


T.E.D.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




  parent reply	other threads:[~1999-02-04  0:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-02-03  0:00 Win NT + Object Ada: serial port I/O lynch
1999-02-03  0:00 ` news.oxy.com
1999-02-04  0:00   ` lynch
1999-02-04  0:00     ` news.oxy.com
1999-02-04  0:00 ` dennison [this message]
1999-02-04  0:00   ` Tom Moran
1999-02-16  0:00   ` lynch
1999-02-16  0:00     ` Steve Doiel
1999-02-16  0:00     ` dennison
1999-02-17  0:00       ` Peter Hend�n
1999-02-16  0:00     ` David C. Hoos, Sr.
1999-02-16  0:00       ` dennison
1999-02-16  0:00     ` dennison
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox