1
2
3
4
Argument "0x1A85" isn't numeric in pack at D:\home\netsh100633\tools\dongle.pl line 52.
Argument "0x1A85" isn't numeric in pack at D:\home\netsh100633\tools\dongle.pl line 52.
#0x1A85#
#0x1A85#
1 2 3
print 2 * "0x85"; # Erzeugt Warnung und ergibt "0" print 2 * "133"; # Keine Warnung und ergibt "266" print 2 * 0x85; # Keine Warnung und ergibt "266"
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
use lib qw( d:/home/netsh100633/files/fwlib d:/home/netsh100633/files/fwlib/factory d:/home/netsh100633/html/cgi-bin ); use strict; use warnings; use JSON; use HTTPRequest; use PX1674; use FastEAV; require dd; my $main = bless{ comport => 'COM1', host => 'rolfrost', file => 'd:/tmp/dongle.cmp', debug => 1 },'main'; $main->request(); ########################################################################### # Status für Geräte vom Webservice abholen sub request{ my $self = shift; my $dal = FastEAV->new( file => $self->{file}, auto => 0 ) or die $@; my $host = $self->{host}; my $r = HTTPRequest->common( host => $host, uri => '/hausomat.html?getstate=1;json=1', method => 'GET' ) or die "Keine Verbindung"; my $json = JSON->new; my $slice = $json->decode($r->response_body); my %objects = (); foreach my $device(@$slice){ next unless $device->{devid}; my ($addr, $id) = split "-", $device->{devid}; my $state = $device->{type} eq 'PWM' ? $self->pwm($device->{state}, $device->{period}) : $device->{state}; push @{$objects{$addr}}, {state => $state, id => $id}; } foreach my $address(keys %objects){ my $px = Win32::SerialPort::PX1674->new( comport => $self->{comport}, address => hex($address), debug => $self->{debug} ); my $comp = $dal->checkout($address) || {}; foreach my $hunt(@{$objects{$address}}){ $comp->{$hunt->{id}} ||= ''; $px->switch($hunt->{state}, $hunt->{id}) if $comp->{$hunt->{id}} ne $hunt->{state}; $comp->{$hunt->{id}} = $hunt->{state}; $dal->checkin($address, %$comp); } $dal->write; } } # PulsWeitenModulation sub pwm{ my $self = shift; my $power = shift; my $period = shift; return 'On' if $power == 1; return 'Off' if $power == 0; my $nr = do "LfdNr.pm"; return ($nr % $period +1)/$period <= $power ? 'On' : 'Off'; }