ModbusAttr .. Schreibweise

Begonnen von ahermann86, 28 Januar 2019, 13:28:02

Vorheriges Thema - Nächstes Thema

ahermann86

Hallo,
ich habe eine 8-Fach Modbus RTU Platine über Fhem gesteuert. Nachfolgend ist ein Ausschnitt aus der fhem.cfg.
Prinzipiell funktioniert das auch schon ... aber als C Programmierer fragt man sich schon, ob man das auch "einfacher" (typedef...) schreiben kann?


define Modbus_Z2 Modbus /dev/serial/by-path/pci-0000:00:13.0-usb-0:2:1.0-port0@9600

define Mod_Relay ModbusAttr 2 30
attr Mod_Relay IODev Modbus_Z2

attr Mod_Relay obj-h1-bswapRegs 1
attr Mod_Relay obj-h1-hint on,off
attr Mod_Relay obj-h1-map 1:on, 2:off
attr Mod_Relay obj-h1-reading Relay_1
attr Mod_Relay obj-h1-set 1

attr Mod_Relay obj-h2-bswapRegs 1
attr Mod_Relay obj-h2-hint on,off
attr Mod_Relay obj-h2-map 1:on, 2:off
attr Mod_Relay obj-h2-reading Relay_2
attr Mod_Relay obj-h2-set 1

attr Mod_Relay obj-h3-bswapRegs 1
attr Mod_Relay obj-h3-hint on,off
attr Mod_Relay obj-h3-map 1:on, 2:off
attr Mod_Relay obj-h3-reading Relay_3
attr Mod_Relay obj-h3-set 1

.
.
.


Wzut

#1
Schreib den Autor (stefanstrobel) des Moduls an ober er seine dev-h-defLen , dev-h-defPoll  &  dev-h-defUnpack Liste nicht noch um ein paar Einträge erweitern möchte,
dann bliebe bei dir nur noch reading pro Register übrig :)

Maintainer der Module: MAX, MPD, UbiquitiMP, UbiquitiOut, SIP, BEOK, readingsWatcher

ahermann86

Danke für den Tip.
Ich habe die Liste in der 98_Modbus.pm um die Einträge erweitert:

Zeile 1471 in 98_Modbus.pm:
        "dev-type-[A-Za-z0-9_]+-hint " .
        "dev-type-[A-Za-z0-9_]+-set " .


Dann sieht meine Definition in der Fhem.cfg wie folgt aus:

define Modbus_Z2 Modbus /dev/serial/by-path/pci-0000:00:13.0-usb-0:2:1.0-port0@9600

define Mod_Relay ModbusAttr 2 30

attr Mod_Relay IODev Modbus_Z2
attr Mod_Relay dev-type-tRelay-bswapRegs 1
attr Mod_Relay dev-type-tRelay-hint on,off
attr Mod_Relay dev-type-tRelay-map 1:on, 2:off
attr Mod_Relay dev-type-tRelay-set 1

attr Mod_Relay obj-h1-reading R1
attr Mod_Relay obj-h1-type tRelay
attr Mod_Relay obj-h2-reading R2
attr Mod_Relay obj-h2-type tRelay
attr Mod_Relay obj-h3-reading R3
attr Mod_Relay obj-h3-type tRelay
attr Mod_Relay obj-h4-reading R4
attr Mod_Relay obj-h4-type tRelay
attr Mod_Relay obj-h5-reading R5
attr Mod_Relay obj-h5-type tRelay
attr Mod_Relay obj-h6-reading R6
attr Mod_Relay obj-h6-type tRelay
attr Mod_Relay obj-h7-reading R7
attr Mod_Relay obj-h7-type tRelay
attr Mod_Relay obj-h8-reading R8
attr Mod_Relay obj-h8-type tRelay

Ich werde das mal an den Verfasser der 98_Modbus.pm weitergeben.

Vielen Dank

Wzut

das ist aber nicht ganz das was ich meinte :) , aber rede trotzdem mit dem Autor, er wird schon am Besten wissen wie er sein Modul verbiegen muss.
Maintainer der Module: MAX, MPD, UbiquitiMP, UbiquitiOut, SIP, BEOK, readingsWatcher

StefanStrobel

Hallo,

die Änderung war tatsächlich minimal und sollte nichts schaden. Daher habe ich beide Änderungen eingebaut
(sowohl die Erweiterung bei den Types, als auch dev-x-defSet und dev-x-defHint)

siehe https://forum.fhem.de/index.php/topic,75638.210.html

Gruss
   Stefan

Klinki

Hallo Forum,

Ich nutze das ModbusAttr-Modul schon seit einiger Zeit um Holding Register von meinen Stromzählern auszulesen. Das funktioniert auch prima.

Die Aufgabe des Tages ist das Lesen von Coils einer Siemens Logo. Diese lässt sich per ModBusMaster PC-Tool auf Coil-Adresse 884 auslesen. Nur per Fhem kriege ich das nicht hin.

attr Modbus_LogoWaschmaschinen obj-c884-reading test9
attr Modbus_LogoWaschmaschinen obj-c884-len 1
attr Modbus_LogoWaschmaschinen obj-c884-unpack b>

Im verbose-Log scheint die Anforderung auch gar nicht aufzutauchen:

2022.06.13 11:47:49.652 4: Modbus_LogoWaschmaschinen: UpdateTimer called from GetUpdate with cmd next sets timer to call update function in 60.0 sec at 11:48:49.652, interval 60
2022.06.13 11:47:49.653 5: Modbus_LogoWaschmaschinen: CreateUpdateHash full object list: c1 c110 c111 c112 c113 c114 c370 c880 c881 c882 c883 c884 d111
2022.06.13 11:47:49.655 4: Modbus_LogoWaschmaschinen: CombineUpdateHash objHash keys before combine:
2022.06.13 11:47:49.656 5: Modbus_LogoWaschmaschinen: CombineUpdateHash tries to combine read commands
2022.06.13 11:47:49.656 5: Modbus_LogoWaschmaschinen: CombineUpdateHash keys are now
2022.06.13 11:47:49.657 4: Modbus_LogoWaschmaschinen: GetUpdate will now create requests for


Was mache ich denn hier falsch? Letzen Endes will ich nur einzelne Coils auslesen.

Gruß,
klinki

StefanStrobel

Fehlt da ein
obj-c884-poll 1
oder
dev-c-defPoll 1

Gruß
    Stefan

Klinki

oh je, bin ich dumm.... Wald, Bäume, usw.

Klar, logisch! Dann führt er auch die richtige Modbus-Funktion aus.

Ich danke Dir!

Gruß,
Klinki

PS: Das Modul gefällt mir ausnahmslos gut - auch wenn es eine gewisse Lernkurve gab