Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

km271.pl does not parse the value 0x02 correctly #56

Open
rhabacker opened this issue Apr 17, 2022 · 1 comment
Open

km271.pl does not parse the value 0x02 correctly #56

rhabacker opened this issue Apr 17, 2022 · 1 comment

Comments

@rhabacker
Copy link

I am using https://github.com/mhop/fhem-mirror/blob/master/fhem/contrib/km271.pl to extract log data from a Buderus Logamatic 2107 and have discovered an error in the log data parser when a value is received as 0x02 as shown in the following example:

The data stream received from the device for the key Betriebswerte_1_HK1 4.

2022-04-17_05:47:24.891 DEV 02
2022-04-17_05:47:24.902 DEV 80  
2022-04-17_05:47:24.906 DEV 00   
2022-04-17_05:47:24.910 DEV 04
2022-04-17_05:47:24.913 DEV 10
2022-04-17_05:47:24.917 DEV 03
2022-04-17_05:47:24.922 DEV 97

is parsed correctly as

2022-04-17_05:47:24.923 Betriebswerte_1_HK1 4

The data stream received for the key Betriebswerte_2_HK1 2.

2022-04-17_05:47:25.139 DEV 02
2022-04-17_05:47:25.147 DEV 80
2022-04-17_05:47:25.153 DEV 01
2022-04-17_05:47:25.156 DEV 02
2022-04-17_05:47:25.160 DEV 10
2022-04-17_05:47:25.164 DEV 03
2022-04-17_05:47:25.169 DEV 90

results in

Wrong CRC in 100390 (90 vs. 13)

which is not correct.

The reason for this problem is that parsing the second '02' value deletes all previously added data in $tbuf at

$tbuf = "";
.

@rhabacker
Copy link
Author

For a related patch to fix this issue see below:

From 180b85f5e9db45e62b1a29d0078d7bd051188ec3 Mon Sep 17 00:00:00 2001
From: Ralf Habacker <[email protected]>
Date: Fri, 8 Jul 2022 21:57:15 +0000
Subject: [PATCH] Fix not parsing the value 0x02 correctly

https://github.com/mhop/fhem-mirror/issues/56
---
 km271.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/km271.pl b/km271.pl
index 5bbcfae..88b707a 100644
--- a/km271.pl
+++ b/km271.pl
@@ -134,7 +134,7 @@ for(;;) {
 
     $buf = unpack('H*', $buf);
     #printf("%s DEV %s\n", fmt_now(), $buf);
-    if($buf eq "02") {
+    if($buf eq "02" && $tbuf eq "") {
       $tbuf = "";
       $po->write($dle);
       next;
-- 
2.11.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant