in reply to Waiting for Device::Serialport
I do something similar but its a pic 16f877 i read from that polls Dallas One-wire 18s20 temp sensors. i use the following
I also am looking for complete lines so i use$ob->read_char_time(5); # avg time between read char $ob->read_const_time(500); # timeout after 500 milliseconds = +0.5 seconds
and to read in all available lines i usemy $ob = tie (*FH, 'Device::SerialPort', $cfgfile) || die "Can't tie: $!\n"; ## TIEHANDLE ##
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.@gotits=<FH> ;
One thing that may be affecting you is that
runs even if you do not want to insert the lines.$timestamp = uts_to_iso(time());
Another thing i noticed is repeated calls to dt(). saying
and then using the variables in the execute may speed things up.my $dtdate=dt('date'); my $dttime=dt('time');
and a last observation is that each insert cycle you run the $dbh->prepare($q); pulling these out of the while loop such that
is only run once, nd the loop code just uses $sth->execute(...); may speed things up a whole lot.$q = "insert into weather_data values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? +, ?, ?, ?, ?, ?, ?)"; my $sth = $dbh->prepare($q);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Waiting for Device::Serialport
by wjw (Priest) on May 17, 2018 at 19:10 UTC |
In Section
Seekers of Perl Wisdom