Skip to content

fix(axparameter): clarify parameter name format for axparameter API#441

Closed
lucky-rydar wants to merge 1 commit into
AxisCommunications:mainfrom
lucky-rydar:bugfix/lucky-rydar/axparameter-fix-inconsistency-in-api-usage
Closed

fix(axparameter): clarify parameter name format for axparameter API#441
lucky-rydar wants to merge 1 commit into
AxisCommunications:mainfrom
lucky-rydar:bugfix/lucky-rydar/axparameter-fix-inconsistency-in-api-usage

Conversation

@lucky-rydar

@lucky-rydar lucky-rydar commented Dec 13, 2025

Copy link
Copy Markdown
Contributor

Describe your changes

  • Add explanatory comment showing both short and fully qualified parameter names are valid
  • Use both fully qualified and short parameter names for clear demonstration

Issue ticket number and link

Checklist before requesting a review

  • I have performed a self-review of my own code
  • I have verified that the code builds perfectly fine on my local system
  • I have added tests that prove my fix is effective or that my feature works
  • I have commented my code, particularly in hard-to-understand areas
  • I have verified that my code follows the style already available in the repository
  • I have made corresponding changes to the documentation

@lucky-rydar
lucky-rydar requested a review from a team as a code owner December 13, 2025 21:43
@lucky-rydar
lucky-rydar force-pushed the bugfix/lucky-rydar/axparameter-fix-inconsistency-in-api-usage branch 2 times, most recently from a6deba9 to 8a9d237 Compare December 15, 2025 15:36
@lucky-rydar lucky-rydar changed the title fix(axparameter): register callbacks with fully qualified parameter names fix(axparameter): Don't parse parameter name in the callback Dec 15, 2025
@lucky-rydar
lucky-rydar force-pushed the bugfix/lucky-rydar/axparameter-fix-inconsistency-in-api-usage branch from 8a9d237 to d487b8b Compare December 16, 2025 16:08
@FelixNilsson

Copy link
Copy Markdown

I see how this can look a bit inconsistent, however how the ax_parameter_register_callback() functions work is that it will convert the parameter name to the full path name. I.e it does not matter if the input is "IsCustomized" or "root." APP_NAME ".IsCustomized", the former input will be converted to the latter one.

When the callback parameter_changed is called the input name will always be the full name i.e
"root." APP_NAME ".IsCustomized".

So to keep it consistent I would prefer to also change the call to ax_parameter_register_callback() to use the full name.

@lucky-rydar

Copy link
Copy Markdown
Contributor Author

...it will convert the parameter name to the full path name...

so the callback registrator and other API can differ "relative" parameter name like IsCustom and full path names so in the result it converts everything to full path?

I think it is also required to add a comment next to ax_parameter_register_callback that will say that both formats of parameter name can be used.

@FelixNilsson

Copy link
Copy Markdown

Yes I agree we will update the documentation to make it clear that both formats can use but it will always be converted to the full path name, and it is the full path name that you get it the callback function.

@lucky-rydar
lucky-rydar force-pushed the bugfix/lucky-rydar/axparameter-fix-inconsistency-in-api-usage branch from d487b8b to fedb734 Compare December 17, 2025 18:32
@lucky-rydar lucky-rydar changed the title fix(axparameter): Don't parse parameter name in the callback fix(axparameter): Enforce fully-qualified parameter names for consistency Dec 17, 2025
@lucky-rydar

Copy link
Copy Markdown
Contributor Author

@FelixNilsson consider reviewing the updated PR with all the replaced parameter names to fully qualified. Also I have added a comment describing which alternative formats can be used as well.

Comment thread axparameter/app/axparameter.c Outdated
// - "IsCustomized"
// - "root.axparameter.IsCustomized"
//
// There is alternative formar used only for system parameters:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove R197-198, it is only possible to register callbacks to the ACAPs own parameters.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@lucky-rydar
lucky-rydar force-pushed the bugfix/lucky-rydar/axparameter-fix-inconsistency-in-api-usage branch from fedb734 to b548036 Compare December 18, 2025 13:57
Comment thread axparameter/app/axparameter.c Outdated

if (!ax_parameter_get(handle, "BackupValue", &value, &error) ||
!ax_parameter_add(handle, "CustomValue", value, NULL, &error))
!ax_parameter_add(handle, "root." APP_NAME ".CustomValue", value, NULL, &error))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I missed this but it is not possible to use the full path in the function ax_parameter_add().

I can update the library so that this will work, but it will take sometime until that change is released.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that if we have same multi format input we will improve consistency. So I think the library should be updated.

I would offer to add here a note also. Once it will be updated on the implementation side, we will remove it and update usage.

BTW, as I dont have any hardware to run it on. Is that possible to request someone to verify how it works?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we are veryfing the changes before we take them in that is how we noticed this issue.
I will update the library part so hopefully we can get that in to AXIS OS 12.9.

So if you update this now to use the short form we can bring in these changes and then I can update the documentation when the library changes has been delivered.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I will soon update it to use short name. I will also leave the explanation comment with additional line that says it works for all the API except of ax_parameter_add function

by the way, we need somehow to track who is adding new parameter so for example app "axparameter" cant create parameter with name "root.custom_app.MyParam" because it does not belong to "axparameter", But' that's on your side anyway

@killenheladagen

Copy link
Copy Markdown
Contributor

Why is this a desirable change?

I understand that it is reasonable to handle the parameters as fully qualified parameters internally, inside libaxparam, but here?

The ability to use the short names must be preserved, since removing that would be a breaking change and has to be announced in advance.

Given that the short name option exists, why would anyone want to use the fully qualified when only dealing with your own parameters? It just leads to more typing and longer code to read. This reasoning also applies to this example, that should focus on API usage and not string concatenation.

It could be an idea to replace one usage of a parameter here with a fully qualified one, just to show that it's possible, but as long as it is valid to use the short form, I'd argue that it's also the best choice for your own code.

@lucky-rydar
lucky-rydar marked this pull request as draft December 20, 2025 07:31
@lucky-rydar

Copy link
Copy Markdown
Contributor Author

It could be an idea to replace one usage of a parameter here with a fully qualified one, just to show that it's possible, but as long as it is valid to use the short form, I'd argue that it's also the best choice for your own code.

I agree. The original idea was to show that both formats of parameter names are possible so they always converted to full path if needed.

Just because I have never used this API before, that wasn't clear that callback registered in ax_parameter_register_callback is going to expect full qualified path despite the fact we registered for short formatted parameter name. So, this thing I think is needed to be updated in the docs for ax_parameter_register_callback

@lucky-rydar
lucky-rydar force-pushed the bugfix/lucky-rydar/axparameter-fix-inconsistency-in-api-usage branch 2 times, most recently from 26617d5 to 9c8b5e1 Compare December 25, 2025 09:34
@lucky-rydar lucky-rydar changed the title fix(axparameter): Enforce fully-qualified parameter names for consistency fix(axparameter): clarify parameter name format for axparameter API Dec 25, 2025
@lucky-rydar
lucky-rydar marked this pull request as ready for review December 25, 2025 10:05
@lucky-rydar

Copy link
Copy Markdown
Contributor Author

@FelixNilsson @killenheladagen Merry Christmas. consider to review pls

- Add explanatory comment showing both short and fully qualified parameter names are valid
- Use both fully qualified and short parameter names for clear demonstration
@johan-hultberg-work
johan-hultberg-work force-pushed the bugfix/lucky-rydar/axparameter-fix-inconsistency-in-api-usage branch from 9c8b5e1 to 538376e Compare February 12, 2026 08:14
@johan-hultberg-work

Copy link
Copy Markdown
Contributor

Thank you for your contribution!

Our workflow involves cherry-picking external contributions into an internal staging repository for more extensive testing before syncing back to this public repo. Your changes have passed that process and are now merged as part of the sync in #465.

Closing this PR since the changes are covered by the sync PR above. We welcome any future contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistent API usage in the "axparameter" example

4 participants