From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,7e490a18b9688bd9 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,UTF8 Received: by 10.68.66.161 with SMTP id g1mr1241771pbt.10.1316122924654; Thu, 15 Sep 2011 14:42:04 -0700 (PDT) Path: m9ni7051pbd.0!nntp.google.com!news1.google.com!goblin3!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Stream_Element_Array Date: Thu, 15 Sep 2011 22:42:03 +0100 Organization: A noiseless patient Spider Message-ID: References: <1e6rw4vto3ldb.i8d7fxixapx4.dlg@40tude.net> <28u4e86fk8gn$.ialexttobgr0$.dlg@40tude.net> <276b8d0a-5b3c-4559-a275-98620657cc2f@s30g2000pri.googlegroups.com> <01c12338-e9f8-49ab-863d-c8282be3875e@g31g2000yqh.googlegroups.com> <1esmml9qftomp.vihelaijmcar$.dlg@40tude.net> <02671fc7-5c38-42dc-8017-529f6dead8fd@j19g2000yqc.googlegroups.com> <631f3859-8118-4f4c-a684-152ee5f589bf@o15g2000vbe.googlegroups.com> Mime-Version: 1.0 Injection-Info: mx04.eternal-september.org; posting-host="dFCm8HWntFqmDIilBLqEJQ"; logging-data="20445"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18VE4exf9Hu50jBRfyYrMERGN4mpJXgeaU=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (darwin) Cancel-Lock: sha1:Yrp2EdWU9uA3Jp4r+kHN/IrSRlk= sha1:XxEt51oTwk/kp/zqrXnTNaE3LD8= Xref: news1.google.com comp.lang.ada:17982 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Date: 2011-09-15T22:42:03+01:00 List-Id: Alexander Korolev writes: > On Sep 16, 12:11 am, Simon Wright wrote: >> Alexander Korolev 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