Gary Stainburn wrote:
> 
> Hi Jon,
> 
> On Tuesday 12 March 2002 11:54 am, Jon Molin wrote:
> > Gary Stainburn wrote:
> > > Hi all,
> > >
> > > I've got a project where I need to develop an single-board-computer based
> > > network device using packet modems connected to Amateur Radio equipment
> > > and I'm trying to develop a simulator in Perl under Linux and I've got a
> > > few questions.
> > >
> > > Basically I'm going to have X number of nodes running inside Xterm
> > > sessions, all sitting in the same working directory and simulating
> > > transmitting data by appending the data to a file.  Each program will
> > > simulate receiving the data, by doing the equivelent of a tail -f on this
> > > file.
> > >
> > > Keyboard input will be used to simulate data being received from the
> > > box's serial port.
> > >
> > > 1) How can I simulate the 'tail -f' under perl without hanging my
> > > program.
> >
> > open (F, 'tail -f /var/log/messages |');
> > while (<F>)
> > {
> >   # do stuff
> > }
> > close (F);
> >
> 
> This won't do because my code will hang on the file reading part of the
> while(<F>) statement and prevent any further processing until some data is
> available.
> 
> My program will be simultaniously handling incoming data from the radio (this
> file) and a serial port (the keyboard) while processing real-time data that
> has already been received.
> 

I'm not sure i follow you here, will you have to process them at the
same time so
while (1)
{
  read tail
  check result
  read keyboard
  check result
  read radio
  check result

do other stuff
}
won't do?

then i'd fork off to three processes, one that handle each event.

[snip]
> > > }
> > >
> > > 2) can this same method be used to get the characters from the keyboard.
> >
> > read 'perldoc perlopentut', go to the part with pipes
> 
> Pipes are not really required here as I've already got a valid input stream
> from the Xterm session - STDIN.  All I need to do is to be able to check the
> status of the stream, and if data is available then read it.

what i was refering to was the last part:
       If you would like to open a bidirectional pipe, the IPC::Open2
library will handle this for you.
       Check out the section on Bidirectional Communication with Another
Process in the perlipc manpage



> 
> >
> > > 3) can I reduce the priority of these programs (equivelent of the unix
> > > 'nice' command) from within the perl script or do I need to do it from
> > > the shell script calling the program. (If I nice -> xterm -> perl script,
> > > will the nice still affect the perl script or will I have to do xterm ->
> > > nice -> perl script)?
> >
> > open (F, 'nice -15 tail -f /var/log/messages |');
> 
> Surely, this will only reduce the priority of the nice command and not my
> perl app?
> 

that's true, i wasn't sure with what you meant with 'these programs' i
thought you refered to tail which will be nicer
I don't know a way to change the priority of the own proces

/jon


> >
> > > 4) Is there an easy way (or a hard way) within Perl to control the xterm
> > > output, something similar to GotoXY that I used to have in TurboPascal in
> > > the good old (?) DOS days.
> >
> > i've never used dos (not even in the good old turbopascal days) but
> > there are term modules:
> > http://www.cpan.org/modules/by-module/Term/
> > i bet they offer alot of control
> 
> I'll look into these, thanks.
> 
> >
> >
> > /Jon
> >
> > > --
> > > Gary Stainburn
> > >
> > > This email does not contain private or confidential material as it
> > > may be snooped on by interested government parties for unknown
> > > and undisclosed purposes - Regulation of Investigatory Powers Act, 2000
> > >
> > > --
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> 
> --
> Gary Stainburn
> 
> This email does not contain private or confidential material as it
> may be snooped on by interested government parties for unknown
> and undisclosed purposes - Regulation of Investigatory Powers Act, 2000
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to