Go Down

Topic: Monitoring Serial Port in Perl without using 100% CPU (Read 990 times) previous topic - next topic

redcliffe

Hi,

I've implemented a Perl script using this page as a template: http://playground.arduino.cc/interfacing/PERL

The while(1) loop uses 100% of the CPU power available. Is there a way to do this without using so much processor load? In my case the Arduino spits out a line of telemetry once per second. The perl script reads this and inserts it into a db. Any suggestions about better ways to do this? Thanks,

David

robtillaart


put in a sleep of a few (10) milliseconds as the hardware will buffer several characters anyway ?

#include "all disclaimers"
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

PaulS

Code: [Select]
#include "all disclaimers"
What operating system allows spaces in file names?

zoomkat

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)

afremont

Try using "select" to wait for data with a timeout.  I think it's in IO::select.pm or something like that.
Experience, it's what you get when you were expecting something else.

redcliffe

Thanks, sleeping fixed it up. Seemed silly that such simple code would chew so much. Thanks,

David

robtillaart

Quote
Code:
#include "all disclaimers"
What operating system allows spaces in file names?

almost all?
and yes spaces are mainly for us mere mortals to help our associative brain ;)
and yes they cause a lot of trouble (almost daily! )
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up