Skip Menu |

This queue is for tickets about the Device-WH1091 CPAN distribution.

Report information
The Basics
Id: 72508
Status: new
Priority: 0/
Queue: Device-WH1091

People
Owner: Nobody in particular
Requestors: kevin [...] susa.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Patch for correction to winddirtext in WH1091.pm
Date: Thu, 17 Nov 2011 23:59:15 +0000
To: bug-Device-WH1091 [...] rt.cpan.org
From: Kevin Sangeelee <kevin [...] susa.net>
Hi, Below is a correction to the handling of textual wind directions. Unless my understanding is wrong, the existing code was using the direction-degrees value (instead of the direction-index) as an index into the array, which itself was defined incorrectly. Thanks for sharing the module, it was exactly what I was looking for. Regards, Kevin ------ kaka:~# diff -u WH1091.pm WH1091.pm.new --- WH1091.pm 2011-11-17 23:37:48.000000000 +0000 +++ WH1091.pm.new 2011-11-17 23:36:37.000000000 +0000 @@ -66,7 +66,7 @@ my $buffer2; my $current={}; - my @dir = ['N','NNE','NE','ENE','E','SEE','SE','SSE','S','SSW','SW','WSW','W','WNW','NW','NNW']; + my @dir = ('N','NNE','NE','ENE','E','SEE','SE','SSE','S','SSW','SW','WSW','W','WNW','NW','NNW'); getweather($buffer2); @@ -76,12 +76,15 @@ $self->{houtdoor} = get_bufferval($buffer2, 244); $self->{windspeed} = get_bufferval($buffer2, 249)/10; $self->{windgust} = get_bufferval($buffer2, 250)/10; - $self->{winddir} = get_bufferval($buffer2, 252) * 22.5; - $self->{winddirtext} = $dir[$self->{winddir}]; + + my $winddir_idx = get_bufferval($buffer2, 252); + $self->{winddir} = $winddir_idx * 22.5; + $self->{winddirtext} = $dir[$winddir_idx]; + $self->{pressure} = get_bufferval($buffer2, 247, 248)/10; $self->{raintot} = get_bufferval($buffer2,253,254) * 3 / 10; + return 1; - }