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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4afd08be1096008a X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-07-14 09:16:41 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!213.56.195.71!fr.usenet-edu.net!usenet-edu.net!enst!enst.fr!not-for-mail From: "David C. Hoos" Newsgroups: comp.lang.ada Subject: Re: converting floats, ints byte arrays Date: Fri, 13 Jul 2001 06:34:05 -0500 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: References: <9ije24$9kg$1@fang.dsto.defence.gov.au> Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 995024070 25117 137.194.161.2 (13 Jul 2001 11:34:30 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Fri, 13 Jul 2001 11:34:30 +0000 (UTC) Cc: To: Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.4 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , List-Archive: Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:9950 Date: 2001-07-13T06:34:05-05:00 Hi Vladimir, Based on your earlier queries about the adasockets package, I am answering your question in the context of adacokets. If, after creating the socket and establishing the connection, you call Sockets.Stream_IO.Initialize, that call will associate a stream with the connected socket. Then if your data is placed in an Ada record declared like this: type my_type is record sampleRate : C.C_Float; scalingFactor : C.C_Float; numSamples : C.Unsigned; numSensors : C.Unsigned; positionChanged : C.Unsigned_Char; groupBySensors : C.Unsigned_Char; end record; My_Object : My_Type; Then, when my_object is populates with the values you can simply write My_Type'Write (Stream, My_Object); where Stream is the stream object associated with the socket by calling Initialize. This will create the TCP packet just as you specified. This is demonstrated in the adasockets examples directory in the program stream_sender.adb. ----- Original Message ----- From: "Vladimir Bednikov" Newsgroups: comp.lang.ada To: Sent: Thursday, July 12, 2001 12:46 AM Subject: converting floats, ints byte arrays > Hi all, > > I have a bunch of values I want to send via tcp, instead of converting > each to a string and sending it out, I want to store all the values into > a byte array, ie: > type byte is mod 256; > type byte_array is array(integer range <>) of byte; > > The values are for example, > > sampleRate : C.C_Float; > scalingFactor : C.C_Float; > numSamples : C.Unsigned; > numSensors : C.Unsigned; > positionChanged : C.Unsigned_Char; > groupBySensors : C.Unsigned_Char; > > What I want is an array where the first C.C_Float'size bytes is the sample > rate, > the next C.C_Float'size bytes is the scaling factor, the next > C.Unsigned'size bytes > is the number of samples etc and finally send the byte array out via tcp. > > Does anybody out there know of a way to do this. > > All help is appreciated, > Thanks in advance > > > _______________________________________________ > comp.lang.ada mailing list > comp.lang.ada@ada.eu.org > http://ada.eu.org/mailman/listinfo/comp.lang.ada >