Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I do something similar but its a pic 16f877 i read from that polls Dallas One-wire 18s20 temp sensors. i use the following

$ob->read_char_time(5); # avg time between read char $ob->read_const_time(500); # timeout after 500 milliseconds = +0.5 seconds
I also am looking for complete lines so i use
my $ob = tie (*FH, 'Device::SerialPort', $cfgfile) || die "Can't tie: $!\n"; ## TIEHANDLE ##
and to read in all available lines i use
@gotits=<FH> ;
This seems to work well for me, but i can get a bunch of lines all at once for while i too only cycle every 15 seconds a cycle reads about 50 18s20 sensors 6 at a time and there may not be much time between the lines for each sensor.

One thing that may be affecting you is that

$timestamp = uts_to_iso(time());
runs even if you do not want to insert the lines.

Another thing i noticed is repeated calls to dt(). saying

my $dtdate=dt('date'); my $dttime=dt('time');
and then using the variables in the execute may speed things up.

and a last observation is that each insert cycle you run the $dbh->prepare($q); pulling these out of the while loop such that

$q = "insert into weather_data values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? +, ?, ?, ?, ?, ?, ?)"; my $sth = $dbh->prepare($q);
is only run once, nd the loop code just uses $sth->execute(...); may speed things up a whole lot.


In reply to Re: Waiting for Device::Serialport by huck
in thread Waiting for Device::Serialport by wjw

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-04-16 19:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found