TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Classic View

Use Proportional Font
Show Text Part by Default
Condense Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Sender: "Team Ada: Ada Advocacy Issues (83 & 95)" <[log in to unmask]>
X-To: Tecnosistemi BCN <[log in to unmask]>
Date: Tue, 9 Apr 2002 08:11:21 -0500
Reply-To: "David C. Hoos" <[log in to unmask]>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="iso-8859-1"
From: "David C. Hoos" <[log in to unmask]>
Parts/Attachments: text/plain (97 lines)
Hi Carlos,

Your approach to the problem is flawed.  The address to which you
mapped Device'Address is a memory (RAM) address within the
virtual address space of your executable.  It is not an I/O address.

The reason you got an exception, is that address 16#378# within
a program's virtual memory space is not accessible by User code.

For a technique which will work in a DOS window on Windows 9X
platforms, see http://users.ncrvnet.nl/gmvdijk/other_os.html#PORTS

However, this approach requires GNAT for DOS available at
http://www.mysunrise.ch/users/gdm/gnatdos.htm

It would be helpful to know what you are trying to do with the
parallel port -- perhaps there's a higher-level way to do what
you want to do.

David Hoos

P.S. Attachments to E-mail are not allowed on this list, so your
.exe was deleted, and the source code made a part of the message
text.

----- Original Message -----
From: "Tecnosistemi BCN" <[log in to unmask]>
To: <[log in to unmask]>
Sent: Tuesday, April 09, 2002 7:17 AM
Subject: parallel port control


> Hi,
> I get a exception while running the program. The
> compilations is OK.
> I attach the source and the .exe.
>
> I'm not sure if Ada can manage devices over the
> Windows Layer.
>
> Anybody can take a look to it?
>
> Carlos
>
> PS: Tested on Pentium, 32Mb RAM, Windows 98 SE
> 4.10.2222A
> compiled with GNAT 3.13p
>
> ------- Here starts the source -----
> --with Text_Io;
> --use Text_Io;
> with Ada.Integer_Text_Io;
> use Ada.Integer_Text_Io;
> with System;
> use System;
>
> procedure Prueba is
>    type Flags is mod 2**24; -- 3 bytes for control,
> data , status
>    F : Flags;
>    type Recurso is
>       record
>          Estado : Flags;
>       end record;
>
>    Device    : Recurso;
>    Direccion : System.Address := System'To_Address
> (16#378#);
>    -- LPT1 configured as standard bidi.
>    for Device'Address use Direccion;
>    --   pragma Atomic (device);
>    --   pragma Import (Ada, device);
>
>
>
> begin
>
>    F:=Device.Estado;
>   -- PROGRAM_ERROR: EXCEPTION_ACCESS_VIOLATION
>    --Put (Integer (F));
>    null;
>
>    --exception
>
>    --   when others =>
>    --      Put (Integer (device.Estado));
>
> end Prueba;
>
>
> _______________________________________________________________
> Do You Yahoo!?
> Yahoo! Messenger
> Comunicación instantánea gratis con tu gente.
> http://messenger.yahoo.es
>

ATOM RSS1 RSS2