(der socat ist primär dafür da sich das gefrette mit dem serielln Port zu sparen, ganze packerl zu bekommen [eol] usw..)Das kann man noch etwas ausdünnen:
Code:
[COLOR="Red"]#-[/COLOR]use Device::SerialPort;
$plugin_info{$plugname.'_cycle'}=0;
my $socknum=15;
# Configure socket
if (!$socket[$socknum]) {
if (defined $socket[$socknum]) { #debug
if ($socket[$socknum]->opened) { $socket[$socknum]->close(); }
undef $socket[$socknum];
} #debug
$socksel->remove($socket[$socknum]);
$socket[$socknum] = IO::Socket::INET->new(
LocalAddr => "localhost",
LocalPort => '500'.$socknum,
Proto => 'udp'
) || return ("open socket failed: $!");
$socksel->add($socket[$socknum]);
$plugin_socket_subscribe{$socket[$socknum]} = $plugname;
return "opened UDP-Socket $socknum";
}
#get reason for wakeup -> only acquire data if woken up by socket
[COLOR="Red"]#-[/COLOR]for what?
[COLOR="Red"]#-[/COLOR]my $event=undef;
[COLOR="Red"]#-[/COLOR]if (!$plugin_initflag) {$event='restart';}
[COLOR="Red"]#-[/COLOR]elsif ($plugin_info{$plugname.'_lastsaved'} > $plugin_info{$plugname.'_last'}) {$event='modified';}
[COLOR="Red"]#-[/COLOR]elsif ($fh) {$event='socket';}
[COLOR="Red"]#-[/COLOR]else {$event='cycle';}
[COLOR="Red"]#-[/COLOR]if ($event=~/socket/) {
[COLOR="Green"]if ($fh) {
[/COLOR] my @res = split(';',<$fh>);
$plugin_info{$plugname.'_info'}=@res;
my $T1 = @res[1]; #Vorlauf Dach
my $T2 = @res[2]; #Speicher
my $T3 = @res[3]; #Puffer oben
my $T4 = @res[4]; #Puffer unten
my $R1 = @res[8]; #Solarpumpe
my $R2 = @res[9]; #Umschaltventil Speicher, ein=Puffer
my $R3 = @res[10]; #Umschaltventil Puffer, ein=unten
update_rrd("T_VL_Solar_Dach","",$T1);
update_rrd("T_Speicher","",$T2);
update_rrd("T_Puffer_Oben","",$T3);
update_rrd("T_Puffer_Unten","",$T4);
update_rrd("P_Solar","",$R1);
update_rrd("V_Speicher","",$R2);
update_rrd("V_Puffer","",$R3);
return "Entry added: $T1 $T2 $T3 $T4 $R1 $R2 $R3";
}
return "nothing to do, yet";
P.S.: Wenn derlei Kisten alle einfach zyklisch einen parse-baren Wert aufn RS232 ausspucken würden, wär das leben so viel einfacher


Einen Kommentar schreiben: