2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

M232 merge, some new snapshots

git-svn-id: https://svn.fhem.de/fhem/trunk@111 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2007-11-27 09:14:25 +00:00
parent ed07484166
commit 1a204bcdfc
11 changed files with 211 additions and 34 deletions

View File

@ -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;

View File

@ -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 <name> auto <value>\n" .
"set <name> stop\n" .
"set <name> start";
"set <name> start\n" .
"set <name> octet <value>\n" .
"set <name> [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;
}

View File

@ -1,3 +1,9 @@
#
#
# 81_M232Counter.pm
# written by Dr. Boris Neubert 2007-11-26
# e-mail: omega at online dot de
#
##############################################
package main;

View File

@ -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);

View File

@ -652,9 +652,9 @@ split in multiple lines<br><br>
<a name="WS300"></a>
<h4>Type WS300</h4>
<ul>
<code>define WS300Device WS300 &lt;serial device&gt;<br>
<code>define WS300Device WS300 &lt;serial device&gt;</code><br>
or<br>
<code>define &lt;devname&gt WS300 [0-9]<br>
<code>define &lt;devname&gt WS300 [0-9]</code><br>
<br>
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<br><br>
<br>
</ul>
<a name="M232"></a>
<h4>Type M232</h4>
<ul>
<code>define &lt;name&gt; M232 &lt;m232-device&gt;</code>
<br><br>
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.<br><br>
Examples:
<ul>
<code>define m232 M232 /dev/ttyUSB2</code><br>
</ul>
<br>
</ul>
<a name="M232Counter"></a>
<h4>Type M232Counter</h4>
<ul>
<code>define &lt;name&gt; M232Counter [unit [factor]]</code>
<br><br>
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. <code>unit</code> is the unit
name, <code>factor</code> is used to calculate the reading of the counter
from number of ticks. <br><br> <br>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 <code>set .. start</code> for
M232) or to start the counter and set the reading to a specified value
(with <code>set ... value</code> for M232Counter). <br><br>
Example:
<ul>
<code>define counter M232Counter turns</code><br>
<code>define counter M232Counter kWh 0.0008</code><br>
</ul>
<br>
</ul>
<a name="SCIVT"></a>
<h4>Type SCIVT</h4>
<ul>
@ -1058,6 +1104,39 @@ split in multiple lines<br><br>
<br><br>
This is the same command which is scheduled every 5 minutes internally.
</ul>
<h4>Type M232:</h4>
<ul>
<code>get &lt;name&gt; [an0..an5]</code>
<br><br>
Gets the reading of analog input 0..5 in volts.
<br><br>
<code>get &lt;name&gt; [io0..io7]</code>
<br><br>
Gets the state of digital ports 0..7, result is 0 or 1.
<br><br>
<code>get &lt;name&gt; octet</code>
<br><br>
Gets the state of all digital ports at once, result is 0..255.
<br><br>
<code>get &lt;name&gt; counter</code>
<br><br>
Gets the number of ticks of the counter since the last reset. The counter
wraps around from 65535 to 0.
<br><br>
</ul>
<h4>Type M232Counter:</h4>
<ul>
<code>get &lt;name&gt; status</code>
<br><br>
Gets the reading of the counter multiplied by the factor from the
<code>define</code> statement. Wraparounds of the counter are accounted for
by an offset (see reading <code>basis</code> in the output of the
<code>list</code> statement for the device).
<br><br>
</ul>
</ul>
@ -1289,7 +1368,7 @@ Send buffer:<br /> 2007-10-19 00:31:24 desired-temp 22.5
<li>In order to set the time of your FHT's, schedule this command every
minute:<br>
<code>define fhz_timer at +*00:01:00 set FHZ time</code><br>
See the <a href="#loglevel">loglevel<a> to prevent logging of
See the <a href="#loglevel">loglevel</a> to prevent logging of
this command.
</li>
<li>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.
<a name="WS300set"></a>
<h4>Type WS300:</h4>
<ul>
<code>set WS300Device &lt;interval(min.)&gt; &lt;height(m)&gt; &lt;rainvalume(ml)&gt;
<code>set WS300Device &lt;interval(min.)&gt; &lt;height(m)&gt; &lt;rainvalume(ml)&gt;</code>
<br><br>
Set some WS300 configuration parameters.
</ul>
@ -1487,7 +1566,7 @@ must between 5.5 and 30.5 Celsius. Value 5.5 set the actuator to OFF, value 30.
<a name="EMWZset"></a>
<h4>Type EMWZ:</h4>
<ul>
<code>set EMWZdevice &lt;param&gt; &lt;value&gt;<br><br>
<code>set EMWZdevice &lt;param&gt; &lt;value&gt;</code><br><br>
where param is one of:
<ul>
<li>rperkw<br>
@ -1505,6 +1584,35 @@ must between 5.5 and 30.5 Celsius. Value 5.5 set the actuator to OFF, value 30.
</ul>
</ul>
<h4>Type M232:</h4>
<ul>
<code>set &lt;name&gt; stop</code>
<br><br>
Stops the counter.
<br><br>
<code>set &lt;name&gt; start</code>
<br><br>
Resets the counter to zero and starts it.
<br><br>
<code>set &lt;name&gt; octet <value></code>
<br><br>
Sets the state of all digital ports at once, value is 0..255.
<br><br>
<code>set &lt;name&gt; [io0..io7] 0|1</code>
<br><br>
Turns digital port 0..7 off or on.
<br><br>
</ul>
<h4>Type M232Counter:</h4>
<ul>
<code>set &lt;name&gt; value &lt;value&gt;</code>
<br><br>
Sets the reading of the counter to the given value. The counter is reset
and started and the offset is adjusted to value/unit.
<br><br>
</ul>
</ul>
@ -1644,7 +1752,7 @@ must between 5.5 and 30.5 Celsius. Value 5.5 set the actuator to OFF, value 30.
<li>
To access the numerical value of an FS20 command (e.g. toggle), use the
hash <code>fs20_c2b<code>. E.g. { Log 2, $fs20_c2b{"toggle"} }
hash <code>fs20_c2b</code>. E.g. { Log 2, $fs20_c2b{"toggle"} }
</li>
<li>

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

BIN
fhem/docs/pgm2-1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

BIN
fhem/docs/pgm2-2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB