Click here to get back home

Reduce CPU time while using serialport?

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Reduce CPU time while using serialport? jis 09-06-2007
Posted by jis on September 6, 2007, 4:18 pm
Please log in for more thread options


Hi,

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.
I use WIndows NT4(its old..but i have to...)

Pls share your ideas.

Cheers,
jis


Posted by Brian McCauley on September 8, 2007, 10:11 am
Please log in for more thread options


> 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?


Posted by jis on September 8, 2007, 11:29 am
Please log in for more thread options


>
> > 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.

Cheers,
jis


Posted by Petr Vileta on September 8, 2007, 10:28 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.)




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


Similar ThreadsPosted
Reduce colors with Image::Magick July 6, 2007, 7:06 am
Need help with Win32::SerialPort August 13, 2004, 5:43 am
need help with "SerialPort" module April 25, 2006, 11:34 pm
help on win32::serialport June 4, 2007, 5:12 pm
SerialPort error July 7, 2007, 10:58 pm
Please help on win32::serialport July 13, 2007, 12:41 pm
SerialPort write question October 28, 2004, 11:52 am
Serialport Read question October 28, 2004, 11:59 am
Loopback with Device::SerialPort? March 18, 2005, 1:24 pm
problem with Device::SerialPort November 30, 2005, 4:19 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap