SML: support for byte stuffing for Kamstrup devices #16893
Replies: 3 comments 5 replies
-
@JanSchmidt3 Nice extension. Please edit this file by clicking the little pen in the upper right corner, "Propose changes" and "Create pull request" - done. Also, just my thoughts, "byte stuffing" could be made the default for Kamstrup protocol (spare the extra k in the meter definition)... currently the only protocol where it's meaningful. |
Beta Was this translation helpful? Give feedback.
-
Hi @JanSchmidt3, I have a multical 21, but still can not read out the values. How did you do it? Do you have some blog or detailed explanation? Thanks a lot. |
Beta Was this translation helpful? Give feedback.
-
Hello, |
Beta Was this translation helpful? Give feedback.
-
Kamstrup devices (i.e. water meter, heat meter) use a byte stuff algorithm, whith cannot be handelt be SML raw decoder. So I created a patch to xsns_53_sml.ino as followes
The principle is to add a "stuff type" (I used 'k' for Kamstrup) before the data type (the example can be used for Kamstrup multical 21 water meter):
>D
>B
->sensor53 r
>M 1
+1,3,rN2,0,1200,WASSER,1,20,803F1007004403EC0063004A00F30124012BE2C30D
1,0044280443kUUuuUUuu@1000,Verbrauch,m³,volume,19
1,004A290200kUUuu@1,flow,l/h,flow,20
1,03EC330400kUUuuUUuu@1,hours,h,hours,0
1,0124250100kuu@1,water temp,°C,watertemp,0
1,012b250100kuu@1,meter temp,°C,metertemp,0
#
If the decoder finds that 'k', the following information will be destuffed before decoding. I modified only the datatypes which are used by kamstrup devices.
This patch works for me, I compiled the project with gitpod, but cannot create a pull request. Maybe someone with proper rights can patch the code and update the docu.
Jan
diff --git a/tasmota/tasmota_xsns_sensor/xsns_53_sml.ino b/tasmota/tasmota_xsns_sensor/xsns_53_sml.ino index c3a9a9743..214435066 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_53_sml.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_53_sml.ino @@ -1777,12 +1777,27 @@ char *skip_double(char *cp) { return 0; }- uint8_t retval = *(*cp + index);
- if (typ == 'k')
- {
- if (*(*cp + index) == 0x1b)
- {
-
-
- }
- }
- return retval;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+uint8_t byte_destuff (uint8_t typ, uint8_t **cp, uint8_t index)
+{
+}
void SML_Decode(uint8_t index) {
const char mp=(const char)meter_p;
int8_t mindex;
uint8_t *cp;
uint8_t dindex = 0, vindex = 0;
uint8_t destuff_typ = ' ';
delay(0);
while (mp != NULL) {
@@ -1973,8 +1988,15 @@ void SML_Decode(uint8_t index) {
cp += skip;
}
}
@@ -1996,7 +2018,9 @@ void SML_Decode(uint8_t index) {
ebus_dval = val;
mbus_dval = val;
} else if (!strncmp(mp, "UUuu", 4)) {
@@ -2030,7 +2054,9 @@ void SML_Decode(uint8_t index) {
mp += 4;
cp += 2;
} else if (!strncmp(mp, "uu", 2)) {
Beta Was this translation helpful? Give feedback.
All reactions