Setting/getting values in a Structure containing multiple c_bool bitfields like:
_fields_ = [
('one', c_bool, 1),
('two', c_bool, 1),
]
results in an unexpected behavior.
Setting any one of these fields to `True` results in ALL of these fields being set to `True` (i.e.: setting `struct.one` to `True` causes both `struct.one` as well as `struct.two` to be set to `True`.
This also results in the binary representation of the struct to be incorrect. The only possible outcomes for `bytes(struct)` are `b'\x00` and `b'\x01'`
Expected behavior should be that when setting `struct.one` only sets the desired field.
This is achievable when defining the same Structure with `c_byte` rather than `c_bool`.
When defining the struct like:
_fields_ = [
('one', c_byte, 1),
('two', c_byte, 1),
]
setting `struct.one` only affects `struct.one` and not `struct.two`.
The binary representation of the structure is also correct. When setting `struct.two` to `True`, `bytes(struct)` returns `b'\x02'` (aka. 0b10).
I've attached a Minimal Runnable Example that hopefully helps outline the issue.
|