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,ASCII Received: by 10.68.34.33 with SMTP id w1mr1319229pbi.27.1316132308441; Thu, 15 Sep 2011 17:18:28 -0700 (PDT) Path: m9ni7124pbd.0!nntp.google.com!news1.google.com!postnews.google.com!a12g2000yqi.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Stream_Element_Array Date: Thu, 15 Sep 2011 17:18:28 -0700 (PDT) Organization: http://groups.google.com 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> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 X-Trace: posting.google.com 1316132308 2397 127.0.0.1 (16 Sep 2011 00:18:28 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 16 Sep 2011 00:18:28 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: a12g2000yqi.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: ARLUEHNKC X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C),gzip(gfe) Xref: news1.google.com comp.lang.ada:17985 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2011-09-15T17:18:28-07:00 List-Id: On Sep 15, 2:42=A0pm, Simon Wright wrote: > Alexander Korolev writes: > > On Sep 16, 12:11=A0am, 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 > > =A0 =A0Write (Length / 256); > =A0 =A0Write (Length and 255); > > or maybe > > with Ada.Text_IO; use Ada.Text_IO; > with Interfaces; > procedure Streaming is > > =A0 =A0procedure Write (B : Interfaces.Unsigned_8) is > =A0 =A0begin > =A0 =A0 =A0 Put_Line ("b =3D> " & Interfaces.Unsigned_8'Image (B)); > =A0 =A0end Write; > > =A0 =A0V : Interfaces.Unsigned_16; > > =A0 =A0use type Interfaces.Unsigned_16; > > begin > > =A0 =A0V :=3D 16#8180#; > > =A0 =A0Write (Interfaces.Unsigned_8 (Interfaces.Shift_Right (V, 8))); > =A0 =A0Write (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