From: Michael Bode <m.g.bode@web.de>
Subject: Beginners question: serial IO
Date: 05 Nov 2001 23:43:25 +0100
Date: 2001-11-05T23:43:25+01:00 [thread overview]
Message-ID: <dm47s9.ff.ln@320025674319.dialin.t-online.de> (raw)
Hi, I'm just starting with Ada and have the following problem: I tried
some file IO to/from the serial port aka /dev/ttyS? aka COMx:. I
figured that the following code works with GNAT/Linux (and
GNAT/Windows with the obvious change), but there must be a better way
of doing it:
with Text_IO; use Text_IO;
procedure IO_Test is
Com_Port : Text_IO.File_Type;
Answer : Character;
begin
Create(Com_Port, Mode=>Text_IO.Out_File, Name=>"/dev/ttyS0");
Put(Com_Port,"Hello World!");
Close(Com_Port);
Create(Com_Port, Mode=>Text_IO.In_File, Name=>"/dev/ttyS0");
Get(Com_Port,Answer);
Close(Com_Port);
end IO_Test;
Imagine some kind of program that talks to a device on the com port
constantly opening, closing and reopening /dev/ttyS0. It seems to be
impossible to assign two files of type In_File and Out_File to the same
device file. So, how do I do it then?
reply other threads:[~2001-11-05 22:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox