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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,21f034c3990be45c,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-05-24 09:46:02 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsmm00.sul.t-online.com!t-online.de!news.t-online.com!not-for-mail From: Tilman Gloetzner Newsgroups: comp.lang.ada Subject: Device file not closing on close command Date: Thu, 24 May 2001 20:39:00 +0200 Organization: U und Z Message-ID: <3B0D5544.ED114B7E@uundz.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.t-online.com 990722476 05 23263 gM+QSfIVSt-FyV 010524 16:41:16 X-Complaints-To: abuse@t-online.com X-Sender: 0931406720-0001@t-dialin.net X-Mailer: Mozilla 4.76 [de] (X11; U; Linux 2.4.0-64GB-SMP i686) X-Accept-Language: en Xref: archiver1.google.com comp.lang.ada:7726 Date: 2001-05-24T20:39:00+02:00 List-Id: Hi, the program below controls a task handeling a serial device. The task opens the device file, and 5 secs later the device file should be closed. When running the program below, the device is opened, but when the time comes to close the device the task just blocks on the closecommand. If I open and close the device from the main procedure it just works fine. The device is connected to a GPS receiver which is constantly sending data. I am using gnat 3.13 onlinux (2.1.18) and linux native threads. Why does the task block(is it because there is still unread data in the device -- but why would it work then if I open and close the device from the main procedure rather than from the task ?) ? How can I make the task close the file right away ? Thank you, Tilman ================== main ===================== with Text_IO;use Text_IO; with Device;use Device; procedure access_dev is TtyS2: DevTask; In_Stream: File_Type; begin TtyS2.Open("/dev/ttyS2"); delay(5.0); Put_Line("waited for 5 secs"); TtyS2.Close; end access_dev; =============== package specification ============== package Device is task type DevTask is entry Open(Dev:String); entry Close; entry Quit; end DevTask; end Device; ============== package body ======================= with Text_Io;use Text_Io; with Device; use Device; package body Device is task body DevTask is Exit_Flag: Boolean := False; In_Stream: File_Type; Buf: String(1..82); Noc: Integer := 0; begin while (Exit_Flag = False) loop select accept Open(Dev:String) do Put_Line("Openening Device " & Dev ); Open(In_Stream,IN_FILE, "/dev/ttyS2"); Put_Line("Device opened"); end Open; or accept Close do --if (Is_Open(In_Stream)) then Put_Line("Closing Device"); Close(In_Stream); Put_Line("Device closed"); -- end if; end Close; or accept Quit do Exit_Flag := True; end Quit; or delay(0.0); -- if (Is_Open(In_Stream)) then Get_Line(In_Stream,Buf,Noc); Put_Line(Buf(1..Noc)); -- end if; end select; end loop; Put_line("Task terminated"); end DevTask; end Device;