comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Stream_Element_Array
Date: Thu, 15 Sep 2011 17:18:28 -0700 (PDT)
Date: 2011-09-15T17:18:28-07:00	[thread overview]
Message-ID: <a833dae4-4d84-4155-93c1-1ce17585114e@a12g2000yqi.googlegroups.com> (raw)
In-Reply-To: m262ktfpp0.fsf@pushface.org

On Sep 15, 2:42 pm, Simon Wright <si...@pushface.org> wrote:
> Alexander Korolev <antonovkab...@gmail.com> writes:
> > On Sep 16, 12:11 am, Simon Wright <si...@pushface.org> wrote:
> >> Alexander Korolev <antonovkab...@gmail.com> writes:
> >> > My confusion is about the order of the Stream_Element for the cases I
> >> > posted
>
> >> That has to depend on what the thing at the other end is expecting!
>
> >> If there's no proper specification, do you maybe have some C code that
> >> we could help to work it out from?
>
> > It expecting 2 byte Lenth: |192|lenght (MSB)|Lenth (LSB)|Data|
> > checksum|
> > " The message length is a 2-byte field (MSB) equal to the size of the
> > data field and checksum
> > before byte stuffing has been executed" - from the doc
>
> I don't know what they mean by (MSB) in "a 2-byte field (MSB)".
>
> That said, it seems pretty clear that the first byte on the wire is to
> be the most significant byte of Length : Unsigned_16, so you want
> somthing like
>
>    Write (Length / 256);
>    Write (Length and 255);
>
> or maybe
>
> with Ada.Text_IO; use Ada.Text_IO;
> with Interfaces;
> procedure Streaming is
>
>    procedure Write (B : Interfaces.Unsigned_8) is
>    begin
>       Put_Line ("b => " & Interfaces.Unsigned_8'Image (B));
>    end Write;
>
>    V : Interfaces.Unsigned_16;
>
>    use type Interfaces.Unsigned_16;
>
> begin
>
>    V := 16#8180#;
>
>    Write (Interfaces.Unsigned_8 (Interfaces.Shift_Right (V, 8)));
>    Write (Interfaces.Unsigned_8 (V and 16#FF#));

Would it be useful to add a 'Stream_Element_Order attribute to the
language (somewhat analogous to 'Stream_Size) that would allow a
programmer to specify, via an aspect clause or attribute definition
clause, whether values of a given elementary type are read/written
with the most or least significant byte first?

                          -- Adam




  parent reply	other threads:[~2011-09-16  0:18 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-14  3:13 Stream_Element_Array Alexander Korolev
2011-09-14  5:29 ` Stream_Element_Array Per Sandberg
2011-09-14  8:34   ` Stream_Element_Array Alexander Korolev
2011-09-14  8:31 ` Stream_Element_Array Simon Wright
2011-09-14  9:09   ` Stream_Element_Array Alexander Korolev
2011-09-14  9:40     ` Stream_Element_Array Dmitry A. Kazakov
2011-09-14  9:41       ` Stream_Element_Array Dmitry A. Kazakov
2011-09-14 10:18         ` Stream_Element_Array Simon Wright
2011-09-14 12:42           ` Stream_Element_Array Dmitry A. Kazakov
2011-09-14 16:20             ` Stream_Element_Array Simon Wright
2011-09-14 19:53               ` Stream_Element_Array Dmitry A. Kazakov
2011-09-14 10:53       ` Stream_Element_Array Simon Wright
2011-09-14 12:48         ` Stream_Element_Array Dmitry A. Kazakov
2011-09-14 14:48           ` Stream_Element_Array Alexander Korolev
2011-09-14 15:08             ` Stream_Element_Array Dmitry A. Kazakov
2011-09-14 17:16               ` Stream_Element_Array Alexander Korolev
2011-09-14 20:13                 ` Stream_Element_Array Dmitry A. Kazakov
2011-09-14 21:29                   ` Stream_Element_Array Alexander Korolev
2011-09-15  8:20                     ` Stream_Element_Array Dmitry A. Kazakov
2011-09-15 18:58                       ` Stream_Element_Array Alexander Korolev
2011-09-15 20:48                         ` Stream_Element_Array Dmitry A. Kazakov
2011-09-16  0:20                           ` Stream_Element_Array Alexander Korolev
2011-09-15 19:15                       ` Stream_Element_Array Alexander Korolev
2011-09-15 20:11                         ` Stream_Element_Array Simon Wright
2011-09-15 20:34                           ` Stream_Element_Array Alexander Korolev
2011-09-15 21:42                             ` Stream_Element_Array Simon Wright
2011-09-15 21:50                               ` Stream_Element_Array Simon Wright
2011-09-16  0:01                                 ` Stream_Element_Array Alexander Korolev
2011-09-16  0:18                               ` Adam Beneschan [this message]
2011-09-16  7:22                                 ` Stream_Element_Array Dmitry A. Kazakov
2011-09-16 10:21                                   ` Stream_Element_Array Simon Wright
2011-09-16 12:13                                     ` Stream_Element_Array Dmitry A. Kazakov
2011-09-16 17:20                                       ` Stream_Element_Array Simon Wright
2011-09-16 19:32                                         ` Stream_Element_Array Dmitry A. Kazakov
2011-09-16 22:18                                           ` Stream_Element_Array Simon Wright
2011-09-17  8:18                                             ` Stream_Element_Array Dmitry A. Kazakov
2011-09-19 23:22                                   ` Stream_Element_Array Randy Brukardt
2011-09-15 21:28                           ` Stream_Element_Array Alexander Korolev
2011-09-15  2:33                   ` Stream_Element_Array Alexander Korolev
2011-09-19 23:11           ` Stream_Element_Array Randy Brukardt
2011-09-14 12:19 ` Stream_Element_Array Gautier write-only
2011-09-16 11:17 ` Stream_Element_Array 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