Spontaneously received ECMD

Begonnen von NeuFehm, 15 November 2016, 21:03:50

Vorheriges Thema - Nächstes Thema

NeuFehm

Ich möchte gern den "spontanen Empfang", verursacht durch einen Schalter im BUS auf den das ECMD lauscht, verarbeiten.

Zunächst der Auszug aus dem Logfile


# Zunächst sendet der Schalter (Hardware) "#M(E\001\001\001\r\n" und das ECMD empängt:
2016.11.15 20:50:35 5: myMModul: Spontaneously received "#"
2016.11.15 20:50:35 5: myMModul dispatch #
2016.11.15 20:50:35 5: myMModul: Spontaneously received "M(E\001\001\001\r\n"
2016.11.15 20:50:35 5: myMModul dispatch M(E

# außerdem meldet das Relais im Bus (Hardware) die Bestätigung, statt # ein !, also "!M(E\001\001\001\r\n" welches ECMD gleichzeitig empfängt
2016.11.15 20:50:35 5: myMModul: Spontaneously received "!"
2016.11.15 20:50:35 5: myMModul dispatch !
2016.11.15 20:50:35 5: myMModul: Spontaneously received "M(E\001\001\001\r\n"
2016.11.15 20:50:35 5: myMModul dispatch M(E


und hier die dazugehörige Definition in der fhem.cfg
define myMModul ECMD serial /dev/ttyUSB0@9600
attr myMModul classdefs MModul=/opt/fhem/MModul.classdef
attr myMModul partial 2
attr myMModul verbose 5


Nun ist meine Grundüberlegung die, in der MModul.classdef zunächst ein reading zu eröffnen und dieses anschließend mit postproc zu verarbeiten:

reading TModul match "!M.*\n"
postproc TModul {}


Ist mein Ansatz richtig?
Wenn ja, wie müsste das dazugehörige Perl aussehen?

Kann mir jemand eine Richtung geben, damit ich gezielter unterwegs bin?
Vielen lieben Dank vorab.

PS.: Die "Teilung" am # oder ! ist zufällig. Es ist auch schon bei "!M" oder "!M(E" geteilt wurden. Nie waren es allerdings mehr als 2 "Fragmente"

Raspberry Pi B+
RS 485 Schnittstellen: DIGITUS DA-70157, LINKSPTITE RS485/GPIO Shield for Raspberry Pi
RS485 Geräte: Ultraschallsensor für Zisternenfüllstand (Eigenbau), 4x8 Relais-M-Mastermodule (Eigenbau), 6 T-Module (Schalter und 3 analoge Eingänge) (Eigenbau)
sonstige Hardware: 2 Relay Modul

NeuFehm

Mir fiel soeben auf

attr myMModul partial 2
hat NUR Auswirkung auf die Antworten des "set on cmd/set off cmd" und leider NICHT auf die spontanen Empfänge.

Logfile:

# Ohne "attr myMModul partial 2" und der Schalterbetätigung (FHEM-Software)
2016.11.15 21:33:20 5: myMModul: sending command "#M(E\001\001\001\r\n"
2016.11.15 21:33:20 5: myMModul: write "#M(E\001\001\001\r\n", expect !M.*\n
2016.11.15 21:33:20 5: SW: 234d28450101010d0a
2016.11.15 21:33:20 5: myMModul: read "!"
2016.11.15 21:33:20 1: myMModul: unexpected answer "!" received (wrote "#M(E\001\001\001\r\n", expected !M.*\n)
2016.11.15 21:33:20 5: myMModul: received answer "!"
2016.11.15 21:33:20 5: myMModul: read "M(E\001\001\001\r\n"
2016.11.15 21:33:20 5: myMModul: Spontaneously received "M(E\001\001\001\r\n"
2016.11.15 21:33:20 5: myMModul dispatch M(E
# mit "attr myMModul partial 2" und der Schalterbetätigung (FHEM-Software)
2016.11.15 21:34:34 5: myMModul: sending command "#M(E\001\001\000\r\n"
2016.11.15 21:34:34 5: myMModul: write "#M(E\001\001\000\r\n", expect !M.*\n
2016.11.15 21:34:34 5: SW: 234d28450101000d0a
2016.11.15 21:34:34 5: myMModul: read "!M(E\001\001\000\r\n"
2016.11.15 21:34:34 5: myMModul: received answer "!M(E\001\001\000\r\n"
Raspberry Pi B+
RS 485 Schnittstellen: DIGITUS DA-70157, LINKSPTITE RS485/GPIO Shield for Raspberry Pi
RS485 Geräte: Ultraschallsensor für Zisternenfüllstand (Eigenbau), 4x8 Relais-M-Mastermodule (Eigenbau), 6 T-Module (Schalter und 3 analoge Eingänge) (Eigenbau)
sonstige Hardware: 2 Relay Modul

Dr. Boris Neubert

Hallo,

partial funktioniert grundsätzlich auch für spontan empfangene Datagramme - im Code wird gar kein Unterschied gemacht.

Ich habe das Problem jedoch nachstellen können. Die Ursache ist, dass der Anfang des Datagramms auf den regulären Ausdruck hinter expect passt:

2016.11.20 10:53:43 5: myServer: match regex !M.*\n for reading TModul of device myMModul with class MModul

Das irritiert mich sehr: ich verstehe nämlich nicht, warum !M auf den regulären Ausdruck ^!M.*\n$ passt. Hier der Code aus 67_ECMDDevice.pm:

 
if($msg =~ m/^$regex$/) {
    # we found a match
    Log3 $IOhash, 5, "$name: match regex $regex for reading $r of device $d with class $classname";
            ...


Wer gibt mir bitte Nachhilfe?

Viele Grüße
Boris
Globaler Moderator, Developer, aktives Mitglied des FHEM e.V. (Marketing, Verwaltung)
Bitte keine unaufgeforderten privaten Nachrichten!

NeuFehm

#3
Hallo Boris,
da kann ich Dir noch zu wenig sagen.
Aber ich habe mal als Dateianhang zunächst einmal die Hardware skizziert, damit man alles leichter nachvollziehen kann.

Wenn ich in Fhem ein "set 40Relais1 on" sende, schaltet das Relais 1 vom M-Modul mit M-Modul-Adresse 40.
Analog dazu ein "set 40Relais1 off". Ohne die folgende Anweisung, wird die Antwort des M-Moduls als "spontan" gelistet.
Mit dem Code gibt es keine Fehler, auch wenn vlt. der Code suboptimal ist, da ich den nur blind kopiert habe.

set on expect "!M.*\n"
set on postproc {s/([!M.*|;]*)/success/; "$_" eq "success" ? "ok" : "error";}


Meine jetzige Herausforderung besteht in der Erfassung der Anweisung und der Antwort des T-Moduls, wenn ich den Hardware-Taster betätige.
Dann wird der gleiche Code über den Bus gesendet, aber ich habe keine Idee, wie ich den "erfassen/wegordnen" kann.

Meine Idee war zunächst ein fast "identisches" Regex der an/aus-Befehle zu kopieren und daraus ein "reading off" zu machen,
welches am Bus lauscht- Ich schalte über Fhem das Relais an und dachte für den ersten Test das dann per Hardwaretaster auszuschalten.

reading off match "!M.*\n"
reading off postproc {s/([!M.*|;]*)/success/; "$_" eq "success" ? "ok" : "error";}


Hier das dazugehörige Log von per Fhem anschalten und per Hardware ausschalten:

2016.11.20 21:06:08 5: myMModul: sending command "#M(E\001\001\001\r\n"
2016.11.20 21:06:08 5: myMModul: write "#M(E\001\001\001\r\n", expect !M.*\n
2016.11.20 21:06:08 5: SW: 234d28450101010d0a
2016.11.20 21:06:08 5: myMModul: read "!M(E\001\001\001\r\n"
2016.11.20 21:06:08 5: myMModul: received answer "!M(E\001\001\001\r\n"

2016.11.20 21:06:30 5: myMModul: read "#"
2016.11.20 21:06:30 5: myMModul: Spontaneously received "#"
2016.11.20 21:06:30 5: myMModul dispatch #
2016.11.20 21:06:30 5: myMModul: read "M(E\001\001\000\r\n"
2016.11.20 21:06:30 5: myMModul: Spontaneously received "M(E\001\001\000\r\n"
2016.11.20 21:06:30 5: myMModul dispatch M(E

2016.11.20 21:06:30 5: myMModul: read "!"
2016.11.20 21:06:30 5: myMModul: Spontaneously received "!"
2016.11.20 21:06:30 5: myMModul dispatch !
2016.11.20 21:06:30 5: myMModul: read "M(E\001\001\000\r\n"
2016.11.20 21:06:30 5: myMModul: Spontaneously received "M(E\001\001\000\r\n"
2016.11.20 21:06:30 5: myMModul dispatch M(E



Auf die Idee, dass partial hier keine Anwendung findet, bin ich gestoßen, als ich mir die Log-Zeiten anschaute.
Laut Partiallogik müsste doch wenigsten 2 Sekunden später geloggt werden. Also er empfängt, wartet 2 Sekunden und
verwirft, wenn er kein Match hat. Aber da alle Fragmente zur gleichen Zeit geloggt werden, denke ich dass hier das Partial nicht greift.


Außerdem ist mir aufgefallen, dass ich nach jedem Neustart den "deleteattr myMModul requestSeparator" immer wieder per fhem-commandozeile setzen muss,
trotz "safe config". Offensichtlich überschreibt eine Routine speziell diesen Wert. Nach evtl. folgender Logik: "wenn "attr requestSeparator" nicht vorhanden, dann füge es in die fhem.cfg ein.... was jedoch nicht berücksichtigt, dass es schon mal vorhanden sein konnte, aber nicht gewünscht ist.

Raspberry Pi B+
RS 485 Schnittstellen: DIGITUS DA-70157, LINKSPTITE RS485/GPIO Shield for Raspberry Pi
RS485 Geräte: Ultraschallsensor für Zisternenfüllstand (Eigenbau), 4x8 Relais-M-Mastermodule (Eigenbau), 6 T-Module (Schalter und 3 analoge Eingänge) (Eigenbau)
sonstige Hardware: 2 Relay Modul

kaihs

Zitat von: Dr. Boris Neubert am 20 November 2016, 10:59:49
if($msg =~ m/^$regex$/) {
       # we found a match
       Log3 $IOhash, 5, "$name: match regex $regex for reading $r of device $d with class $classname";
            ...

Ich bin zwar auch kein Experte, aber wie soll in

m/^$regex$/


zwischen dem $ für Variablensubstitution und dem $ als Regulärenausdruck unterschieden werden?

Evtl. hilft

$regex = qr/!M.*\n/;
if($msg =~ m/^${regex}$/) {
Banana Pi, Add-On Board mit 1.8" TFT LCD und IR-Sender, CULFW V1.61, div. Homematic Komponenten, Pollin Funksteckdosen, Selbstbau CUL433 MHz, Jeelink Clone, EC3000
Selbstbau CUL868MHz für Wireless M-Bus, SIGNALduino mit Logilink Temp.-sensoren und Auriol Wetterstation

Dr. Boris Neubert

Hallo,

ich wurde in die Irre geführt von meinem eigenen Testsetup, welches ein LF hinterherschickt.

Ich denke, dass Deine Device-Konfiguration falsch ist. Bitte poste sie hier (ECMD und ECMDDevice). Es sollte darin ein

deleteattr DeinECMD replySeparator
attr DeinECDM partial 2

enthalten sein.

Grüße
Boris
Globaler Moderator, Developer, aktives Mitglied des FHEM e.V. (Marketing, Verwaltung)
Bitte keine unaufgeforderten privaten Nachrichten!

NeuFehm

Hallo Boris,
deleteattr myMModul requestSeparator und
deleteattr myMModul replySeparator

werden NIE gespeichert und wenn ich die per Hand in die fehm.cfg reinzwinge,
werden sie beim nächsten "save config" wieder entfernt

Aktuelle komplette fhem.cfg

attr global userattr cmdIcon devStateIcon devStateStyle icon sortby webCmd widgetOverride
attr global autoload_undefined_devices 1
attr global logfile ./log/fhem-%Y-%m.log
attr global modpath .
attr global motd Error messages while initializing FHEM:\
attr global statefile ./log/fhem.save
attr global statefile ./log/fhem.save
attr global updateInBackground 1
attr global verbose 3

define telnetPort telnet 7072 global

define WEB FHEMWEB 8083 global
attr WEB JavaScripts codemirror/fhem_codemirror.js
attr WEB editConfig 1

define WEBphone FHEMWEB 8084 global
attr WEBphone JavaScripts codemirror/fhem_codemirror.js
attr WEBphone stylesheetPrefix smallscreen

define WEBtablet FHEMWEB 8085 global
attr WEBtablet JavaScripts codemirror/fhem_codemirror.js
attr WEBtablet stylesheetPrefix touchpad

# Fake FileLog entry, to access the fhem log from FHEMWEB
define Logfile FileLog ./log/fhem-%Y-%m.log fakelog

define autocreate autocreate
attr autocreate filelog ./log/%NAME-%Y.log

define eventTypes eventTypes ./log/eventTypes.txt

# Disable this to avoid looking for new USB devices on startup
define initialUsbCheck notify global:INITIALIZED usb create
define myMModul ECMD serial /dev/ttyUSB0@9600
attr myMModul classdefs MModul=/opt/fhem/MModul.classdef
attr myMModul logTraffic 5
attr myMModul partial 2
attr myMModul verbose 5
define 40Relais1 ECMDDevice MModul 40 1
attr 40Relais1 IODev myMModul
attr 40Relais1 room Buero

Raspberry Pi B+
RS 485 Schnittstellen: DIGITUS DA-70157, LINKSPTITE RS485/GPIO Shield for Raspberry Pi
RS485 Geräte: Ultraschallsensor für Zisternenfüllstand (Eigenbau), 4x8 Relais-M-Mastermodule (Eigenbau), 6 T-Module (Schalter und 3 analoge Eingänge) (Eigenbau)
sonstige Hardware: 2 Relay Modul

Dr. Boris Neubert

Zitat von: NeuFehm am 21 November 2016, 19:58:08
deleteattr myMModul requestSeparator und
deleteattr myMModul replySeparator

werden NIE gespeichert und wenn ich die per Hand in die fehm.cfg reinzwinge,
werden sie beim nächsten "save config" wieder entfernt

Ich kläre nebenan, ob dass ein Bug oder ein Feature ist.

Bitte behilf Dir damit, die Separatoren auf irgendwas zu setzen, was nie vorkommt, z.B.

attr myMModul requestSeparator workaround
attr myMModul replySeparator workaround



Der Rest sieht OK aus. Wenn Du bitte dann wieder einen Auszug aus dem Log posten könntest.

Grüße
Boris
Globaler Moderator, Developer, aktives Mitglied des FHEM e.V. (Marketing, Verwaltung)
Bitte keine unaufgeforderten privaten Nachrichten!

NeuFehm

#8
myMModul: unknown attribute replySeparator. Type 'attr myMModul ?' for a detailed list.

HAbe ich vlt. keine aktuelle 66_ecmd?
Raspberry Pi B+
RS 485 Schnittstellen: DIGITUS DA-70157, LINKSPTITE RS485/GPIO Shield for Raspberry Pi
RS485 Geräte: Ultraschallsensor für Zisternenfüllstand (Eigenbau), 4x8 Relais-M-Mastermodule (Eigenbau), 6 T-Module (Schalter und 3 analoge Eingänge) (Eigenbau)
sonstige Hardware: 2 Relay Modul

Dr. Boris Neubert

Upsi, das Attribut heißt responseSeparator.
Globaler Moderator, Developer, aktives Mitglied des FHEM e.V. (Marketing, Verwaltung)
Bitte keine unaufgeforderten privaten Nachrichten!

NeuFehm

Beide Werte drin:
define myMModul ECMD serial /dev/ttyUSB0@9600
attr myMModul classdefs MModul=/opt/fhem/MModul.classdef
attr myMModul logTraffic 5
attr myMModul partial 2
attr myMModul requestSeparator workaround
attr myMModul responseSeparator workaround
attr myMModul verbose 5
define 40Relais1 ECMDDevice MModul 40 1
attr 40Relais1 IODev myMModul
attr 40Relais1 room Buero


Hier die Log. Erst an/aus mit FHEM, dann an aus mit Hardware:
2016.11.21 21:25:08 5: myMModul: sending command "#M(E\001\001\001\r\n"
2016.11.21 21:25:08 5: myMModul: write "#M(E\001\001\001\r\n", expect !M.*\n
2016.11.21 21:25:08 5: SW: 234d28450101010d0a
2016.11.21 21:25:08 5: myMModul: read "!M(E\001\001\001\r\n"
2016.11.21 21:25:08 5: myMModul: received answer "!M(E\001\001\001\r\n"
2016.11.21 21:25:13 5: myMModul: sending command "#M(E\001\001\000\r\n"
2016.11.21 21:25:13 5: myMModul: write "#M(E\001\001\000\r\n", expect !M.*\n
2016.11.21 21:25:13 5: SW: 234d28450101000d0a
2016.11.21 21:25:13 5: myMModul: read "!M(E\001\001\000\r\n"
2016.11.21 21:25:13 5: myMModul: received answer "!M(E\001\001\000\r\n"
2016.11.21 21:25:20 5: myMModul: read "#"
2016.11.21 21:25:20 5: myMModul: Spontaneously received "#"
2016.11.21 21:25:20 5: myMModul dispatch #
2016.11.21 21:25:20 5: myMModul: read "M(E\001\001\001\r\n!M(E\001\001\001\r\n"
2016.11.21 21:25:20 5: myMModul: Spontaneously received "M(E\001\001\001\r\n!M(E\001\001\001\r\n"
2016.11.21 21:25:20 5: myMModul dispatch M(E
!M(E

2016.11.21 21:25:24 5: myMModul: read "#"
2016.11.21 21:25:24 5: myMModul: Spontaneously received "#"
2016.11.21 21:25:24 5: myMModul dispatch #
2016.11.21 21:25:24 5: myMModul: read "M(E\001\001\000\r\n"
2016.11.21 21:25:24 5: myMModul: Spontaneously received "M(E\001\001\000\r\n"
2016.11.21 21:25:24 5: myMModul dispatch M(E

2016.11.21 21:25:24 5: myMModul: read "!"
2016.11.21 21:25:24 5: myMModul: Spontaneously received "!"
2016.11.21 21:25:24 5: myMModul dispatch !
2016.11.21 21:25:24 5: myMModul: read "M(E\001\001\000\r\n"
2016.11.21 21:25:24 5: myMModul: Spontaneously received "M(E\001\001\000\r\n"
2016.11.21 21:25:24 5: myMModul dispatch M(E


Habe allerdings nur set-commands in der aktuellen classdef, falls das ne Rolle spielt:
]
params M_Adresse M_Relais
set on cmd {chr(35).chr(77).chr(%M_Adresse).chr(69).chr(1).chr(%M_Relais).chr(1).chr(13).chr(10)}
set on expect "!M.*\n"
set on postproc {s/([!M.*|;]*)/success/; "$_" eq "success" ? "ok" : "error";}
set off cmd {chr(35).chr(77).chr(%M_Adresse).chr(69).chr(1).chr(%M_Relais).chr(0).chr(13).chr(10)}
set off expect "!M.*\n"
set off postproc {s/([!M.*|;]*)/success/; "$_" eq "success" ? "ok" : "error";}


Raspberry Pi B+
RS 485 Schnittstellen: DIGITUS DA-70157, LINKSPTITE RS485/GPIO Shield for Raspberry Pi
RS485 Geräte: Ultraschallsensor für Zisternenfüllstand (Eigenbau), 4x8 Relais-M-Mastermodule (Eigenbau), 6 T-Module (Schalter und 3 analoge Eingänge) (Eigenbau)
sonstige Hardware: 2 Relay Modul

Dr. Boris Neubert

Aha. Als Antwort kommt eine Verkettung von Request und Response und diese auch noch unglücklich am ersten # gesplittet.

Da ja alle Kommandos und Antworten auf \r\n enden, schlage ich vor, dass Du als responseSeparator \n einsetzt. Bitte beim Match berücksichtigen, dass dann \n aus der Antwort herausgeschnitten wird.

Grüße
Boris
Globaler Moderator, Developer, aktives Mitglied des FHEM e.V. (Marketing, Verwaltung)
Bitte keine unaufgeforderten privaten Nachrichten!

NeuFehm

Dann habe ich das Problem, dass der Befehl nicht mehr ausgeführt wird...
Außerdem, schau Dir mal die Anwortzeiten an.

FHEM an: 14:03:40
FHEM aus: 14:03:51
Hardware an: 14:04:10
Hardware aus: 14:04:20


2016.11.22 14:03:40 5: myMModul: sending command "#M(E\001\001\001\r"
2016.11.22 14:03:40 5: myMModul: write "#M(E\001\001\001\r", expect !M.*\r
2016.11.22 14:03:40 5: SW: 234d28450101010d
2016.11.22 14:03:43 2: myMModul: first attempt to read timed out, trying to close and open the device.
2016.11.22 14:03:43 3: Opening myMModul device /dev/ttyUSB0
2016.11.22 14:03:43 3: Setting myMModul serial parameters to 9600,8,N,1
2016.11.22 14:03:43 3: myMModul device opened
2016.11.22 14:03:43 5: SW: 234d28450101010d
2016.11.22 14:03:46 2: myMModul: second attempt to read timed out, this is an unrecoverable error.
2016.11.22 14:03:48 1: myMModul: no answer received (wrote "#M(E\001\001\001\r", expected !M.*\r)
2016.11.22 14:03:48 5: myMModul: received answer ""
2016.11.22 14:03:51 5: myMModul: sending command "#M(E\001\001\000\r"
2016.11.22 14:03:51 5: myMModul: write "#M(E\001\001\000\r", expect !M.*\r
2016.11.22 14:03:51 5: SW: 234d28450101000d
2016.11.22 14:03:54 2: myMModul: first attempt to read timed out, trying to close and open the device.
2016.11.22 14:03:54 3: Opening myMModul device /dev/ttyUSB0
2016.11.22 14:03:54 3: Setting myMModul serial parameters to 9600,8,N,1
2016.11.22 14:03:54 3: myMModul device opened
2016.11.22 14:03:54 5: SW: 234d28450101000d
2016.11.22 14:03:57 2: myMModul: second attempt to read timed out, this is an unrecoverable error.
2016.11.22 14:03:59 1: myMModul: no answer received (wrote "#M(E\001\001\000\r", expected !M.*\r)
2016.11.22 14:03:59 5: myMModul: received answer ""
2016.11.22 14:04:10 5: myMModul: read "#M("
2016.11.22 14:04:10 5: myMModul: Spontaneously received "#M("
2016.11.22 14:04:10 5: myMModul dispatch #M(
2016.11.22 14:04:10 5: myMModul: read "E\001\001\001\r\n"
2016.11.22 14:04:10 5: myMModul: Spontaneously received "E\001\001\001\r\n"
2016.11.22 14:04:10 5: myMModul dispatch E

2016.11.22 14:04:10 5: myMModul: read "!"
2016.11.22 14:04:10 5: myMModul: Spontaneously received "!"
2016.11.22 14:04:10 5: myMModul dispatch !
2016.11.22 14:04:10 5: myMModul: read "M(E\001\001\001\r\n"
2016.11.22 14:04:10 5: myMModul: Spontaneously received "M(E\001\001\001\r\n"
2016.11.22 14:04:10 5: myMModul dispatch M(E

2016.11.22 14:04:20 5: myMModul: read "#"
2016.11.22 14:04:20 5: myMModul: Spontaneously received "#"
2016.11.22 14:04:20 5: myMModul dispatch #
2016.11.22 14:04:20 5: myMModul: read "M(E\001\001\000\r\n"
2016.11.22 14:04:20 5: myMModul: Spontaneously received "M(E\001\001\000\r\n"
2016.11.22 14:04:20 5: myMModul dispatch M(E

2016.11.22 14:04:20 5: myMModul: read "!"
2016.11.22 14:04:20 5: myMModul: Spontaneously received "!"
2016.11.22 14:04:20 5: myMModul dispatch !
2016.11.22 14:04:20 5: myMModul: read "M(E\001\001\000\r\n"
2016.11.22 14:04:20 5: myMModul: Spontaneously received "M(E\001\001\000\r\n"
2016.11.22 14:04:20 5: myMModul dispatch M(E



Wenn das Partial bei "spontan" arbeiten würde, müsste es doch wenigstens 2 Sekunden dauern, bis er checkt, dass nix passt....
Es müsste quasie so aussehen wie der Bereich von "FHEM geschaltet"...

Ich vermute daher immer noch, dass Partial nur für set und get und nicht für sonstige Antworten funktioniert....?
Raspberry Pi B+
RS 485 Schnittstellen: DIGITUS DA-70157, LINKSPTITE RS485/GPIO Shield for Raspberry Pi
RS485 Geräte: Ultraschallsensor für Zisternenfüllstand (Eigenbau), 4x8 Relais-M-Mastermodule (Eigenbau), 6 T-Module (Schalter und 3 analoge Eingänge) (Eigenbau)
sonstige Hardware: 2 Relay Modul

NeuFehm

#13
Ich glaube, nun habe ich einen Denkfehler.
Wenn ich nicht das Richtige "matche" dann ist alles was er findet ein Treffer...
Ich muss mal mein regex-match überarbeiten...

Mh... das sollte aber was finden:
reading TModul match "[#!].*\n" bzw. reading TModul match "[#!].*\\n"
Also ich erwarte entweder ein # oder ein ! und dann kommt irgendwas, allerdings am Schluss ein \n
Trozdem sieht (\n in Seperator wieder zu "workaround" geändert) das log so aus.
Auffällig, dass immer am ! # oder !M und #M getrennt wird.


2016.11.22 18:43:40 5: myMModul: read "#M"
2016.11.22 18:43:40 5: myMModul: Spontaneously received "#M"
2016.11.22 18:43:40 5: myMModul dispatch #M
2016.11.22 18:43:40 5: myMModul: read "(E\001\001\001\r\n"
2016.11.22 18:43:40 5: myMModul: Spontaneously received "(E\001\001\001\r\n"
2016.11.22 18:43:40 5: myMModul dispatch (E

2016.11.22 18:43:40 5: myMModul: read "!M"
2016.11.22 18:43:40 5: myMModul: Spontaneously received "!M"
2016.11.22 18:43:40 5: myMModul dispatch !M
2016.11.22 18:43:40 5: myMModul: read "(E\001\001\001\r\n"
2016.11.22 18:43:40 5: myMModul: Spontaneously received "(E\001\001\001\r\n"
2016.11.22 18:43:40 5: myMModul dispatch (E

2016.11.22 18:43:41 5: myMModul: read "#"
2016.11.22 18:43:41 5: myMModul: Spontaneously received "#"
2016.11.22 18:43:41 5: myMModul dispatch #
2016.11.22 18:43:41 5: myMModul: read "M(E\001\001\000\r\n"
2016.11.22 18:43:41 5: myMModul: Spontaneously received "M(E\001\001\000\r\n"
2016.11.22 18:43:41 5: myMModul dispatch M(E

2016.11.22 18:43:41 5: myMModul: read "!"
2016.11.22 18:43:41 5: myMModul: Spontaneously received "!"
2016.11.22 18:43:41 5: myMModul dispatch !
2016.11.22 18:43:41 5: myMModul: read "M(E\001\001\000\r\n"
2016.11.22 18:43:41 5: myMModul: Spontaneously received "M(E\001\001\000\r\n"
2016.11.22 18:43:41 5: myMModul dispatch M(E


Und ich habe noch einen weiteren Test gemacht.
Habe das set on cmd geleert: set on cmd {}
und dann set 40Relais1 gesendet und sofort den Hardwaretaster gedrückt, in der Hoffnung, dass das expect:

set on expect "#M.*\r\n"

das Ganze erfasst ;)
Leider nicht....

2016.11.22 19:10:59 5: myMModul: sending command "HASH(0x104ca18)"
2016.11.22 19:10:59 5: myMModul: write "HASH(0x104ca18)"
2016.11.22 19:10:59 5: SW: 484153482830783130346361313829
2016.11.22 19:11:00 5: myMModul: read "#"
2016.11.22 19:11:00 5: myMModul: Spontaneously received "#"
2016.11.22 19:11:00 5: myMModul dispatch #
2016.11.22 19:11:00 5: myMModul: read "M(E\001\001\001\r\n"
2016.11.22 19:11:00 5: myMModul: Spontaneously received "M(E\001\001\001\r\n"
2016.11.22 19:11:00 5: myMModul dispatch M(E

2016.11.22 19:11:00 5: myMModul: read "!"
2016.11.22 19:11:00 5: myMModul: Spontaneously received "!"
2016.11.22 19:11:00 5: myMModul dispatch !
2016.11.22 19:11:00 5: myMModul: read "M(E\001\001\001\r\n"
2016.11.22 19:11:00 5: myMModul: Spontaneously received "M(E\001\001\001\r\n"
2016.11.22 19:11:00 5: myMModul dispatch M(E



Und hier der nächste Test in der classdef...:
reading TModul1 match "#"
reading TModul2 match "!"
reading TModul3 match "#M"
reading TModul4 match "!M"

gibt in der Log beim starten einen wichtigen Hinweis???:
2016.11.22 19:28:06 3: Opening myMModul device /dev/ttyUSB0
2016.11.22 19:28:07 3: Setting myMModul serial parameters to 9600,8,N,1
2016.11.22 19:28:07 3: myMModul device opened
2016.11.22 19:28:07 1: myMModul: match for reading TModul1 is not enclosed in double quotes.
2016.11.22 19:28:07 1: myMModul: match for reading TModul3 is not enclosed in double quotes.


Und kein MATCH im log:

2016.11.22 19:30:54 5: myMModul: read "#"
2016.11.22 19:30:54 5: myMModul: Spontaneously received "#"
2016.11.22 19:30:54 5: myMModul dispatch #
2016.11.22 19:30:54 5: myMModul: read "M(E\001\001\000\r\n"
2016.11.22 19:30:54 5: myMModul: Spontaneously received "M(E\001\001\000\r\n"
2016.11.22 19:30:54 5: myMModul dispatch M(E

2016.11.22 19:30:54 5: myMModul: read "!"
2016.11.22 19:30:54 5: myMModul: Spontaneously received "!"
2016.11.22 19:30:54 5: myMModul dispatch !
2016.11.22 19:30:54 5: myMModul: read "M(E\001\001\000\r\n"
2016.11.22 19:30:54 5: myMModul: Spontaneously received "M(E\001\001\000\r\n"
2016.11.22 19:30:54 5: myMModul dispatch M(E

Raspberry Pi B+
RS 485 Schnittstellen: DIGITUS DA-70157, LINKSPTITE RS485/GPIO Shield for Raspberry Pi
RS485 Geräte: Ultraschallsensor für Zisternenfüllstand (Eigenbau), 4x8 Relais-M-Mastermodule (Eigenbau), 6 T-Module (Schalter und 3 analoge Eingänge) (Eigenbau)
sonstige Hardware: 2 Relay Modul

Dr. Boris Neubert

Hallo,

hast Du nur den responseSeparator auf \n gesetzt (sollst Du) oder auch den requestSeparator (sollst Du nicht)?

In der classdef musst Du immer noch bei den cmds das \n mitsenden und bei den expect rauslassen.

Grüße
Boris
Globaler Moderator, Developer, aktives Mitglied des FHEM e.V. (Marketing, Verwaltung)
Bitte keine unaufgeforderten privaten Nachrichten!