buttonGroupMembership
is stored in config bank:3 index:0x01 4 high bits
buttonActiveGroup
is stored in config bank:3 index:0x1d
Historically, buttonGroupMembership
was first. It was replaced later
by 8-bit buttonActiveGroup
,
but buttonActiveGroup
is not persistenly stored by old terminal blocks.
Both config bytes are being updated in dsm by dsm-api call
DeviceProperties_set_button_active_group
.
So, for groups < 16, they are usually in sync.
But buttonGroupMembership
shares the config register with buttonId
.
When dss needs to update buttonId
, it uses its own cached copy
of buttonGroupMembership
to create config bank:3 index:0x01 value.
This leads to race conditions, because the cache may be outdated.
In fact, the buttonGroupMembership
cached copy in dss was updated
only on an config event from dsm or in device readout in BusScanner.
This makes the race window quite big.
We remove buttonGroupMembership
field as it does not carry
any additional information.
We use buttonActiveGroup
that is synchronously updated
from when calling DeviceProperties_set_button_active_group
.
The race condition still exists. E.g. when setDeviceButtonId is called during device readout. But it is much harder to trigger now. To fully remove the race condition, we must either
- store only 0 for
buttonGroupMembership
in config bank:3 index:0x01 - combine button group and button id only in dsm, never in dss.
That require to introduce and use new dsm-api method
DeviceProperties_set_button_id
and use it instead ofDeviceConfig_set_sync
ref #17170