From a16d763fac16767718ec242d9fe09ca4a93debd4 Mon Sep 17 00:00:00 2001 From: rybancr <121522039+rybancr@users.noreply.github.com> Date: Tue, 27 Dec 2022 19:05:10 -0700 Subject: [PATCH 1/5] Full 8 digit consumption, nouse, leak fields Decreased NoUse and Leak to 3 bits. Leak contained the LSB of the consumption high bits field. Removed Unkn3. Extended consumption to use the two consumption high bits located in Unkn3 and one from leak to allow for full 8 digit reads. 24 bits allow a consumption up to 16,777,215 before prematurely rolling over. --- r900/r900.go | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/r900/r900.go b/r900/r900.go index 5a5ee1331..f7cce47f3 100644 --- a/r900/r900.go +++ b/r900/r900.go @@ -226,12 +226,11 @@ func (p *Parser) Parse(pkts []protocol.Data, msgCh chan protocol.Message, wg *sy } id, _ := strconv.ParseUint(bits[:32], 2, 32) - unkn1, _ := strconv.ParseUint(bits[32:40], 2, 8) - nouse, _ := strconv.ParseUint(bits[40:46], 2, 6) + unkn1, _ := strconv.ParseUint(bits[32:43], 2, 11) + nouse, _ := strconv.ParseUint(bits[43:46], 2, 3) backflow, _ := strconv.ParseUint(bits[46:48], 2, 2) - consumption, _ := strconv.ParseUint(bits[48:72], 2, 24) - unkn3, _ := strconv.ParseUint(bits[72:74], 2, 2) - leak, _ := strconv.ParseUint(bits[74:78], 2, 4) + consumption, _ := strconv.ParseUint(bits[72:75] + bits[48:72], 2, 27) + leak, _ := strconv.ParseUint(bits[75:78], 2, 3) leaknow, _ := strconv.ParseUint(bits[78:80], 2, 2) var r900 R900 @@ -241,7 +240,6 @@ func (p *Parser) Parse(pkts []protocol.Data, msgCh chan protocol.Message, wg *sy r900.NoUse = uint8(nouse) r900.BackFlow = uint8(backflow) r900.Consumption = uint32(consumption) - r900.Unkn3 = uint8(unkn3) r900.Leak = uint8(leak) r900.LeakNow = uint8(leaknow) copy(r900.checksum[:], symbols[16:]) @@ -254,12 +252,11 @@ func (p *Parser) Parse(pkts []protocol.Data, msgCh chan protocol.Message, wg *sy type R900 struct { ID uint32 `xml:",attr"` // 32 bits - Unkn1 uint8 `xml:",attr"` // 8 bits - NoUse uint8 `xml:",attr"` // 6 bits, day bins of no use + Unkn1 uint8 `xml:",attr"` // 11 bits + NoUse uint8 `xml:",attr"` // 3 bits, day bins of no use BackFlow uint8 `xml:",attr"` // 2 bits, backflow past 35d hi/lo - Consumption uint32 `xml:",attr"` // 24 bits - Unkn3 uint8 `xml:",attr"` // 2 bits - Leak uint8 `xml:",attr"` // 4 bits, day bins of leak + Consumption uint32 `xml:",attr"` // 27 bits + Leak uint8 `xml:",attr"` // 3 bits, day bins of leak LeakNow uint8 `xml:",attr"` // 2 bits, leak past 24h hi/lo checksum [5]byte } @@ -281,13 +278,12 @@ func (r900 R900) Checksum() []byte { } func (r900 R900) String() string { - return fmt.Sprintf("{ID:%10d Unkn1:0x%02X NoUse:%2d BackFlow:%1d Consumption:%8d Unkn3:0x%02X Leak:%2d LeakNow:%1d}", + return fmt.Sprintf("{ID:%10d Unkn1:0x%02X NoUse:%2d BackFlow:%1d Consumption:%8d Leak:%2d LeakNow:%1d}", r900.ID, r900.Unkn1, r900.NoUse, r900.BackFlow, r900.Consumption, - r900.Unkn3, r900.Leak, r900.LeakNow, ) @@ -299,7 +295,6 @@ func (r900 R900) Record() (r []string) { r = append(r, strconv.FormatUint(uint64(r900.NoUse), 10)) r = append(r, strconv.FormatUint(uint64(r900.BackFlow), 10)) r = append(r, strconv.FormatUint(uint64(r900.Consumption), 10)) - r = append(r, strconv.FormatUint(uint64(r900.Unkn3), 10)) r = append(r, strconv.FormatUint(uint64(r900.Leak), 10)) r = append(r, strconv.FormatUint(uint64(r900.LeakNow), 10)) From 3cbae43637b5f37ef79d6ee878c87f9e5a4f6e09 Mon Sep 17 00:00:00 2001 From: rybancr <121522039+rybancr@users.noreply.github.com> Date: Tue, 27 Dec 2022 23:03:41 -0700 Subject: [PATCH 2/5] Add MeterType --- r900/r900.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/r900/r900.go b/r900/r900.go index f7cce47f3..aee58e790 100644 --- a/r900/r900.go +++ b/r900/r900.go @@ -226,7 +226,9 @@ func (p *Parser) Parse(pkts []protocol.Data, msgCh chan protocol.Message, wg *sy } id, _ := strconv.ParseUint(bits[:32], 2, 32) - unkn1, _ := strconv.ParseUint(bits[32:43], 2, 11) + unkn1, _ := strconv.ParseUint(bits[32:36], 2, 4) + metertype, _ := strconv.ParseUint(bits[36:40], 2, 4) + unkn2, _ := strconv.ParseUint(bits[40:43], 2, 3) nouse, _ := strconv.ParseUint(bits[43:46], 2, 3) backflow, _ := strconv.ParseUint(bits[46:48], 2, 2) consumption, _ := strconv.ParseUint(bits[72:75] + bits[48:72], 2, 27) @@ -237,6 +239,8 @@ func (p *Parser) Parse(pkts []protocol.Data, msgCh chan protocol.Message, wg *sy r900.ID = uint32(id) r900.Unkn1 = uint8(unkn1) + r900.AmrType = uint8(metertype) + r900.Unkn2 = uint8(unkn2) r900.NoUse = uint8(nouse) r900.BackFlow = uint8(backflow) r900.Consumption = uint32(consumption) @@ -252,7 +256,9 @@ func (p *Parser) Parse(pkts []protocol.Data, msgCh chan protocol.Message, wg *sy type R900 struct { ID uint32 `xml:",attr"` // 32 bits - Unkn1 uint8 `xml:",attr"` // 11 bits + Unkn1 uint8 `xml:",attr"` // 4 bits + AmrType uint8 `xml:",attr"` // 4 bits + Unkn2 uint8 `xml:",attr"` // 3 bits NoUse uint8 `xml:",attr"` // 3 bits, day bins of no use BackFlow uint8 `xml:",attr"` // 2 bits, backflow past 35d hi/lo Consumption uint32 `xml:",attr"` // 27 bits @@ -270,7 +276,7 @@ func (r900 R900) MeterID() uint32 { } func (r900 R900) MeterType() uint8 { - return r900.Unkn1 + return r900.AmrType } func (r900 R900) Checksum() []byte { @@ -278,9 +284,11 @@ func (r900 R900) Checksum() []byte { } func (r900 R900) String() string { - return fmt.Sprintf("{ID:%10d Unkn1:0x%02X NoUse:%2d BackFlow:%1d Consumption:%8d Leak:%2d LeakNow:%1d}", + return fmt.Sprintf("{ID:%10d Unkn1:0x%02X MeterType:%02d Unkn2:0x%02X NoUse:%2d BackFlow:%1d Consumption:%8d Leak:%2d LeakNow:%1d}", r900.ID, r900.Unkn1, + r900.AmrType, + r900.Unkn2, r900.NoUse, r900.BackFlow, r900.Consumption, @@ -292,6 +300,8 @@ func (r900 R900) String() string { func (r900 R900) Record() (r []string) { r = append(r, strconv.FormatUint(uint64(r900.ID), 10)) r = append(r, strconv.FormatUint(uint64(r900.Unkn1), 10)) + r = append(r, strconv.FormatUint(uint64(r900.AmrType), 10)) + r = append(r, strconv.FormatUint(uint64(r900.Unkn2), 10)) r = append(r, strconv.FormatUint(uint64(r900.NoUse), 10)) r = append(r, strconv.FormatUint(uint64(r900.BackFlow), 10)) r = append(r, strconv.FormatUint(uint64(r900.Consumption), 10)) From 301370df206c2699f7075bd3d4185bf804a0df01 Mon Sep 17 00:00:00 2001 From: rybancr <121522039+rybancr@users.noreply.github.com> Date: Sat, 31 Dec 2022 09:44:41 -0700 Subject: [PATCH 3/5] Update r900.go --- r900/r900.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r900/r900.go b/r900/r900.go index aee58e790..f40155bd7 100644 --- a/r900/r900.go +++ b/r900/r900.go @@ -257,7 +257,7 @@ func (p *Parser) Parse(pkts []protocol.Data, msgCh chan protocol.Message, wg *sy type R900 struct { ID uint32 `xml:",attr"` // 32 bits Unkn1 uint8 `xml:",attr"` // 4 bits - AmrType uint8 `xml:",attr"` // 4 bits + AmrType uint8 `xml:",attr"` // 4 bits Unkn2 uint8 `xml:",attr"` // 3 bits NoUse uint8 `xml:",attr"` // 3 bits, day bins of no use BackFlow uint8 `xml:",attr"` // 2 bits, backflow past 35d hi/lo From 020981b82b5207b517b3220806b2ac0f5b88009a Mon Sep 17 00:00:00 2001 From: rybancr <121522039+rybancr@users.noreply.github.com> Date: Sat, 31 Dec 2022 13:32:09 -0700 Subject: [PATCH 4/5] Update r900.go --- r900/r900.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r900/r900.go b/r900/r900.go index f40155bd7..4286fda77 100644 --- a/r900/r900.go +++ b/r900/r900.go @@ -284,7 +284,7 @@ func (r900 R900) Checksum() []byte { } func (r900 R900) String() string { - return fmt.Sprintf("{ID:%10d Unkn1:0x%02X MeterType:%02d Unkn2:0x%02X NoUse:%2d BackFlow:%1d Consumption:%8d Leak:%2d LeakNow:%1d}", + return fmt.Sprintf("{ID:%10d Unkn1:0x%1X MeterType:%02d Unkn2:0x%1X NoUse:%1d BackFlow:%1d Consumption:%8d Leak:%1d LeakNow:%1d}", r900.ID, r900.Unkn1, r900.AmrType, From 45f1c03f6261554850b6a2fa49d44b36bc2fc5e5 Mon Sep 17 00:00:00 2001 From: rybancr <121522039+rybancr@users.noreply.github.com> Date: Tue, 19 Nov 2024 19:25:39 -0700 Subject: [PATCH 5/5] Update go.mod --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 61f015107..d3f51b02a 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/bemasher/rtlamr +module github.com/rybancr/rtlamr go 1.12