From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: * X-Spam-Status: No, score=1.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6551e8ab1fe1fab7 X-Google-Attributes: gid103376,public From: David C. Hoos, Sr. Subject: Re: how to access a (serial) device (linux) Date: 2000/01/27 Message-ID: <86pat1$2pi$1@nnrp1.deja.com>#1/1 X-Deja-AN: 578242440 References: <86op66$lu9$1@nnrp1.deja.com> To: tilmanglotzner@my-deja.com X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt) X-Http-Proxy: 1.1 x37.deja.com:80 (Squid/1.1.22) for client 205.149.60.17 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Thu Jan 27 11:41:21 2000 GMT X-MyDeja-Info: XMYDJUIDdhoossr Newsgroups: comp.lang.ada Date: 2000-01-27T00:00:00+00:00 List-Id: 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.