diff --git a/fhem/FHEM/00_OWX.pm b/fhem/FHEM/00_OWX.pm index 4b325d0cc..d9d0f293c 100644 --- a/fhem/FHEM/00_OWX.pm +++ b/fhem/FHEM/00_OWX.pm @@ -5,7 +5,7 @@ # * via an active DS2480 bus master interface attached to a TCP/IP-UART device # * via a network-attached CUNO # * via a COC attached to a Raspberry Pi -# * via an Arduino running OneWireFirmata attached to USB +# * via an Arduino running OneWireFirmata # # Prof. Dr. Peter A. Henning # @@ -54,7 +54,7 @@ use vars qw{%owg_family %gets %sets $owx_version $owx_debug}; # 1-Wire devices # http://owfs.sourceforge.net/family.html %owg_family = ( - "01" => ["DS2401/DS1990A","OWID DS2401"], + "01" => ["DS2401/DS2411/DS1990A","OWID DS2401"], "05" => ["DS2405","OWID DS2405"], "09" => ["DS2502","OWID DS2502"], "10" => ["DS18S20/DS1920","OWTHERM DS1820"], @@ -81,21 +81,16 @@ use vars qw{%owg_family %gets %sets $owx_version $owx_debug}; %gets = ( "alarms" => "A", "devices" => "D", - "qstatus" => "Q", "version" => "V" ); #-- These occur in a pulldown menu as settable values for the bus master %sets = ( - "close" => "c", "open" => "o", "closeopen" => "co" ,"reopen" => "R", - "discover" => "C", - "detect" => "T", - "disconnected" => "D", - "process" => "P" + "reopen" => "R" ); #-- some globals needed for the 1-Wire module -$owx_version="7.03"; +$owx_version="7.04"; #-- debugging now verbosity, this is just for backward compatibility $owx_debug=0; @@ -115,13 +110,11 @@ $owx_debug=0; sub OWX_Initialize ($) { my ($hash) = @_; - #-- Provider $hash->{Clients} = ":OWAD:OWCOUNT:OWID:OWLCD:OWMULTI:OWSWITCH:OWTHERM:OWVAR:"; $hash->{WriteFn} = "OWX_Write"; $hash->{ReadFn} = "OWX_Read"; $hash->{ReadyFn} = "OWX_Ready"; - #-- Consumer $hash->{DefFn} = "OWX_Define"; $hash->{UndefFn} = "OWX_Undef"; $hash->{GetFn} = "OWX_Get"; @@ -183,7 +176,7 @@ sub OWX_Define ($$) { $hwdevice = OWX_TCP->new($hash); #-- check if we have an i2c interface attached - }elsif( $dev =~ m|\d\:\d\d| ){ + }elsif( $dev =~ m|^\d\:\d\d| ){ require "$attr{global}{modpath}/FHEM/11_OWX_I2C.pm"; $hwdevice = OWX_I2C->new($hash); @@ -693,24 +686,6 @@ sub OWX_Get($@) { my $res = OWX_Discover($hash); #-- process result return $res - - } elsif( $a[1] eq "qstatus") { - my $qlen = ($hash->{QUEUE} ? scalar(@{$hash->{QUEUE}}) : 0); - my $state = $hash->{STATE}; - my $dev = $hash->{DeviceName}; - my $busy = ($hash->{BUSY})? "BUSY" : "NOT BUSY"; - my $block = ($hash->{BLOCK})? "BLOCKED" : "NOT BLOCKED"; - $hash->{BUSY} = 1; - - - my $rout=''; - my $hash2 = $selectlist{'OWX_WIFI.192.168.0.97:23'}; - my $vc = vec($rout, $hash2->{FD}, 1); - my $res = "OWX: Queue $name: => dev=$dev vc=$vc length=$qlen, state=$state, $busy, $block\n"; - foreach my $diapoint (@{$hash->{QUEUE}}) { - $res .= " => ".$diapoint->{owx_dev}." context ".$diapoint->{context}." expecting ".$diapoint->{numread}." bytes, ".$diapoint->{status}."\n"; - } - return $res; } elsif( $a[1] eq "version") { return $owx_version; @@ -1008,17 +983,10 @@ sub OWX_Ready($) { } return undef; } - - #-- If we are here, we are disconnected - #return DevIo_OpenDev($hash, 1, undef ) if ( $hash->{STATE} eq "disconnected" ); - #return DevIo_OpenDev($hash,1,"main::OWX_Init") if ( $hash->{STATE} eq "disconnected" ); #-- get the interface my $owx = $hash->{OWX}; my $name = $hash->{NAME}; - - #Log3 $name,1,"OWX_Ready called for $name"; - my $time = time(); #-- skip this if delay time is not yet over @@ -1056,60 +1024,15 @@ sub OWX_Set($@) { #-- for the selector: which values are possible return join(" ", sort keys %sets) if(!defined($sets{$a[0]})); - #return "OWX_Set: With unknown argument $a[0], choose one of " . join(" ", sort keys %sets) - # if(!defined($sets{$a[0]})); - - #-- Set closedev - if( $a[0] eq "close" ){ - OWX_WDBGL($name,1,"====> CLOSING DEVICE",main::DevIo_CloseDev($hash)); - $res = 0; - } - - #-- Set opendev - if( $a[0] eq "open" ){ - OWX_WDBGL($name,1,"====> OPENING DEVICE",main::DevIo_OpenDev($hash,0,undef)); - $res = 0; - } - - #-- Set closeopendev - if( $a[0] eq "closeopen" ){ - OWX_WDBGL($name,1,"====> CLOSING DEVICE",main::DevIo_CloseDev($hash)); - OWX_WDBGL($name,1," OPENING DEVICE",main::DevIo_OpenDev($hash, 0, undef)); - } + return "OWX_Set: With unknown argument $a[0], choose one of " . join(" ", sort keys %sets) + if(!defined($sets{$a[0]})); #-- Set reopen if( $a[0] eq "reopen" ){ - OWX_WDBGL($name,1,"====> REOPENING DEVICE",main::DevIo_OpenDev($hash, 1, undef)); + DevIo_OpenDev($hash, 1, undef); $res = 0; } - - #-- Set discover - if( $a[0] eq "discover" ){ - OWX_Discover($hash); - $res = 0; - } - - #-- Set detect - if( $a[0] eq "detect" ){ - my $owx = $hash->{OWX}; - $owx->Detect(); - $res = 0; - } - - if( $a[0] eq "process") { - my $res = OWX_PrQueue("queue:$name"); - #-- process result - return $res - } - - #-- Set reopen - if( $a[0] eq "disconnected" ){ - main::DevIo_Disconnected($hash); - $res = 0; - } - Log3 $name, 3, "OWX_Set $name ".join(" ",@a)." => $res"; - # DoTrigger($name, undef) if($init_done); } ######################################################################################## @@ -1669,7 +1592,7 @@ sub OWX_WDBGL($$$$) { =pod =item helper =item summary to commmunicate with 1-Wire bus devices -=item summary_DE zur Kommunikationm mit 1-Wire Geräten +=item summary_DE zur Kommunikation mit 1-Wire Geräten =begin html @@ -1680,44 +1603,24 @@ sub OWX_WDBGL($$$$) { port or
- define OWio1 OWX /dev/ttyUSB1
-
- define OWio2 OWX COC
-
- define OWio3 OWX FIRMATA:10
-
-
- define <name> OWX <serial-device> or
- define <name> OWX <tcpip>[:<port>] or
- # define define <name> OWX <cuno/coc-device> or
- define <name> OWX <firmata-device>:<firmata-pin>
-
Define a 1-Wire interface to communicate with a 1-Wire bus.
-
-
To define a 1-Wire interface to communicate with a 1-Wire bus, several possibilities exist:
<serial-device> The serial device (e.g. USB port) to which the
- 1-Wire bus is attached.<cuno-device> The previously defined CUNO to which the 1-Wire bus
- is attached. <arduino-pin> The pin of the previous defined FRM
- to which the 1-Wire bus is attached. If there is more than one FRM device defined
- use IODev attribute to select which FRM device to use.define <name> OWX <serial-device>, i.e. specify the serial device (e.g. USB port) to which the
+ 1-Wire bus is attached, for example define OWio1 OWX /dev/ttyUSB1.define <name> OWX <tcpip>[:<port>], i.e. specify the IP address and port to which the 1-Wire bus is attached,
+ for example define OWio1 OWX 192.168.0.1:23. Attention: no socat program needed. define <name> OWX <cuno/coc-device>, i.e. specify the previously defined COC/CUNO to which the 1-Wire bus
+ is attached, forexample define OWio2 OWX COCdefine <name> OWX <firmata-device>:<firmata-pin>, i.e. specify the name and 1-Wire pin of the previously defined FRM
+ device to which the 1-Wire bus is attached, for example define OWio3 OWX FIRMATA:10.set <name> reopen
- get <name> alarms
- get <name> devices
- get <name> version
+ attr <name> interval <number>
attr <name> IODev
-