From: "Pat Rogers" <progers@classwide.com>
Subject: Re: Device file not closing on close command
Date: Thu, 24 May 2001 13:16:28 -0500
Date: 2001-05-24T13:16:28-05:00 [thread overview]
Message-ID: <2ecP6.31$2K1.31102@nnrp2.sbc.net> (raw)
In-Reply-To: 3B0D5544.ED114B7E@uundz.de
Procedure access_dev is the master of task TtyS2. Since you never told
TtyS2 to quit it is still running, so access_dev can not complete. Call the
"quit" entry after you call the "close" entry.
---
Patrick Rogers Consulting and Training in:
http://www.classwide.com Real-Time/OO Languages
progers@classwide.com Hard Deadline Schedulability Analysis
(281)648-3165 Software Fault Tolerance
"Tilman Gloetzner" <Tilman.Gloetzner@uundz.de> wrote in message
news:3B0D5544.ED114B7E@uundz.de...
> 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;
>
next prev parent reply other threads:[~2001-05-24 18:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-05-24 18:39 Device file not closing on close command Tilman Gloetzner
2001-05-24 18:16 ` Pat Rogers [this message]
2001-05-24 20:42 ` Ted Dennison
2001-05-24 20:47 ` Ted Dennison
-- strict thread matches above, loose matches on Subject: below --
2001-05-24 21:06 Beard, Frank
2001-05-25 22:30 ` Tilman Gloetzner
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox