Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Sending Wrong Values on Failed Conversion to DPT #300

Conversation

cornelius-koepp
Copy link
Contributor

@cornelius-koepp cornelius-koepp commented Nov 6, 2024

This is an Upstream-Fix from OpenKNX. Marked as draft as long review is pending.
Description below is a copy of OpenKNX#30

Limitation (for redesign on devel): This fix will not work with current implementation. See separate PR #301


Issue

Setting a value which cannot be converted to the given DPT did result in unexpected behaviour.

  • valueNoSendCompare/valueCompare resulted in value 0 (and returned change based on this value)
  • valueNoSend updated state from unitialized to OK, without updating the value
  • value wrote to GA without setting the KO value

Reproduce

For all cases use a value/type combination which results in KNX_Encode_Value return false.

Example: value 500 with type DPT_Value_1_Ucount, or any other

Note: DPT1 will not fail; ignoring all other bits.

  • valueNoSendCompare/valueCompare: did always set value to 0 (no special preconditions needed beside conversion fail)
  • valueNoSend: use before any other change of KO. No change in value expected, but read requests will answered (with undefined value)
  • value use before any other change of KO. Will result in write telegram (with other value included)

Fix

Suppress updating, status-update and sending for invalid values.

To Discuss

The fix does not change the public interface for changing/writing KO values, so there will be no feedback if conversion fails. Current methods return type void could be changed to bool to indicate success, without breaking.

@thelsing
Copy link
Owner

thelsing commented Nov 8, 2024

Changing the void methods to bool to signal success seems like a good idea for me. A stable API is not that important. Constant improvement of the code is :-)

@cornelius-koepp
Copy link
Contributor Author

cornelius-koepp commented Nov 8, 2024

Changing the void methods to bool to signal success seems like a good idea for me.

I'll prepare a draft.

See #301 for modified PR for devel.

…ersion to DPT

Remove _valueNoSend(..) as valueNoSend(..) is now the same
…object-setting-invalid-value--thelsing/master

# Conflicts:
#	src/knx/group_object.h
@thelsing
Copy link
Owner

Do you still want to change something or can I merge this? (PR is still draft)

@cornelius-koepp
Copy link
Contributor Author

Do you still want to change something or can I merge this?

No need of changes anymore.

Note: Testing was only conducted in Upstream/OpenKNX-Environment.

@cornelius-koepp cornelius-koepp marked this pull request as ready for review November 18, 2024 18:40
@thelsing thelsing merged commit 940f2df into thelsing:master Nov 19, 2024
7 checks passed
@thelsing
Copy link
Owner

Merged. Thanks for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants