Device Davis
Details
| Last Update: | 2008-01-31 05:01:19 |
| Version: | Device::Davis 1. |
| License/Program Type: | Perl Artistic License |
| Publisher: | Stan Sander |
| Price: | $0.00 |
Description:
Device::Davis is a Perl extension for communicating with Davis
weather stations.
SYNOPSIS
use Device::Davis;
$fd = station_open($tty);
put_string($fd, "$string");
$char = get_char($fd);
$crc = crc_accum($crc, $data_byte);
put_unsigned($fd, $num);
Davis is a Perl 5 module that facilitates communication with
Davis weather stations. This module should work on most unix
systems, however it was developed on Linux.
station_open() takes the tty where the station is connected as
an argument and opens the tty with the correct parameters for
communication. The baud rate that is used matches the factory
default of the Vantage Pro, which is 19200. If you need to use a
different baud rate, you will need to modify the Davis.xs file
before compiling the module.
put_string() takes a file descriptor (NOT a perl filehandle)
and the string to send as arguments and sends the string to the
weather station. This function will return the number of bytes
written.
get_char() takes a file descriptor as an argument and retuns 1
byte from the weather station.
crc_accum() is an accumulator for the crc calculation. It takes
the previous value of the crc that has been accumulated ($crc) and
the new data byte that needs to be added to the accumulated total.
Be sure to initialize $crc to 0 before sending a new set of data
bytes. The function will return the new accumulated crc value. Once
you pass in the crc value received from the weather station, the
function should return a 0 if the crc check passed. If you are
sending commands to the station, the last value returned by the
function should be what you send to the station as the crc value.
Note that the station expects the most significant byte of the crc
to be sent first, which is opposite of how regular data values are
sent.
put_unsigned() is for sending numeric values to the station. It
takes the file descriptor and the character to send as arguments.
It will send it's argument as a one byte unsigned character. It
will return the number of bytes written.
EXAMPLES
$bytes = put_string($fd, "n");
$bytes = put_string($fd, "TESTn");
Reading the results from a LOOP 1 request:
$crc = 0;
while($index < 100){
$data[$index] = get_char($fd);
The first byte returned by the station in a LOOP 1 packet is an
ACK (0x06) and should not be included in the crc.
if($index){$crc = crc_accum($crc, $data[$index]);};
$data[$index] = sprintf("%02x", "$data[$index]");
Convert to hex
$index++;
};
At this point the value of $crc should be 0 if there were no
transmission errors, and you can continue to process the
packet.
Sending a command or other value to the station:
We will want to calculate the value for the crc by running each
byte we will send through crc_accum().
$crc = crc_accum($crc, 0xc6);
$crc = crc_accum($crc, 0xce);
$crc = crc_accum($crc, 0xa2);
$crc = crc_accum($crc, 0x03)
;
Let's say at this point that the value of $crc is e2b4. If we
are sending a command to the weather station, we should send e2b4
(most significant byte first) to the station.
$msbyte = $crc >> 8; For our example equals e2
put_unsigned($fd, $msbyte);
$lsbyte = $crc << 24;
$lsbyte = $lsbyte >> 24; For our example equals b4
put_unsigned($fd, $lsbyte);
Requirements:
· Perl
0 comments
Add to
Device Davis Version History
Related Software
|
|
From category: Perl-Modules |
| Device::Davis is a Perl extension for communicating with Davis weather stations.... |
|
|
From category: Libraries |
| BBDB::Export 0.012 is libraries software developed by wu. BBDB::Export is a Perl module to export data from The Insidious Big Brother Database. SYNOPSIS use BBDB::Export;... |
|
|
From category: Compilers |
| Free Pascal Compiler 2.0.2 is compilers software developed by Dani?l Mantione. Free Pascal (aka FPK Pascal) is a 32 or 64 bit (from 1.9.6) pascal compiler. Free Pascal Compiler is available for dif... |
|
|
From category: Bug-Tracking |
| eTraxis is a free web-based bug tracking system with unlimited number of custom workflow templates.... |
|
|
From category: Libraries |
| JPerf is a Java library, a perfect hash function generator.... |
|
|
From category: Libraries |
| CGI::WeT::Modules::Calendar 0.71 is libraries software developed by CGI::WeT::Modules::Calendar Team. CGI::WeT::Modules::Calendar are Perl extensions to engine to allow calendar management.... |
|
|
From category: Perl-Modules |
| WWW::Authen::Simple is a cookie based session and authentication module using database backend.... |
|
|
From category: Libraries |
| Acme::MetaSyntactic 0.90 is libraries software developed by Philippe Bruhat. Acme::MetaSyntactic is Perl module themed metasyntactic variables. When writing code examples, it\'s always easy... |
|
|
From category: Code-Generators |
| CodeSugar Eclipse Plugin 1.3.0 is code generators software developed by Mike G. CodeSugar Eclipse Plugin is an Eclipse plugin that can generate methods such as equals(), clone(), toString(), and ha... |
|
|
From category: Libraries |
| Declare::Constraints::Simple 0.03 is libraries software developed by Robert Sedlacek. Declare::Constraints::Simple is a Perl module for Declarative Validation of Data Structures. SYNOPSIS \... |
|
|
From category: Libraries |
| Want is a Perl module created to implement the `want\' command.... |
|
|
From category: Libraries |
| Date::Hijri 0.02 is libraries software developed by Alex Pleiner. Date::Hijri is a Perl extension to convert islamic (hijri) and gregorian dates. SYNOPSIS use Date::Hijri;... |
|
|
From category: UI-User-Interfaces |
| Asterisk Desktop Manager 0.9 is ui (user interfaces) software developed by Richard Hamnett. Asterisk Desktop Manager application interfaces your VOIP telephony with the desktop and Asterisk PBX. \... |
|
|
From category: Libraries |
| DBIx::Migration::Directories 0.05 is libraries software developed by Tyler MacDonald. DBIx::Migration::Directories is a Perl module to install/remove/upgrade/downgrade SQL schemas. SYNOPSIS\... |
|
|
From category: Bug-Tracking |
| Deskzilla 1.2.1 is bug tracking software developed by ALM Works Ltd. Deskzilla allows you to do more with issues in your Bugzilla bug tracking system. Deskzilla is an alternative Bugzilla cl... |
Leave a comment