comp.lang.ada
 help / color / mirror / Atom feed
From: "Nick Roberts" <nickroberts@adaos.worldonline.co.uk>
Subject: Re: Ada way to read/write to character file
Date: Wed, 9 Jan 2002 00:04:20 -0000
Date: 2002-01-09T00:04:20+00:00	[thread overview]
Message-ID: <a1g3kv$q2ehl$2@ID-25716.news.dfncis.de> (raw)
In-Reply-To: 3C39BB2B.57F2BB3D@icn.siemens.de

"Alfred Hilscher" <Alfred.Hilscher@icn.siemens.de> wrote in message
news:3C39BB2B.57F2BB3D@icn.siemens.de...

> I think it's because Text_IO is designed for sequential files where it
> does not make sense to switch between reading and writing. For what you
> want do you should use "Direct_IO" which provides an open mode
> "Inout_file".
>
> e.g. package Com_IO is new Direct_IO (Character); -- hope this works as
> intended

No, no, no! This won't vaguely work. Michael wants to use a serial device
for (bidirectional) sequential text I/O. Ada.Direct_IO is for random binary
file access (totally different!).

> Michael Bode wrote:
> >
> > Hi,
> >
> > I'm wondering if there is an Ada way (i.e. standard package) to read
> > and write to a character mode (sequential) file like the COM?:
> > resp. /dev/ttyS? interface. Ada.Text_IO has no read/write file mode
> > and with GNAT I wasn't able to connect two File_Type variables to the
> > same physical file at the same time.
> >
> > I want to communicate with a device hanging on the RS232 port. I have
> > to write to the device and read the answers. I could of course do it
> > like open, write, close, open read, close, open,... But I think this
> > is not very elegant. I just finished doing it with the Win32
> > resp. POSIX API functions, but I'm still wondering if it could be done
> > with some standard Ada package.

I think the answer to this question is, unfortunately, "No".

Personally, if I were writing an Ada.Text_IO implementation for MS-DOS (or
Windows) or an *n[iu]x, I would have made damn sure it could be used
(bidirectionally) with the character devices, but there's nothing (and there
could not sensibly have been anything) in the RM95 compelling any
implementation to do so.

--
Best wishes,
Nick Roberts






  reply	other threads:[~2002-01-09  0:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-05 12:01 Ada way to read/write to character file Michael Bode
2002-01-07 15:13 ` Alfred Hilscher
2002-01-09  0:04   ` Nick Roberts [this message]
2002-01-09  2:12     ` tmoran
2002-01-09  6:25       ` Michael Bode
2002-01-09 16:12         ` Georg Bauhaus
2002-01-09 20:38           ` Michael Bode
2002-01-09 23:57             ` James Rogers
2002-01-10  6:17               ` Michael Bode
2002-01-10 23:13             ` Georg Bauhaus
2002-01-09 12:11       ` Nick Roberts
2002-01-09 14:17         ` Ted Dennison
2002-01-11  0:19           ` Nick Roberts
2002-01-12 16:01             ` Michael Bode
replies disabled

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