From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: GNAT.Serial_Communication and Streams
Date: Tue, 24 Nov 2015 09:28:55 +0100
Date: 2015-11-24T09:28:55+01:00 [thread overview]
Message-ID: <z1z0lmyfw8oz.11i1vv0zjj8ur$.dlg@40tude.net> (raw)
In-Reply-To: n2tddf$eue$1@dont-email.me
On Sun, 22 Nov 2015 14:54:04 -0700, Jeffrey R. Carter wrote:
> What about
>
> procedure Send (Cmd : in String) is
> Local : constant String := Cmd & Ada.Characters.Latin_1.LF;
> Output : constant Ada.Streams.Stream_Element_Array (1 .. Local'Length);
> pragma Import (Ada, Output);
> for Output'Address use Local'Address;
> begin -- Send
> GNAT.Serial_Communication.Write (P, Output)?
> end Send;
If you wanted optimize it, then Cmd and LF should be written in separate
calls rather than making a local copies.
A case when a copying makes sense is in a packet-oriented protocol. Which
is not the case here since streams are used. Maybe it is still
packet-oriented because of the USB device class, but then interfacing it
through a stream is inappropriate.
P.S. I don't see anything wrong with the original code. Stream attributes
not to be trusted in general. An explicit conversion is clearer and
cleaner, IMO.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2015-11-24 8:28 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-22 21:40 GNAT.Serial_Communication and Streams rrr.eee.27
2015-11-22 21:52 ` Simon Wright
2015-11-22 21:54 ` Jeffrey R. Carter
2015-11-24 1:29 ` Randy Brukardt
2015-11-24 16:09 ` Jeffrey R. Carter
2015-11-24 8:28 ` Dmitry A. Kazakov [this message]
2015-11-24 10:28 ` Simon Wright
2015-11-24 10:45 ` Dmitry A. Kazakov
2015-11-25 6:24 ` Shark8
2015-11-25 8:07 ` Simon Wright
2015-11-25 8:52 ` Dmitry A. Kazakov
2015-11-25 12:45 ` Shark8
2015-11-25 17:43 ` Dmitry A. Kazakov
2015-11-29 8:45 ` Shark8
2015-11-29 9:33 ` Dmitry A. Kazakov
2015-11-29 11:34 ` Simon Wright
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox