Skip to content

Commit

Permalink
Fix for NewGroupAddr2 #82
Browse files Browse the repository at this point in the history
  • Loading branch information
mobilarte committed Apr 4, 2024
1 parent c32596d commit a683fb7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions knx/cemi/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ func NewGroupAddr3(a, b, c uint8) GroupAddr {
return GroupAddr(a&0x1F)<<11 | GroupAddr(b&0x7)<<8 | GroupAddr(c)
}

// NewGroupAddr2 generates a group address from and "a/b"
// NewGroupAddr2 generates a group address from an "a/b"
// representation, where a is the Main Group [0..31] and b is
// the Sub Group [0..2047].
func NewGroupAddr2(a uint8, b uint16) GroupAddr {
return GroupAddr(a)<<8 | GroupAddr(b&0x7FF)
return GroupAddr(a&0x1F)<<11 | GroupAddr(b&0x7FF)
}

// NewGroupAddrString parses the given string to a group address.
Expand Down
3 changes: 2 additions & 1 deletion knx/cemi/address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ func Test_GroupAddresses(t *testing.T) {
var addrs = []Addr{
{"1/2/3", true, "1/2/3"},
{"31/7/255", true, "31/7/255"},
{"31/2040", true, "3/7/248"},
{"31/2040", true, "31/7/248"},
{"31/2047", true, "31/7/255"},
{"65535", true, "31/7/255"},
{"82/8/260", false, ""},
{"84/230", false, ""},
Expand Down

0 comments on commit a683fb7

Please sign in to comment.