|
Posted by jis on September 8, 2007, 10:52 pm
Please log in for more thread options
> jis wrote:
>
> >>> I am using Win32::serialport for reading a data through a scanner
> >>> which is connected to the serial port.
> >>> I use polling as below.But this consumes 99% of my CPU time. and
> >>> slows down the system.
> >>> while(!($data=~/\r/))
> >>> {
> >>> $data=$Scanner->input(); #read the scanner port
> >>> $labeldata=$labeldata.$data; #append
> >>> }
>
> >>> Is there any way I implement interrupts or events using perl. Or is
> >>> there any other method to solve this issue.
>
> >> Is there any particular reason you couldn't simply use a blocking
> >> read rather than a non-blocking one?
>
> > I am now trying to use $Scanner->lookfor which is a blocking read i
> > believe. But main issue now is I am using a perl tk window in the
> > program. The tk window needs continuous update.The call lookfor takes
> > me to unknownloop and prevents me from servicing tk window.
>
> > Appreciate your help.
>
> Do not use $Scanner->lookfor but create "timer" and test $Scanner->status
> value. Take a look to Tk::After and repeat() function. All PCs have 8-16
> bytes buffer for COM ports and you can test $Scanner->status value say every
> 50 miliseconds and if status will indicate some bytes in input buffer then
> you will read this, in other case you will can to update some Tk widget.
> --
>
> Petr Vileta, Czech republic
> (My server rejects all messages from Yahoo and Hotmail. Send me your mail
> from another non-spammer site please.)- Hide quoted text -
>
> - Show quoted text -
thanks for tthe info.it was helpful. But is there any problem using
$scanner->lookfor?
It luks to me even lookfor polls the com port effectively .
regards,
jis
|