From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Using representation clauses in networking software
Date: Sun, 15 Aug 2010 16:32:47 +0200
Date: 2010-08-15T16:32:45+02:00 [thread overview]
Message-ID: <43fkp7an4c5m$.3db3n6adym42.dlg@40tude.net> (raw)
In-Reply-To: op.vhhe4kqfule2fv@garhos
On Sun, 15 Aug 2010 15:44:34 +0200, Yannick Duch�ne (Hibou57) wrote:
(I agree with what you wrote. I am programming a lot of communication
stuff, but never used representation clauses to handle endianness.)
> I do not know neither any representation clause for Byte Ordering.
Byte ordering is what S'Bit_Ordering is, when bytes are addressable.
IMO, Bit_Ordering was an unfortunate choice. The attribute name suggests
ordering of bits in some machine storage unit, which it is not.
> Just to try to meet your request (something else later) : I do not know a
> way to have a method which would automatically know the bit order of its
> platform,
Bit order is useless if bits are not directly addressable.
> except perhaps receiving a standard data, like 16#1234#
> (0x1234), and then check if it looks like 16#3412# or like 16#1234#.
This would determine byte ordering. Bit ordering is when you serialize a
sequence of bits {0, 0, 0, 0, 0, 0, 0, 1} and get 2#1000_0000# (little
endian) 2#0000_0001# (big endian).
Most types of hardware have opaque bytes compatible with the machine, e.g.
UARTs. If the hardware is not, then representation clause would not be my
choice anyway. I would recode bytes or whatever units immediately as
obtained from the device:
type Strange_Octet is mod 2**8;
Decode_Strange_Octet : array (Strange_Octet) of Unsigned_8 :=
( 2#0000_0001# => 2#0000_1000#,
2#0000_0010# => 2#0000_0100#,
2#0000_0011# => 2#0000_1100#,
...
);
> Or else you may suggest it for a future Ada revision (via this newsgroup
> or else ada-auth.org ).
One could introduce enumeration representation clauses for modular types,
e.g.
type Strange_Octet is mod 2**8;
for Strange_Octet use (2#0000_0001# => 2#0000_1000#, ...);
Better would be to allow user-defined integer literals, so that the
programmer could define its own type.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2010-08-15 14:32 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-15 11:33 Using representation clauses in networking software Florian Weimer
2010-08-15 13:44 ` Yannick Duchêne (Hibou57)
2010-08-15 14:32 ` Dmitry A. Kazakov [this message]
2010-08-15 14:44 ` Florian Weimer
2010-08-15 15:04 ` Dmitry A. Kazakov
2010-08-15 15:32 ` Florian Weimer
2010-08-15 16:10 ` Dmitry A. Kazakov
2010-08-15 16:40 ` Yannick Duchêne (Hibou57)
2010-08-15 17:58 ` Dmitry A. Kazakov
2010-08-15 19:11 ` Shark8
2010-08-15 19:15 ` Simon Wright
2010-08-15 20:25 ` Maciej Sobczak
2010-08-15 21:24 ` Simon Wright
2010-08-16 6:40 ` Dmitry A. Kazakov
2010-09-04 20:46 ` Florian Weimer
2010-08-15 15:39 ` Yannick Duchêne (Hibou57)
2010-08-15 15:31 ` Yannick Duchêne (Hibou57)
2010-08-15 15:30 ` Yannick Duchêne (Hibou57)
2010-08-15 16:10 ` Dmitry A. Kazakov
2010-08-16 10:57 ` Stephen Leake
2010-08-15 15:58 ` Simon Wright
2010-08-15 16:03 ` Florian Weimer
2010-08-17 3:32 ` Randy Brukardt
2010-08-16 9:12 ` anon
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox