comp.lang.ada
 help / color / mirror / Atom feed
From: David C. Hoos, Sr. <david.c.hoos.sr@ada95.com>
To: tilmanglotzner@my-deja.com
Subject: Re: how to access a (serial) device (linux)
Date: 2000/01/27
Date: 2000-01-27T00:00:00+00:00	[thread overview]
Message-ID: <86pat1$2pi$1@nnrp1.deja.com> (raw)
In-Reply-To: 86op66$lu9$1@nnrp1.deja.com

In article <86op66$lu9$1@nnrp1.deja.com>,
  tilmanglotzner@my-deja.com wrote:
> Hello,
>
> I wrote a program to access serial port via the device file. One
> task reads on the port, another task writes to the port. The
> tasks somehow seem to block each other, and an antenna controller
> connected to the serial port does not receive anything.
>
> 1) Is accessing the serial port via a device file the wrong approach ?
> Is it better to do this by an interrupt service routine ? A sample
> which I could reuse would be very, very helpful here :-)
>
> 2) Maybe the processes are in a dead lock because 2 processes try to
> access the same file. Is it feasible to access a device file from 2
> task  ?
>
> 3) Maybe it is better to access the device file from only 1 task.
> I would need to open the file as read/write. Text_io seems not be
> capable of this.Are there other packages which allow opening
> (device) file as read/write ?
I have implemented a network physical layer via a serial port in
Linux, using a custom PCMCI card modem.  This channel runs reliably
at 512000 bps, because the hardware supports that kind of rate.

The underlying implementation uses the POSIX.IO and
POSIX.Terminal_Characteristics packages from the FLORIST implementation
of the IEEE Ada95 POSIX bindings.

The /dev/ttySN device is opened with POSIX.IO.Open with Read_Write
mode.

Reading is done with a task that puts the incoming octets in a
protected queue from which the link layer reads using an Ada.Streams
interface.  Reading is done with POSIX.IO.Read.

Writing is done without a task directly from the Stream's Write
procedure by calling POSIX.IO.Write.

To build a robust serial port package requires attention to quite
a number of details. For example, my port Open procedure first obtains
a lock on the port, using the lock file feature.

The link layer has a task (which I call a frame server), that reads the
incoming stream, identifying frames, and calling a procedure that has
registered with the task to receive frames.  This procedure is called
passing a validated frame as an Ada.Streams.Stream_Element_Array.


Sent via Deja.com http://www.deja.com/
Before you buy.




  reply	other threads:[~2000-01-27  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-01-27  0:00 how to access a (serial) device (linux) tilmanglotzner
2000-01-27  0:00 ` David [this message]
2000-01-27  0:00 ` Alfred Hilscher
replies disabled

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