From 8fd0e82fe300c75b591eb4b4cd16d6f6367a0dc8 Mon Sep 17 00:00:00 2001 From: LeonGaultier Date: Thu, 20 Jun 2019 20:34:51 +0000 Subject: [PATCH] 73_AMADCommBridge: fix bug Undefined subroutine git-svn-id: https://svn.fhem.de/fhem/trunk@19673 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/73_AMADCommBridge.pm | 29 +++++++---------------------- fhem/FHEM/74_AMADDevice.pm | 33 ++++++++++++--------------------- 3 files changed, 20 insertions(+), 43 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 0d56e6aa5..ec4151a50 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - bugfix: 73_AMADCommBridge: fix bug Undefined subroutine - change: GPUtils: add modul header - feature: GPUtils: change Maintainer, add Export Fn - feature: 73_AMADCommBridge: change version code diff --git a/fhem/FHEM/73_AMADCommBridge.pm b/fhem/FHEM/73_AMADCommBridge.pm index d6158c906..f275dcfb1 100644 --- a/fhem/FHEM/73_AMADCommBridge.pm +++ b/fhem/FHEM/73_AMADCommBridge.pm @@ -64,12 +64,10 @@ use strict; use warnings; use POSIX; use FHEM::Meta; -use GPUtils qw(GP_Import); +use GPUtils qw(GP_Import GP_Export); use HttpUtils; use TcpServerUtils; -my $flowsetversion = '4.4.1'; - my $missingModul = ''; eval "use Encode qw(encode encode_utf8);1" or $missingModul .= 'Encode '; @@ -176,22 +174,10 @@ BEGIN { ); } -# _Export - Export references to main context using a different naming schema -sub _Export { - no strict qw/refs/; ## no critic - my $pkg = caller(0); - my $main = $pkg; - $main =~ s/^(?:.+::)?([^:]+)$/main::$1\_/g; - foreach (@_) { - *{ $main . $_ } = *{ $pkg . '::' . $_ }; - } -} - #-- Export to main context with different name -_Export( +GP_Export( qw( Initialize - Flowsetversion ) ); @@ -249,7 +235,7 @@ sub Define($$) { $hash->{BRIDGE} = 1; $hash->{PORT} = $port; $hash->{VERSION} = version->parse($VERSION)->normal; - $hash->{VERSIONFLOWSET} = $flowsetversion; + $hash->{VERSIONFLOWSET} = FHEM::Meta::Get( $hash, 'x_flowsetversion' ); CommandAttr( undef, $name . ' room AMAD' ) if ( AttrVal( $name, 'room', 'none' ) eq 'none' ); @@ -890,6 +876,8 @@ sub ProcessRead($$) { my ( $hash, $buf ) = @_; my $name = $hash->{NAME}; + my $flowsetversion = + $modules{AMADCommBridge}{defptr}{BRIDGE}->{VERSIONFLOWSET}; my @data = split( '\R\R', $buf ); my $data = $data[0]; @@ -1286,10 +1274,6 @@ sub ParseMsg($$) { return ( $msg, $tail ); } -sub Flowsetversion() { - return $flowsetversion; -} - ##### bleibt zu Anschauungszwecken erhalten #sub Header2Hash($) { # @@ -1478,7 +1462,8 @@ sub Flowsetversion() { ], "release_status": "stable", "license": "GPL_2", - "version": "v4.4.2", + "version": "v4.4.3", + "x_flowsetversion": "4.4.1", "author": [ "Marko Oldenburg " ], diff --git a/fhem/FHEM/74_AMADDevice.pm b/fhem/FHEM/74_AMADDevice.pm index d3917e4e3..6c5f46761 100644 --- a/fhem/FHEM/74_AMADDevice.pm +++ b/fhem/FHEM/74_AMADDevice.pm @@ -52,9 +52,9 @@ use warnings; use POSIX; use FHEM::Meta; use Data::Dumper; #only for Debugging -use GPUtils qw(GP_Import); +use GPUtils qw(GP_Import GP_Export); -require FHEM::73_AMADCommBridge; +require '73_AMADCommBridge.pm'; my $missingModul = ''; eval "use Encode qw(encode encode_utf8);1" or $missingModul .= 'Encode '; @@ -165,19 +165,8 @@ BEGIN { ); } -# _Export - Export references to main context using a different naming schema -sub _Export { - no strict qw/refs/; ## no critic - my $pkg = caller(0); - my $main = $pkg; - $main =~ s/^(?:.+::)?([^:]+)$/main::$1\_/g; - foreach (@_) { - *{ $main . $_ } = *{ $pkg . '::' . $_ }; - } -} - #-- Export to main context with different name -_Export( +GP_Export( qw( Initialize ) @@ -251,12 +240,11 @@ sub Define($$) { my $amad_id = $a[3]; my $remoteServer = $a[4]; - $hash->{HOST} = $host; - $hash->{AMAD_ID} = $amad_id; - $hash->{VERSION} = version->parse($VERSION)->normal; - $hash->{VERSIONFLOWSET} = AMADCommBridge_Flowsetversion(); - $hash->{NOTIFYDEV} = 'global,' . $name; - $hash->{MODEL} = $remoteServer; + $hash->{HOST} = $host; + $hash->{AMAD_ID} = $amad_id; + $hash->{VERSION} = version->parse($VERSION)->normal; + $hash->{NOTIFYDEV} = 'global,' . $name; + $hash->{MODEL} = $remoteServer; $hash->{PORT} = 8090 if ( $remoteServer eq 'Automagic' ); $hash->{PORT} = 1817 if ( $remoteServer eq 'Autoremote' ); @@ -289,6 +277,9 @@ sub Define($$) { $iodev = $hash->{IODev}->{NAME}; +# $hash->{VERSIONFLOWSET} = FHEM::Meta::Get( $defs{$iodev}, 'x_flowsetversion' ); + $hash->{VERSIONFLOWSET} = $defs{$iodev}->{VERSIONFLOWSET}; + my $d = $modules{AMADDevice}{defptr}{$amad_id}; return @@ -1689,7 +1680,7 @@ sub CreateChangeBtDeviceValue($$) { ], "release_status": "stable", "license": "GPL_2", - "version": "v4.4.2", + "version": "v4.4.3", "author": [ "Marko Oldenburg " ],