comp.lang.ada
 help / color / mirror / Atom feed
* Low level (GNAT) Ada?
@ 1998-01-20  0:00 Matthew Kennedy
  1998-01-20  0:00 ` Stephen Leake
  1998-01-22  0:00 ` Jerry van Dijk
  0 siblings, 2 replies; 6+ messages in thread
From: Matthew Kennedy @ 1998-01-20  0:00 UTC (permalink / raw)



Hello all,

I'm using GNAT for Windows (actually NT 4 in my case).

I'd like to be able to control some purpose-built devices on the
parallel and serial ports of my PC as well as bus cards. I have searched
hard through the documentation for a library that provides
parallel/serial interfaces but they just don't exist. I haven't even
found basic C-like outb/inb functions.

Everybody keeps saying that Ada is also great for system and low level
programming but it doesn't look like it from the Windows GNAT point of
view.

BTW, does anyone know if it is possible to interface to the Windows DDE
via a GNAT package and vice-versa?

-- 
Matthew Kennedy
Student of Electrical and Electronics Engineering
University of Southern Queensland, Australia




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Low level (GNAT) Ada?
  1998-01-20  0:00 Low level (GNAT) Ada? Matthew Kennedy
@ 1998-01-20  0:00 ` Stephen Leake
  1998-01-22  0:00 ` Jerry van Dijk
  1 sibling, 0 replies; 6+ messages in thread
From: Stephen Leake @ 1998-01-20  0:00 UTC (permalink / raw)



Matthew Kennedy wrote:
> 
> Hello all,
> 
> I'm using GNAT for Windows (actually NT 4 in my case).
> 
> I'd like to be able to control some purpose-built devices on the
> parallel and serial ports of my PC as well as bus cards. I have searched
> hard through the documentation for a library that provides
> parallel/serial interfaces but they just don't exist. I haven't even
> found basic C-like outb/inb functions.
> 
> Everybody keeps saying that Ada is also great for system and low level
> programming but it doesn't look like it from the Windows GNAT point of
> view.

The "library" you are looking for is the Win32 API, provided by
Microsoft as the operating system. The OS owns the ports; you cannot
write to them directly. You need to get the Microsoft System Development
Kit (comes with the Aonix compiler; also comes with Microsoft
compilers), and read the Help file.

You need an Ada binding for the Win32 API; Win32Ada is free; Aonix sells
another (more structured?) one; RR sells a thick binding (see
www.adahome.com for sources).

To access the serial ports, you just open a file named COM1, COM2, etc.
I have not looked into writing to the parallel port; since it is named
LPT1 in DOS, you can probably get to it that way. 

> 
> BTW, does anyone know if it is possible to interface to the Windows DDE
> via a GNAT package and vice-versa?

Again, the Win32 API provides functions for doing DDE; you need the Ada
binding to those functions. I'm not sure if they are included in
Win32Ada.
> 
> --
> Matthew Kennedy
> Student of Electrical and Electronics Engineering
> University of Southern Queensland, Australia

-- 
- Stephe




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Low level (GNAT) Ada?
  1998-01-20  0:00 Low level (GNAT) Ada? Matthew Kennedy
  1998-01-20  0:00 ` Stephen Leake
@ 1998-01-22  0:00 ` Jerry van Dijk
  1998-01-22  0:00   ` Matthew Kennedy
  1998-01-22  0:00   ` Robert Dewar
  1 sibling, 2 replies; 6+ messages in thread
From: Jerry van Dijk @ 1998-01-22  0:00 UTC (permalink / raw)



In article <34C48A74.26CA@mail.connect.usq.edu.au> q9522772@mail.connect.usq.edu.au writes:

>I'd like to be able to control some purpose-built devices on the
>parallel and serial ports of my PC as well as bus cards.

Not unusual...

> I have searched
>hard through the documentation for a library that provides
>parallel/serial interfaces but they just don't exist. I haven't even
>found basic C-like outb/inb functions.

That is correct, although this has nothing to do with Ada or GNAT.
To access devices in NT your code has to run at ring 0, which means
you need a device driver for them.

Note that you can open I/O devices as files.

>Everybody keeps saying that Ada is also great for system and low level
>programming but it doesn't look like it from the Windows GNAT point of
>view.

Yes, Ada is very good at low-level programming, No, NT does not allow
you to do so in a user program. Neither can you do this in C.

Dare I say it... Yep: the easiest way to do this sort of programming
is to use a DOS compiler.

>BTW, does anyone know if it is possible to interface to the Windows DDE
>via a GNAT package and vice-versa?

Depends on what you mean. Yes, if you installed an Win32 binding you can
use it to build DDE programs the usual Win32 way. If you are trying to
find a package that offers a higher level of abstraction, I am not
aware of any freeware offerings.

--
-- Jerry van Dijk | Leiden, Holland
-- Consultant     | Team Ada
-- Ordina Finance | jdijk@acm.org




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Low level (GNAT) Ada?
  1998-01-22  0:00 ` Jerry van Dijk
@ 1998-01-22  0:00   ` Matthew Kennedy
  1998-01-24  0:00     ` Jerry van Dijk
  1998-01-22  0:00   ` Robert Dewar
  1 sibling, 1 reply; 6+ messages in thread
From: Matthew Kennedy @ 1998-01-22  0:00 UTC (permalink / raw)



OK, I need to write a device driver, no worries! 

Can I write it with GNAT? I know these things are usually written in
assembler but I'm not really wanting anything that special. Afterall
it's only talking to a logger and another PC terminal.

What about those DLL files in the system directory. I know there is a
DLL for Visual C/Basic that is specifically for serial communications.
How does one reference a DLL entry into a GNAT Ada program?

By the way, I'd rather not use DOS.

Many thanks,

Matt

Jerry van Dijk wrote:
> 
> In article <34C48A74.26CA@mail.connect.usq.edu.au> q9522772@mail.connect.usq.edu.au writes:
> 
> >I'd like to be able to control some purpose-built devices on the
> >parallel and serial ports of my PC as well as bus cards.
> 
> Not unusual...
> 
> > I have searched
> >hard through the documentation for a library that provides
> >parallel/serial interfaces but they just don't exist. I haven't even
> >found basic C-like outb/inb functions.
> 
> That is correct, although this has nothing to do with Ada or GNAT.
> To access devices in NT your code has to run at ring 0, which means
> you need a device driver for them.
> 
> Note that you can open I/O devices as files.
> 
> >Everybody keeps saying that Ada is also great for system and low level
> >programming but it doesn't look like it from the Windows GNAT point of
> >view.
> 
> Yes, Ada is very good at low-level programming, No, NT does not allow
> you to do so in a user program. Neither can you do this in C.
> 
> Dare I say it... Yep: the easiest way to do this sort of programming
> is to use a DOS compiler.

-- 
Matthew Kennedy
Student of Electrical and Electronics Engineering
University of Southern Queensland, Australia
  "When will you realise you're already there?" 
      - Marilyn Manson




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Low level (GNAT) Ada?
  1998-01-22  0:00 ` Jerry van Dijk
  1998-01-22  0:00   ` Matthew Kennedy
@ 1998-01-22  0:00   ` Robert Dewar
  1 sibling, 0 replies; 6+ messages in thread
From: Robert Dewar @ 1998-01-22  0:00 UTC (permalink / raw)



<<Dare I say it... Yep: the easiest way to do this sort of programming
is to use a DOS compiler.
>>

Actually the issue is less using a DOS compiler, than using a DOS
operating system, i.e. no operating system at all. Basically DOS is
a program loader that lets you load programs into a bare board environment,
and Jerry is quite right, if you want to mess with low level stuff like
IO ports, you don't *want* an operating system around at all! (and if
you do want to work with an OS, you are definitely in the device driver
area -- this is actually true with DOS also, if you want to "fit in"
to what little is there, you should also write a DOS device driver.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Low level (GNAT) Ada?
  1998-01-22  0:00   ` Matthew Kennedy
@ 1998-01-24  0:00     ` Jerry van Dijk
  0 siblings, 0 replies; 6+ messages in thread
From: Jerry van Dijk @ 1998-01-24  0:00 UTC (permalink / raw)



In article <34C716EC.7F0D@mail.connect.usq.edu.au> q9522772@mail.connect.usq.edu.au writes:

>OK, I need to write a device driver, no worries!
>
>Can I write it with GNAT?

I never tried it as the DDK from MS used to be rather expensive. Although
it probably could be done.

>I know these things are usually written in
>assembler but I'm not really wanting anything that special. Afterall
>it's only talking to a logger and another PC terminal.

Now, I am not sure any more what your question really is:

a) How to contol the I/O ports, bus devices, etc or
b) How access the parallel and serial ports.

I answered question (a).

You already gave the answer to question (b):

>What about those DLL files in the system directory. I know there is a
>DLL for Visual C/Basic that is specifically for serial communications.

Actually, the standard Win32 API contains everything you need. However,
it seems you are thinking in Win95 term, not NT terms. On NT there is
an added issue of security.

The problem therefor is not so much a question of Ada or GNAT but about
Win32 programming knowledge.

>How does one reference a DLL entry into a GNAT Ada program?

Usually by linking the import library to your program and calling it :-))

--

-- Jerry van Dijk | Leiden, Holland
-- Team Ada       | jdijk@acm.org




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1998-01-24  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-01-20  0:00 Low level (GNAT) Ada? Matthew Kennedy
1998-01-20  0:00 ` Stephen Leake
1998-01-22  0:00 ` Jerry van Dijk
1998-01-22  0:00   ` Matthew Kennedy
1998-01-24  0:00     ` Jerry van Dijk
1998-01-22  0:00   ` Robert Dewar

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