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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,f3514db0a21f9b44 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news4.google.com!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!news.tele.dk!news.tele.dk!small.news.tele.dk!bnewspeer01.bru.ops.eu.uu.net!bnewspeer00.bru.ops.eu.uu.net!emea.uu.net!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Hexadecimal and stream element arrays Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: Date: Mon, 19 Apr 2010 19:27:00 +0200 Message-ID: <13872qpzb35yu$.9mbqdk8efq0p.dlg@40tude.net> NNTP-Posting-Date: 19 Apr 2010 19:26:59 CEST NNTP-Posting-Host: 9f2ef2f8.newsspool2.arcor-online.net X-Trace: DXC=o?W?Pd`U]c`UoRk[hk2WalA9EHlD;3Ycb4Fo<]lROoRa8kF On Mon, 19 Apr 2010 08:58:16 -0700 (PDT), tonyg wrote: > On Apr 19, 4:44�pm, tonyg wrote: >> I have some data coming in from a serial port which I want to convert >> to hexadecimal and display on the screen. I was wondering if anyone >> knows of a simple way to do this? > > To make myself more clear I have already dealt with the serial comms > bit, I am looking to display the stream I have already captured The following is based on: http://www.dmitry-kazakov.de/ada/strings_edit.htm with Ada.Streams; use Ada.Streams; with Strings_Edit; use Strings_Edit; with Strings_Edit.Integers; use Strings_Edit.Integers; function Image (Data : Stream_Element_Array) return String is begin if Data'Length = 0 then return ""; end if; declare Text : String (1..Data'Length * 3); Pointer : Integer := 1; begin for I in Data'Range loop Put ( Text, Pointer, Stream_Element'Pos (Data (I)), Field=>2, Fill=>'0', Justify=>Right, Base=>16 ); Put (Text, Pointer, ' '); end loop; return Text (1..Text'Last - 1); end; end Image; An individual item is output Put ( Text, Pointer, Stream_Element'Pos (Item), Field=>2, Fill=>'0', Justify=>Right, Base=>16 ); -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de