diff --git a/fhem/CHANGED b/fhem/CHANGED index aff6a4272..af8f045da 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. + - feature: 44_S7: new attribute receiveTimeoutMs - feature: 38_CO20: introduced state reading - change: 73_NUKIBridge,74_NUKIDevice: fix Perlwarnings - bugfix: 38_CO20: fixed definition with serial number diff --git a/fhem/FHEM/44_S7.pm b/fhem/FHEM/44_S7.pm index 4270c2399..0e863c165 100644 --- a/fhem/FHEM/44_S7.pm +++ b/fhem/FHEM/44_S7.pm @@ -57,7 +57,7 @@ sub S7_Initialize($) { #S5_OK $hash->{SetFn} = "S7_Set"; $hash->{AttrFn} = "S7_Attr"; - $hash->{AttrList} = "MaxMessageLength Intervall " . $readingFnAttributes; + $hash->{AttrList} = "MaxMessageLength Intervall receiveTimeoutMs " . $readingFnAttributes; # $hash->{AttrList} = join( " ", @areasconfig )." PLCTime"; } @@ -157,6 +157,8 @@ sub S7_reconnect($) { #S5 OK my $hash = shift @_; S7_disconnect($hash) if ( defined( $hash->{S7PLCClient} ) ); + + if ( $hash->{S7TYPE} eq "S5" ) { $hash->{S7PLCClient} = S5Client->new(); } @@ -239,7 +241,7 @@ sub S7_Define($$) { # S5 OK $hash->{LocalTSAP} = $LocalTSAP; $hash->{RemoteTSAP} = $RemoteTSAP; $hash->{maxPDUlength} = $PDUlength; #initial PDU length - + $hash->{receiveTimeoutMs} = 500; #default receiving timeout = 500ms Log3 $name, 4, "S7: define $name PLC_address=$PLC_address,LocalTSAP=$LocalTSAP, RemoteTSAP=$RemoteTSAP "; @@ -325,7 +327,21 @@ sub S7_Attr(@) { Log3( $name, 3, "$name S7_Attr: setting Intervall= $aVal" ); } + } elsif ($aName eq "receiveTimeoutMs") { + if ( $aVal > 100 && $aVal < 10000) { + + $hash->{receiveTimeoutMs} = $aVal; + + Log3( $name, 3, "$name S7_Attr: setting receiveTimeoutMs= $aVal" ); + + #reconnect with the new receiving timeout + + $hash->{S7PLCClient}->setRecvTimeout($hash->{receiveTimeoutMs}) if ( defined( $hash->{S7PLCClient} ) ); + } + } + + ########### if ( $aName eq "WriteInputs-Config" @@ -1101,158 +1117,218 @@ sub S7_readFromPLC($) { #S5 OK 1; + =pod =item summary basic interface to a SIEMENS S7 / S5 =item summary_DE Schnittstelle zu einer Siemens S7 / S5 =begin html - +

S7

+

 

+



+



+ +



+ +



+ +

 

+ +

 

+ +



Definedefine <name> S7 <PLC_address> <rack> <slot> [<Interval>]

define logo S7 10.0.0.241 2 0

+ +

 

+ +

 

+ +

 

+ +

 

+ +



Attr

+ +

 

+ +

 

+ =end html =begin html_DE - +

S7

+

 

+



+



+ +



+ +



+ +

 

+ +

 

+ +



Definedefine <name> S7 <PLC_address> <rack> <slot> [<Interval>]

define logo S7 10.0.0.241 2 0

+ +

 

+ +

 

+ +

 

+ +

 

+ +



Attr

+ +

 

+ +

 

+ =end html_DE =cut diff --git a/fhem/FHEM/44_S7_Client.pm b/fhem/FHEM/44_S7_Client.pm index cf6a3a4e0..df5b75a92 100644 --- a/fhem/FHEM/44_S7_Client.pm +++ b/fhem/FHEM/44_S7_Client.pm @@ -419,6 +419,14 @@ sub PutFloatAt { return $self->setFloatAt( $Buffer, $index, $value ); } + +#----------------------------------------------------------------------------- +sub setRecvTimeout { + + my ( $self, $newRecvTimeout ) = @_; + + $self->{RecvTimeout} = $newRecvTimeout; +} #----------------------------------------------------------------------------- sub version { @@ -427,6 +435,8 @@ sub version { #----------------------------------------------------------------------------- + + sub getErrorStr { } @@ -453,4 +463,4 @@ sub getErrorStr { =end html_DE -=cut \ No newline at end of file +=cut