From: rrr.eee.27@gmail.com
Subject: GNAT.Serial_Communication and Streams
Date: Sun, 22 Nov 2015 13:40:05 -0800 (PST)
Date: 2015-11-22T13:40:05-08:00 [thread overview]
Message-ID: <d6318f11-df2c-49bd-928c-2abb766f9c9a@googlegroups.com> (raw)
I want to send text strings via a serial line (actually, it is a USB device that presents itself as a serial CDC device).
For sending text snippets I had to declare the following routine:
procedure Send_Command (Cmd : String)
is
Output_Max_Length : constant Ada.Streams.Stream_Element_Offset := 50;
Output : Ada.Streams.Stream_Element_Array (1 .. Output_Max_Length);
begin
for I in 1 .. Cmd'Length loop
Output (Ada.Streams.Stream_Element_Offset(I)) := Character'Pos(Cmd (Cmd'First + I - 1));
end loop;
Output (Cmd'Length+1) := Character'Pos(ASCII.LF);
GNAT.Serial_Communication.Write (P, Output(1..Cmd'Length+1));
end Send_Command;
That works but feels completely strange to me. I'm sure that I'm missing something here. There must be an easier way to fill the output buffer with a standard string.
RE
next reply other threads:[~2015-11-22 21:40 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-22 21:40 rrr.eee.27 [this message]
2015-11-22 21:52 ` GNAT.Serial_Communication and Streams 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
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