Pages: [1]   Go Down
Author Topic: Monitoring Serial Port in Perl without using 100% CPU  (Read 748 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 47
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 170
Posts: 12451
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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

#include "all disclaimers"
Logged

Rob Tillaart

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

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 549
Posts: 46083
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Tesla Member
***
Karma: 114
Posts: 8924
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What operating system allows spaces in file names?

Windows seems to.
Logged

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

texas
Offline Offline
God Member
*****
Karma: 27
Posts: 862
old, but not dead
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Try using "select" to wait for data with a timeout.  I think it's in IO::select.pm or something like that.
Logged

Experience, it's what you get when you were expecting something else.

Offline Offline
Newbie
*
Karma: 0
Posts: 47
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

David
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 170
Posts: 12451
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-wink
and yes they cause a lot of trouble (almost daily! )
Logged

Rob Tillaart

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

Pages: [1]   Go Up
Jump to: