comp.lang.ada
 help / color / mirror / Atom feed
* NVRAM or how can I enforce a range check in Ada83.
@ 1996-11-15  0:00 Peter Vogelsanger
  1996-11-15  0:00 ` Stephen Leake
  1996-11-16  0:00 ` Ken Garlington
  0 siblings, 2 replies; 11+ messages in thread
From: Peter Vogelsanger @ 1996-11-15  0:00 UTC (permalink / 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
>




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

end of thread, other threads:[~1996-11-25  0:00 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-11-15  0:00 NVRAM or how can I enforce a range check in Ada83 Peter Vogelsanger
1996-11-15  0:00 ` 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

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