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: 114c38,b2077f5b728fb9af X-Google-Attributes: gid114c38,public X-Google-Thread: 103376,b2077f5b728fb9af X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-04-12 09:14:07 PST Path: supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!hammer.uoregon.edu!enews.sgi.com!coop.net!newsfeed1.global.lmco.com!svlnews.lmms.lmco.com!not-for-mail From: "Smark" Newsgroups: comp.lang.ada,comp.os.vxworks Subject: Re: redirecting the standard output Date: Thu, 12 Apr 2001 09:01:24 -0500 Organization: Lockheed Martin Corporation Message-ID: <9b4cfn$s6j7@cui1.lmms.lmco.com> References: <3ad31759$1@pull.gecm.com> <3AD42861.A6C58874@NOSPAM.bcs.org.uk> <3ad59c42$1@pull.gecm.com> NNTP-Posting-Host: 138.209.253.101 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2919.6600 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 Xref: supernews.google.com comp.lang.ada:6825 comp.os.vxworks:6446 Date: 2001-04-12T09:01:24-05:00 List-Id: So the trick was to use VxWorks' "open" and "ioGlobalStdSet" rather than Ada.Text_Io's "Open" and "Set_Output" ... interesting. Mark "Martin Dowie" wrote in message news:3ad59c42$1@pull.gecm.com... > Cheers Graham! That's done the trick! > > And in return to the community here is the Ada equivilant we will > be using (feel free to add your own comments :-) > > > -- vxworks.ads > -------------- > with Interfaces.C; > > package VxWorks is > > subtype A_Status is Interfaces.C.Int; > > use type A_Status; > > Ok : constant A_Status := 0; > Error : constant A_Status := -1; > > end VxWorks; > > -- vxworks-iolib.ads > -------------------- > with Interfaces.C; > with Interfaces.C.Strings; > > package VxWorks.ioLib is > > O_RDONLY : constant := 16#0000#; > O_WRONLY : constant := 16#0001#; > O_RDWR : constant := 16#0002#; > O_CREAT : constant := 16#0200#; > > subtype A_File is Interfaces.C.Int; > > function Open (Name : Interfaces.C.Strings.Chars_Ptr; > Flags : Interfaces.C.Int; > Mode : Interfaces.C.Int) return A_File; > > function Close (File : A_File) return A_Status; > > STD_IN : constant A_File := 0; > STD_OUT : constant A_File := 1; > STD_ERR : constant A_File := 2; > > function ioGlobalStdGet (StdFd : A_File) return A_File; > > procedure ioGlobalStdSet (StdFd : A_File; > NewFd : A_File); > > function ioTaskStdGet (TaskId : Interfaces.C.Int := 0; > StdFd : A_File) return A_File; > > procedure ioTaskStdSet (TaskId : Interfaces.C.Int := 0; > StdFd : A_File; > NewFd : A_File); > > private > > pragma Import (C, Open, "open"); > pragma Import (C, Close, "close"); > pragma Import (C, ioGlobalStdGet, "ioGlobalStdGet"); > pragma Import (C, ioGlobalStdSet, "ioGlobalStdSet"); > pragma Import (C, ioTaskStdGet, "ioTaskStdGet"); > pragma Import (C, ioTaskStdSet, "ioTaskStdSet"); > > end VxWorks.ioLib; > > > -- text.ads > ------------ > package Text is > > procedure Send_Outputs_To_Null_Device; > > procedure Return_Outputs_To_Standard_Devices; > > end Text; > > > -- text.adb > ------------ > with Interfaces.C.Strings; > with VxWorks; > with VxWorks.ioLib; > > package body Text is > > Null_Device, > Standard_Output, > Standard_Error : VxWorks.ioLib.A_File; > > > procedure Send_Outputs_To_Null_Device is > > use type VxWorks.ioLib.A_File; > > begin > > Null_Device := VxWorks.ioLib.Open (Name => > Interfaces.C.Strings.New_String ("/null"), > Flags => VxWorks.ioLib.O_RDWR, > Mode => 0); > > if Null_Device = VxWorks.Error then > return; > end if; > > Standard_Output := VxWorks.ioLib.ioGlobalStdGet (StdFd => > VxWorks.ioLib.STD_OUT); > Standard_Error := VxWorks.ioLib.ioGlobalStdGet (StdFd => > VxWorks.ioLib.STD_ERR); > > VxWorks.ioLib.ioGlobalStdSet (StdFd => VxWorks.ioLib.STD_OUT, > NewFd => Null_Device); > > VxWorks.ioLib.ioGlobalStdSet (StdFd => VxWorks.ioLib.STD_ERR, > NewFd => Null_Device); > > end Send_Outputs_To_Null_Device; > > > procedure Return_Outputs_To_Standard_Devices is > > Status : VxWorks.A_Status; > > begin > > VxWorks.ioLib.ioGlobalStdSet (StdFd => VxWorks.ioLib.STD_OUT, > NewFd => Standard_Output); > > VxWorks.ioLib.ioGlobalStdSet (StdFd => VxWorks.ioLib.STD_ERR, > NewFd => Standard_Error); > > Status := VxWorks.ioLib.Close (File => Null_Device); > > end Return_Outputs_To_Standard_Devices; > > end Text; > > > -- test.adb > ----------- > with Ada.Real_Time; use Ada.Real_Time; > with Ada.Text_IO; use Ada.Text_IO; > with Text; > > procedure Test is > > procedure Display (Item : String; Result : out Duration) is > > Start_Time, > End_Time : Time; > > begin > > Start_Time := Clock; > > for I in 1 .. 10_000 loop > > Put (Item => Item); > > end loop; > > End_Time := Clock; > > Result := To_Duration (TS => End_Time - Start_Time); > > end Display; > > Times : array (Natural range 1 .. 10) of Duration; > > Test_String : constant String := "1234567890"; > > begin > > Text.Send_Outputs_To_Null_Device; > > for Index in Times'Range loop > > Test (Item => Test_String (1 .. Index), > Result => Times (Index)); > > end loop; > > Text.Return_Outputs_To_Standard_Devices; > > for Index in Times'Range loop > > Put_Line (Integer'Image (Index) & " Time =" & Duration'Image (Times > (Index))); > > end loop; > > end Display; > > > > "Graham Baxter" wrote in message > news:3AD42861.A6C58874@NOSPAM.bcs.org.uk... > > > > > > Martin Dowie wrote: > > > > > > This time with a subject... :-) > > > > > > Target System: PowerPC, AdaMULTI v1.8.9b, VxWorks 5.4 > > > > > > How do I redirect the standard output? I'd like to redirect it to device > > > "/null" > > > > > > Attempts: > > > Open (DevNull, Append_File, "/null"); > > > Open (DevNull, "/null", "/null"); > > > > > > just cause Status_Error, i.e. the device is already "open". So how can > > > I then "Set_Output (DevNull);" without having the device object in > > > File_Type form?.. > > > > -- > > Try: > > > > int fd = open("/null",O_RDWR,0); > > if(fd != ERROR) > > { > > ioGlobalStdSet(STD_IN,fd); > > ioGlobalStdSet(STD_OUT,fd); > > ioGlobalStdSet(STD_ERR,fd); > > } > > > > > > > > Regards, > > > > > > Graham Baxter > > Freelance Software Engineer > > gbaxter@NOSPAM.bcs.org.uk > >