[gelöst] Modbus Feld unpack

Begonnen von ch.eick, 08 April 2020, 12:45:07

Vorheriges Thema - Nächstes Thema

ch.eick

Hallo zusammen,
ich habe dieses Problemchen mal hierher ausgelagert.

Es geht darum einen Wert mit unpack in den tatsaechlichen Wert zum Anzeigen umzuwandeln. Generell gelingt mir das bereits recht gut, jedoch bei diesem Wert verzweifle ich etwas.

Mit folgenden Werten gibt es da auch ein Problem. In der Doku steht bei allen "0x8000"als Value Range.

Hier sollte die Summe der Stroeme 2.87+5.63+5.11 stehen
M_AC_Current [b]327.68[/b]   <<< 13.61 waere richtig

Hier musste eigentlich ca 380 Volt stehen
M_AC_Voltage_AB 327.68
M_AC_Voltage_BC 327.68
M_AC_Voltage_CA 327.68
M_AC_Voltage_LL 327.68
M_AC_Voltage_LN 327.68


Hier eine korrekte Umwandlung

2020.04.07 16:01:35.526 4: PV_KSEM: ProcessRequestQueue (V4.1.5 - 17.9.2019) qlen 28, sending 00b80000000601039c8a0001 request: id 1, fCode 3, tid 184, type h, adr 40074, len 1 for device PV_KSEM reading M_AC_Current_C (getUpdate), queued 1.79 secs ago, read buffer empty
2020.04.07 16:01:35.526 5: SW: 00b80000000601039c8a0001
2020.04.07 16:01:35.528 5: PV_KSEM: StartQueueTimer called form ProcessRequestQueue sets internal timer to call Modbus_ProcessRequestQueue in 1.000 seconds

2020.04.07 16:01:35.529 5: PV_KSEM: read buffer: 00 b800 0000 0501 0302 021d    <<< Die Leerzeichen habe ich fuer die Lesbarkeit eingefuegt

2020.04.07 16:01:35.529 4: PV_KSEM: ParseFrameStart (TCP) extracted id 1, fCode 3, tid 184, dlen 5 and data 02021d
2020.04.07 16:01:35.529 5: PV_KSEM: HandleResponse called from Read
2020.04.07 16:01:35.529 5: PV_KSEM: ParseResponse called from HandleResponse
2020.04.07 16:01:35.529 5: PV_KSEM: HandleResponse now passing to logical device PV_KSEM for parsing data

2020.04.07 16:01:35.529 5: PV_KSEM: ParseObj called with data 021d, type h, adr 40074, valuesLen 1, op read

2020.04.07 16:01:35.530 5: PV_KSEM: ParseObj ObjInfo for h40074: reading=M_AC_Current_C, unpack=n, expr=$val * (10 ** ReadingsNum("$name" ,"M_AC_Current_SF",0)), format=%.2f, map=
2020.04.07 16:01:35.530 5: PV_KSEM: ParseObj unpacked 021d with n to 541 hex 353431
2020.04.07 16:01:35.530 5: PV_KSEM: CheckEval for ParseObj evaluates expr for M_AC_Current_C, val=541, expr=$val * (10 ** ReadingsNum("$name" ,"M_AC_Current_SF",0))
2020.04.07 16:01:35.530 5: PV_KSEM: CheckEval for ParseObj result is 5.41
2020.04.07 16:01:35.530 5: PV_KSEM: ParseObj for M_AC_Current_C does sprintf with format %.2f, value is 5.41
2020.04.07 16:01:35.531 5: PV_KSEM: ParseObj for M_AC_Current_C sprintf result is 5.41
2020.04.07 16:01:35.531 4: PV_KSEM: ParseObj assigns value 5.41 to M_AC_Current_C
2020.04.07 16:01:35.542 5: PV_KSEM: HandleResponse got 1 readings from ParseObj for PV_KSEM



2020.04.07 16:01:37.366 4: PV_KSEM: ProcessRequestQueue (V4.1.5 - 17.9.2019) qlen 11, sending 001d0000000601039c870001 request: id 1, fCode 3, tid 29, type h, adr 40071, len 1 for device PV_KSEM reading M_AC_Current (getUpdate), queued 3.61 secs ago, read buffer empty
2020.04.07 16:01:37.366 5: SW: 001d0000000601039c870001
2020.04.07 16:01:37.368 5: PV_KSEM: StartQueueTimer called form ProcessRequestQueue sets internal timer to call Modbus_ProcessRequestQueue in 1.000 seconds

2020.04.07 16:01:37.369 5: PV_KSEM: read buffer: 00 1d00 0000 0501 0302 8000    <<< Die Leerzeichen habe ich fuer die Lesbarkeit eingefuegt. Hier taucht diese 0x8000 aus der Tabelle auf???

2020.04.07 16:01:37.369 4: PV_KSEM: ParseFrameStart (TCP) extracted id 1, fCode 3, tid 29, dlen 5 and data 028000
2020.04.07 16:01:37.369 5: PV_KSEM: HandleResponse called from Read
2020.04.07 16:01:37.369 5: PV_KSEM: ParseResponse called from HandleResponse
2020.04.07 16:01:37.369 5: PV_KSEM: HandleResponse now passing to logical device PV_KSEM for parsing data

2020.04.07 16:01:37.369 5: PV_KSEM: ParseObj called with data 8000, type h, adr 40071, valuesLen 1, op read

2020.04.07 16:01:37.370 5: PV_KSEM: ParseObj ObjInfo for h40071: reading=M_AC_Current, unpack=n, expr=$val * (10 ** ReadingsNum("$name" ,"M_AC_Current_SF",0)), format=%.2f, map=
2020.04.07 16:01:37.370 5: PV_KSEM: ParseObj unpacked 8000 with n to 32768 hex 3332373638
2020.04.07 16:01:37.370 5: PV_KSEM: CheckEval for ParseObj evaluates expr for M_AC_Current, val=32768, expr=$val * (10 ** ReadingsNum("$name" ,"M_AC_Current_SF",0))
2020.04.07 16:01:37.370 5: PV_KSEM: CheckEval for ParseObj result is 327.68
2020.04.07 16:01:37.370 5: PV_KSEM: ParseObj for M_AC_Current does sprintf with format %.2f, value is 327.68
2020.04.07 16:01:37.370 5: PV_KSEM: ParseObj for M_AC_Current sprintf result is 327.68
2020.04.07 16:01:37.370 4: PV_KSEM: ParseObj assigns value 327.68 to M_AC_Current


Und hier noch die Definition im Device

attr PV_KSEM dev-type-INT16-len 1
attr PV_KSEM dev-type-INT16-unpack s>

attr PV_KSEM dev-type-INT16_Current-expr $val * (10 ** ReadingsNum("$name" ,"M_AC_Current_SF",0))
attr PV_KSEM dev-type-INT16_Current-format %.2f
attr PV_KSEM dev-type-INT16_Current-len 1
attr PV_KSEM dev-type-INT16_Current-unpack n     <<<< Hier habe ich auch schon andere Werte versucht

attr PV_KSEM obj-h40071-reading M_AC_Current         <<<< Dieser Wert wird falsch angezeigt
attr PV_KSEM obj-h40071-type INT16_Current

attr PV_KSEM obj-h40072-reading M_AC_Current_A    <<<< Das passt
attr PV_KSEM obj-h40072-type INT16_Current

attr PV_KSEM obj-h40073-reading M_AC_Current_B    <<<< Das passt
attr PV_KSEM obj-h40073-type INT16_Current

attr PV_KSEM obj-h40074-reading M_AC_Current_C    <<<< Das passt
attr PV_KSEM obj-h40074-type INT16_Current

attr PV_KSEM obj-h40075-reading M_AC_Current_SF    <<<< Das passt auch und wird fuer das Komma setzen verwendet
attr PV_KSEM obj-h40075-type INT16


Im Anhang habe ich die Tabelle aus der Doku angehaengt, jedoch verstehe ich die letzte Spalte nicht richtig, denn da ist der Unterschied zu den anderen werten.

Viele Gruess
     Christian
RPI4; Docker; CUNX; Eltako FSB61NP; SamsungTV H-Serie; Sonos; Vallox; Luxtronik; 3x FB7490; Stromzähler mit DvLIR; wunderground; Plenticore 10 mit BYD; EM410; SMAEM; Modbus TCP
Contrib: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/ch.eick

ch.eick

Hmm, na wo sind denn die Bitfiselei Kenner?
Kann mir den keiner nen Tip geben?
Wo ist der beste Weblink?

Gruss
      Christian
RPI4; Docker; CUNX; Eltako FSB61NP; SamsungTV H-Serie; Sonos; Vallox; Luxtronik; 3x FB7490; Stromzähler mit DvLIR; wunderground; Plenticore 10 mit BYD; EM410; SMAEM; Modbus TCP
Contrib: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/ch.eick

Shadow3561

Moin,
ich lese meinen Fronius WR per modbus aus und dort muss ich vom Register immer 1 abziehen.

h40071 ist dann in fhem als h40070 angegeben.
mfg

edit: versuch es mal mit unpack      => "f>"

pcbastler

was liefert denn der simplymodbus-Client (hab ich sch ein paar mal verlinkt)?

ch.eick

Moin, die Register passen, da ja auch alle anderen passen. Es geht wohl um die Zusatzinfo mit dem Hex 8000.
F> hatte ich auch schon, aber ich versuch's nochmal.

Gesendet von meinem SM-G930F mit Tapatalk

RPI4; Docker; CUNX; Eltako FSB61NP; SamsungTV H-Serie; Sonos; Vallox; Luxtronik; 3x FB7490; Stromzähler mit DvLIR; wunderground; Plenticore 10 mit BYD; EM410; SMAEM; Modbus TCP
Contrib: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/ch.eick

ch.eick

Also, die Aenderung auf f> hat nichts gebracht


attr PV_KSEM obj-h40071-reading M_AC_Current
attr PV_KSEM obj-h40071-type INT16_Current
attr PV_KSEM obj-h40071-unpack f>



M_AC_Current -327.68
M_AC_Current_A 5.14
M_AC_Current_B 6.87
M_AC_Current_C 6.33
M_AC_Current_SF -2


Kann der "simplymodbus-Client" die gepackten Felder selber analysieren? Ich hatte ja mit verbose 5 bereits einen Trace zu begin beigefuegt, bei dem man die Register auch im Hex Code sehen kann.

Gruss
    Christian
RPI4; Docker; CUNX; Eltako FSB61NP; SamsungTV H-Serie; Sonos; Vallox; Luxtronik; 3x FB7490; Stromzähler mit DvLIR; wunderground; Plenticore 10 mit BYD; EM410; SMAEM; Modbus TCP
Contrib: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/ch.eick

ch.eick

Moin, leider ist das Thema noch nicht geloest und wurde hier auch erwaehnt,
RPI4; Docker; CUNX; Eltako FSB61NP; SamsungTV H-Serie; Sonos; Vallox; Luxtronik; 3x FB7490; Stromzähler mit DvLIR; wunderground; Plenticore 10 mit BYD; EM410; SMAEM; Modbus TCP
Contrib: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/ch.eick

ch.eick

RPI4; Docker; CUNX; Eltako FSB61NP; SamsungTV H-Serie; Sonos; Vallox; Luxtronik; 3x FB7490; Stromzähler mit DvLIR; wunderground; Plenticore 10 mit BYD; EM410; SMAEM; Modbus TCP
Contrib: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/ch.eick