add (working) dirk.pl + other bits
[dweather.git] / DWeather / lib / DWeather / Station / Vantage.pm
1 #
2 # Vantage Pro 2 interface for DWeather
3 #
4 #
5
6 package DWeather::Station::Vantage;
7
8 use strict;
9 use warnings;
10
11 use base qw(DWeather::Station);
12 use DWeather::Debug;
13 use AnyEvent;
14
15 sub new
16 {
17         my $pkg = shift;
18         my $class = ref $pkg || $pkg;
19         my $device = shift;
20         
21         my $self = $class->SUPER::new($device, 19200);
22         $self->on_read(sub{$d->process});
23         return $self;
24 }
25
26 sub process
27 {
28         my $self = shift;
29         my $data = $self->{rbuf};
30         $self->{rbuf} = '';
31         
32         if (isdbg('raw')) {
33                 dbg("I $self->{device} lth " . length $data);
34                 dbgdump(data);
35         } elsif (isdbg('chan')) {
36                 dbg("I $self->{device}: $data");
37         }
38         foreach my $ch (@ch) {
39                 
40         }
41 }
42
43 sub send
44 {
45         my $self= shift;
46         my $data = shift;
47         if (isdbg('raw')) {
48                 dbg("O $self->{device} lth " . length $data);
49                 dbgdump(data);
50         } elsif (isdbg('chan')) {
51                 dbg("O $self->{device}: $data");
52         }
53         $self->push_write($data)
54 }
55
56 sub reset
57 {
58         
59 }
60 1;