comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Stream_Element_Array
Date: Thu, 15 Sep 2011 22:42:03 +0100
Date: 2011-09-15T22:42:03+01:00	[thread overview]
Message-ID: <m262ktfpp0.fsf@pushface.org> (raw)
In-Reply-To: 631f3859-8118-4f4c-a684-152ee5f589bf@o15g2000vbe.googlegroups.com

Alexander Korolev <antonovkablog@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#));

end Streaming;

The output is

$ ./streaming 
b =>  129
b =>  128



  reply	other threads:[~2011-09-15 21:42 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                             ` Simon Wright [this message]
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                               ` Stream_Element_Array Adam Beneschan
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