comp.lang.ada
 help / color / mirror / Atom feed
* Beginners question: serial IO
@ 2001-11-05 22:43 Michael Bode
  0 siblings, 0 replies; only message in thread
From: Michael Bode @ 2001-11-05 22:43 UTC (permalink / 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?



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-11-05 22:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-05 22:43 Beginners question: serial IO Michael Bode

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox