From: Peter Vogelsanger <czvop@OCAG.CH>
Subject: NVRAM or how can I enforce a range check in Ada83.
Date: 1996/11/15
Date: 1996-11-15T00:00:00+00:00 [thread overview]
Message-ID: <9611150709.AA09539@algol.ocag.ch> (raw)
Hello Ada people (or fans ;-))
We are useing a Non Volatile RAM (EEPROM) in our project. The NVRAM driver
accesses the hardware by word operations. Now we've programmed a generic driver
which transform the generic type to a byte or word array. Because of the
possibility of an hardware error, we have to check the read values from the
NVRAM. We use an unchecked_conversion to transform from byte array to the
generic type. We have got no informations about the type inside this generic
procedure.
Code:
generic
type Elements is private;
procedure Read (Item : out Elements);
procedure Read (Item : out Elements) is
function Convert is new Unchecked_Conversion (Source => <<byte array>>,
Target => Elements);
begin
Item := Convert (<<Nvram_Byte_Array_Of_Element_Size>>);
end Read;
The Unchecked_Conversion does not make any checks, therefore the name unchecked.
We've tried to use a temporary variable to assigne the unchecked_converion
value and then assigne our parameter with this temporary variable and hoped
that a check would be performed.
begin
Temp := Convert(<<Nvram_Byte_Array_Of_Element_Size>>);
Item := Temp;
exception
when constraint_error =>
<< some critical action>>
end Read;
But as I've read later the Reference Manual, I've seen that no range check are
done by an assignment.
Now is there a construct that enforce the compiler to make a range check? But
remember in this generic procedure we haven't got any type information.
Also important: we use Ada83.
Has somebody any idea about this problem?
Best Regards
Peter
>
next reply other threads:[~1996-11-15 0:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-11-15 0:00 Peter Vogelsanger [this message]
1996-11-15 0:00 ` NVRAM or how can I enforce a range check in Ada83 Stephen Leake
1996-11-16 0:00 ` Ken Garlington
1996-11-17 0:00 ` Robert Dewar
1996-11-17 0:00 ` Robert A Duff
1996-11-18 0:00 ` Robert Dewar
1996-11-19 0:00 ` Robert A Duff
1996-11-22 0:00 ` Ken Garlington
1996-11-22 0:00 ` Robert Dewar
1996-11-25 0:00 ` Ken Garlington
1996-11-19 0:00 ` Laurent Guerby
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox