Device-VantagePro
view release on metacpan or search on metacpan
lib/Device/VantagePro.pm view on Meta::CPAN
# print out hash reference
print Dumper $hsh_ref;
=head2 get_one_loop
Combines a start_loop and a read_loop and returns a data hash.
my $hsh_ref = $vp_obj->get_one_loop();
I have not tested to see how fast this function can be called before the device chokes. It will run
at a 2-second rep rate without a problem.
The Loop data packet has a value for the Next_Record. This can be monitored in a loop and used to trigger
an event to read the archive via do_dmpaft.
=head2 make_date_time_stamp
Function to create a date and time stamp suitable for using in the dmpaft command. The function
expects a list in the following order ($year, $mon, $mday, $hour, $min) and returns a date stamp and
time stamp.
my ($dstamp,$tstamp) = $vp_obj->make_date_time_stamp(2010,4,17,19,15);
=head2 do_dmpaft
Function to retrieve the archive data after a provided date and time stamp. Refer to the Davis
documentation B<Section IX. Data Formats> for the sub-section concerning DMP and DMPAFT data format.
Functions requires a date stamp and time stamp as detailed in the documenation or provided in the
make_date_time_stamp function above.
The date/time stamp is returned in the archive record and you can save the last returned date/time
stamp values to use in the next call to return archive data after that date/time stamp. Note the
date/time stamp must match a date/time stamp in the archive memory or the whole 513 records will be
returned. Also if no date/time stamp is provided the complete archive will be returned.
The returned value is a reference to a list of hashes, one hash for each archive record.
my $ref = $vp_obj->do_dmpaft($dstamp,$tstamp);
unless ( @{$ref} ) { return 0 }
foreach my $arc_ref ( @{$ref} )
{
# Do something with the hash reference....
print Dumper $arc_ref;
}
=head2 get_eeprom
Retrieve specific EEPROM configuration settings. Currently the following parameters are supported:
ARCHIVE_PERIOD
TIME_ZONE
MANUAL_OR_AUTO
DAYLIGHT_SAVINGS
GMT_OFFSET
GMT_OR_ZONE
SETUP_BITS
The return value is the raw hex value from the unit, so needs to be decoded:
my $rst = $self->get_eeprom('archive_period');
my $archive_period = hex($rst->[0]);
=head2 get_setup_bits
Retrieve the setup of the device. Returns a hashref with the following keys:
TimeMode
IsAM
MonthDayFormat
WindCupSize
RainCollectorSize
Latitude
Longitude
=head1 SEE ALSO
Refer to:
Vantage Pro and Vantage Pro2 Serial Communication Reference Manual
Available at:
http://www.davisnet.com/support/weather/download/VantageSerialProtocolDocs_v230.pdf
Example of module being used at:
http://lpo.dt.navy.mil
Other related Perl modules that might be of interest....
Device::Davis - Low level read/write function
vanprod - High-level integrated daemon package with lots of bells and whistles. However,
no support for retrieving archive data or setting archive period.
=head1 PREREQUISITES
Device::SerialPort
Time::HiRes
use POSIX qw(:errno_h :fcntl_h strftime)
use Time::Local
Except for Device::SerialPort the prerequisites should be loaded with a default install.
=head1 AUTHOR
Steve Troxel, troxel AT perlworks.com
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2010 by Steve Troxel
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.8 or,
at your option, any later version of Perl 5 you may have available.
=cut
( run in 0.720 second using v1.01-cache-2.11-cpan-59e3e3084b8 )