diff --git a/FHEM/60_EM.pm b/FHEM/60_EM.pm index 2557414c5..b32a2e4ee 100755 --- a/FHEM/60_EM.pm +++ b/FHEM/60_EM.pm @@ -333,4 +333,40 @@ DONE: return undef; } + +######################### +# Interpretation is left for the "user"; +sub +EmGetDevData($) +{ + my ($hash) = @_; + + my $dnr = $hash->{DEVNR}; + my $d = IOWrite($hash, sprintf("7a%02x", $dnr-1)); + + return("ERROR: No device no. $dnr present") + if($d eq ((pack('H*',"00") x 45) . pack('H*',"FF") x 6)); + + my $nrreadings = w($d,2); + return("ERROR: No data to read (yet?)") + if($nrreadings == 0); + + my $step = b($d,6); + my $start = b($d,18)+13; + my $end = $start + int(($nrreadings-1)/64)*$step; + + my @ret; + for(my $p = $start; $p <= $end; $p += $step) { # blockwise + $d = IOWrite($hash, sprintf("52%02x%02x00000801", $p%256, int($p/256))); + my $max = (($p == $end) ? ($nrreadings%64)*4+4 : 260); + my $step = b($d, 6); + + for(my $off = 8; $off <= $max; $off += 4) { # Samples in each block + push(@ret, sprintf("%04x%04x\n", w($d,$off), w($d,$off+2))); + } + } + return @ret; +} + + 1; diff --git a/FHEM/80_M232.pm b/FHEM/80_M232.pm index 98aa53589..366302842 100644 --- a/FHEM/80_M232.pm +++ b/FHEM/80_M232.pm @@ -1,3 +1,9 @@ +# +# +# 80_M232.pm +# written by Dr. Boris Neubert 2007-11-26 +# e-mail: omega at online dot de +# ############################################## package main; @@ -77,18 +83,23 @@ M232_Undef($$) ##################################### + sub M232_Set($@) { my ($hash, @a) = @_; my $u1 = "Usage: set auto \n" . "set stop\n" . - "set start"; + "set start\n" . + "set octet \n" . + "set [io0..io7] 0|1\n"; return $u1 if(int(@a) < 2); my $msg; + my $reading= $a[1]; - if($a[1] eq "auto") { + + if($reading eq "auto") { return $u1 if(int(@a) !=3); my $value= $a[2]; my @legal= (0..5,"none"); @@ -99,16 +110,33 @@ M232_Set($@) $msg= "M" . $value; } - elsif($a[1] eq "start") { + elsif($reading eq "start") { return $u1 if(int(@a) !=2); $msg= "Z1"; } - elsif($a[1] eq "stop") { + elsif($reading eq "stop") { return $u1 if(int(@a) !=2); $msg= "Z0"; } + elsif($reading eq "octet") { + return $u1 if(int(@a) !=3); + my $value= $a[2]; + my @legal= (0..255); + if(!grep($value eq $_, @legal)) { + return "Illegal value $value, possible values: 0..255"; + } + $msg= sprintf("W%02X", $value); + } + + elsif($reading =~ /^io[0-7]$/) { + return $u1 if(int(@a) !=3); + my $value= $a[2]; + return $u1 unless($value eq "0" || $value eq "1"); + $msg= "D" . substr($reading,2,1) . $value; + } + else { return $u1; } my $d = M232GetData($hash->{DeviceName}, $msg); @@ -147,7 +175,7 @@ M232_Get($@) $msg= "a" . substr($reading,2,1); my $d = M232GetData($hash->{DeviceName}, $msg); return "Read error" if(!defined($d)); - my $voltage= hex substr($d,0,3); + my $voltage= (hex substr($d,0,3))*5.00/1024.0; my $iscurrent= substr($d,3,1); $retval= $voltage; # . " " . $iscurrent; } diff --git a/FHEM/81_M232Counter.pm b/FHEM/81_M232Counter.pm index 221630e56..92d10dda0 100644 --- a/FHEM/81_M232Counter.pm +++ b/FHEM/81_M232Counter.pm @@ -1,3 +1,9 @@ +# +# +# 81_M232Counter.pm +# written by Dr. Boris Neubert 2007-11-26 +# e-mail: omega at online dot de +# ############################################## package main; diff --git a/contrib/em1010.pl b/contrib/em1010.pl index 2b0601116..5a26c06db 100755 --- a/contrib/em1010.pl +++ b/contrib/em1010.pl @@ -350,7 +350,6 @@ getDevData() if($smooth && (w($d,$off+2) == 0xffff)) { # "smoothing" next; } else { -printf ("%d %d\n", $div, $backlog); my $v = w($d,$off)*12/$div/$backlog; my $f1 = b($d,$off+2); my $f2 = b($d,$off+3); diff --git a/docs/commandref.html b/docs/commandref.html index cff6e800f..3bc65ff0d 100644 --- a/docs/commandref.html +++ b/docs/commandref.html @@ -652,9 +652,9 @@ split in multiple lines

Type WS300

    - define WS300Device WS300 <serial device>
    + define WS300Device WS300 <serial device>
    or
    - define <devname> WS300 [0-9]
    + define <devname> WS300 [0-9]

    The first line is mandatory if you have a WS300 device: it defines the input device with its USB port. The name of this device is fixed and must @@ -733,6 +733,52 @@ split in multiple lines


+ + +

Type M232

+
    + define <name> M232 <m232-device> +

    + + Define a M232 device. You can attach as many M232 devices as you like. A + M232 device provides 6 analog inputs (voltage 0..5V with 10 bit resolution) + and 8 bidirectional digital ports. The eighth digital port can be used as a + 16 bit counter (maximum frequency 3kHz). The M232 device needs to be + connected to a 25pin sub-d RS232 serial port. A USB-to-serial converter + works fine if no serial port is available.

    + + Examples: +
      + define m232 M232 /dev/ttyUSB2
      +
    +
    +
+ + +

Type M232Counter

+
    + define <name> M232Counter [unit [factor]] +

    + + Define at most one M232Counter for a M232 device. Defining a M232Counter + will schedule an internal task, which reads the status of the counter every + minute, and triggers notify/filelog commands. unit is the unit + name, factor is used to calculate the reading of the counter + from number of ticks.


    Note: the unit defaults to the string + "ticks", but it must be specified if you wish to set the factor, which + defaults to 1.0. In the second example below one tick equals 1/1250th kWh. + Do not forget to start the counter (with set .. start for + M232) or to start the counter and set the reading to a specified value + (with set ... value for M232Counter).

    + Example: +
      + define counter M232Counter turns
      + define counter M232Counter kWh 0.0008
      +
    +
    +
+ +

Type SCIVT

    @@ -1058,6 +1104,39 @@ split in multiple lines



    This is the same command which is scheduled every 5 minutes internally.
+ +

Type M232:

+
    + get <name> [an0..an5] +

    + Gets the reading of analog input 0..5 in volts. +

    + get <name> [io0..io7] +

    + Gets the state of digital ports 0..7, result is 0 or 1. +

    + get <name> octet +

    + Gets the state of all digital ports at once, result is 0..255. +

    + get <name> counter +

    + Gets the number of ticks of the counter since the last reset. The counter + wraps around from 65535 to 0. +

    +
+ +

Type M232Counter:

+
    + get <name> status +

    + Gets the reading of the counter multiplied by the factor from the + define statement. Wraparounds of the counter are accounted for + by an offset (see reading basis in the output of the + list statement for the device). +

    +
+ @@ -1289,7 +1368,7 @@ Send buffer:
2007-10-19 00:31:24 desired-temp 22.5
  • In order to set the time of your FHT's, schedule this command every minute:
    define fhz_timer at +*00:01:00 set FHZ time
    - See the loglevel to prevent logging of + See the loglevel to prevent logging of this command.
  • FHTcode is a two digit hex number (from 00 to 63?) and sets the @@ -1479,7 +1558,7 @@ must between 5.5 and 30.5 Celsius. Value 5.5 set the actuator to OFF, value 30.

    Type WS300:

      - set WS300Device <interval(min.)> <height(m)> <rainvalume(ml)> + set WS300Device <interval(min.)> <height(m)> <rainvalume(ml)>

      Set some WS300 configuration parameters.
    @@ -1487,7 +1566,7 @@ must between 5.5 and 30.5 Celsius. Value 5.5 set the actuator to OFF, value 30.

    Type EMWZ:

      - set EMWZdevice <param> <value>

      + set EMWZdevice <param> <value>

      where param is one of:
      • rperkw
        @@ -1505,6 +1584,35 @@ must between 5.5 and 30.5 Celsius. Value 5.5 set the actuator to OFF, value 30.
    +

    Type M232:

    +
      + set <name> stop +

      + Stops the counter. +

      + set <name> start +

      + Resets the counter to zero and starts it. +

      + set <name> octet +

      + Sets the state of all digital ports at once, value is 0..255. +

      + set <name> [io0..io7] 0|1 +

      + Turns digital port 0..7 off or on. +

      +
    + +

    Type M232Counter:

    +
      + set <name> value <value> +

      + Sets the reading of the counter to the given value. The counter is reset + and started and the offset is adjusted to value/unit. +

      +
    + @@ -1644,7 +1752,7 @@ must between 5.5 and 30.5 Celsius. Value 5.5 set the actuator to OFF, value 30.
  • To access the numerical value of an FS20 command (e.g. toggle), use the - hash fs20_c2b. E.g. { Log 2, $fs20_c2b{"toggle"} } + hash fs20_c2b. E.g. { Log 2, $fs20_c2b{"toggle"} }
  • diff --git a/docs/fhem.html b/docs/fhem.html index 1f8d2bee3..ceb129217 100644 --- a/docs/fhem.html +++ b/docs/fhem.html @@ -15,26 +15,25 @@ Formerly known as fhz1000.pl

    News (as of =DATE=, Version =VERS=)

      -
    • doc: linux.html (private udev-rules, not 50-..., ATTRS) -
    • bugfix: setting devices with "-" in their name did not work -
    • doc: fhem.pl and commandref.html (notifyon -> notify, correction - of examples) -
    • feature: modify command added -
    • feature: The "-" in the name is not allowed any more -
    • bugfix: disabled notify causes "uninitialized value" (STefan, 1.5) -
    • bugfix: deleted FS20 items are still logging (zombie) (Gerhard, 16.5) -
    • bugfix: added FS20S8, removed stty_parmrk (Martin, 24.5) -
    • feature: added archivedir/archivecmd to the FileLog -
    • feature: added EM1010PC/EM1000WZ/EM1000EM support -
    • bugfix: undefined messages for unknown HMS devs (Peter, 8.6) -
    • bugfix: em1010 and %oldvalue bugs (Peter, 9.6) -
    • bugfix: SCIVT solar controller (peterp, 1.7) -
    • bugfix: WS300 loglevel change (from 2 to 5 or device specific loglevel) -
    • feature: First steps for a Fritz!Box port. See the fritzbox.html +
    • feature: added archivedir/archivecmd to the the main logfile +
    • feature: 99_Sunrise_EL.pm (does not need any Date modules) +
    • bugfix: seldom xmllist error resulting in corrupt xml (Martin/Peter, 4.9) +
    • bugfix: FHT mode holiday_short added (9.9, Dirk) +
    • bugfix: Modifying a device from its own trigger crashes (Klaus, 10.9) +
    • feature: webpgm2 output reformatted +
    • feature: webpgm2 displaying multiple plots
    • feature: FHT lime-protection code discovered by Dirk (7.10) -
    • feature: Softwarebuffer for FHT devices with queuing unsent commands and repeating commands by transmission failure (Dirk 17.10) -
    • feature: FHT low temperatur warning and setting for lowtemp-offset (Dirk 17.10) -
    • change: Change naming for state into warnings (Dirk 17.10) +
    • feature: softwarebuffer for FHT devices (Dirk 17.10) +
    • feature: FHT low temperatur warning and offset (Dirk 17.10) +
    • change: change FHT state into warnings (Dirk 17.10) +
    • feature: Softwarebuffer code simplified (Rudi 22.11) +
    • bugfix: bug #12327 doppeltes my +
    • bugfix: set STATE from trigger +
    • bugfix: readings state vs STATE problem (xmllist/trigger) +
    • change: SUNRISE doc changed (99_SUNRISE.pm -> 99_SUNRISE_EL.pm) +
    • feature: support for the M232 ELV device (Boris, 25.11) +
    • feature: alternativ Quad-based numbers for the FS20 (Matthias, 24.11) +
    • feature: dummy type added (contrib/99_dummy.pm)
    @@ -55,8 +54,8 @@ Currently implemented features:
  • reading and sending FS20 events (on/off/dimming, timer commands)
  • support of FS20 address features function group, local and global master
  • reading and changing FHT80b parameters (temp, actuator, etc).
    - The FHT8b seems to work too. Note: the FHT8 wont work.
    - For FHT8b devices, FHEM have an internal software buffer for sending commands step by step. This buffer should prevent lost commands. In case of transmission failures FHEM tries to resend commands.
    + The FHT8b seems to work too. Note: the FHT8 wont work.
    + Internal software buffer to prevent lost commands.
  • reading HMS data (HMS100-T,-TF,-WD,-MG,-TFK and RM100-2)
  • reading KS300 data
  • @@ -64,7 +63,8 @@ Currently implemented features:
  • reading WS300 data, and up to 9 attached devices
  • reading EM1000WZ/EM1000EM data via an attached EM1010PC
  • -
  • reading an attached SCIVT device
  • +
  • reading attached SCIVT devices
  • +
  • reading attached M232 devices
  • logging events to files (or database), with regexp filters
  • notifying external programs or internal modules when receiving certain events
  • diff --git a/docs/pgm2-1.gif b/docs/pgm2-1.gif deleted file mode 100644 index e791dcc5c..000000000 Binary files a/docs/pgm2-1.gif and /dev/null differ diff --git a/docs/pgm2-1.png b/docs/pgm2-1.png new file mode 100644 index 000000000..62144a743 Binary files /dev/null and b/docs/pgm2-1.png differ diff --git a/docs/pgm2-2.gif b/docs/pgm2-2.gif deleted file mode 100644 index 5322b3613..000000000 Binary files a/docs/pgm2-2.gif and /dev/null differ diff --git a/docs/pgm2-2.png b/docs/pgm2-2.png new file mode 100644 index 000000000..0735a2745 Binary files /dev/null and b/docs/pgm2-2.png differ diff --git a/docs/pgm2-3.gif b/docs/pgm2-3.gif deleted file mode 100644 index 0ee6d92d5..000000000 Binary files a/docs/pgm2-3.gif and /dev/null differ