-
Notifications
You must be signed in to change notification settings - Fork 373
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
Server method decorated with uamethod do not convert to correct dtypes #1784
Comments
@GPla the main issue is there is no "int16" in python... and if your method does not return the correct VariantType asyncua can only guess and guess what a python int is an int64 the same thing applies with other types as well. due to the fact that OPC UA is strict on typing i recommend you to always specify the correct VariantType! |
I understand why this is the case. However, it would be nice if it was mentioned in the docstring of My problem with this implementation is, that the information is known through the registration of the method. Now, this information should be used to verify the types. This job should actually reside with the |
you are right. I do not see it as a very big issue because if you care about types you should not use that wrapper, but MR is welcome. |
here us a good example! edit @GPla : if you define the "ua.Argument()" and the wrapper before binding you could use the info to validate contents:
|
Describe the bug
A server method decorated with
@uamethod
does not convert to the dtypes specified when registering the method at the server. Integers are always converted toInt64
and floats toDouble
.To Reproduce
Adapted from the sync examples:
Printed output:
Expected behavior
The return type should be
Int16
as inadd_method
instead ofInt64
.Problem
The conversion in
uamethod
is performed by calling_format_call_outputs
andto_variant
if noVariant
is returned by the method; a newVariant
withVariantType=None
is initialized.Thereby, the types are guessed and the types from the method registration are ignored.
From methods.py:
Version
Python-Version: 3.11
opcua-asyncio Version (e.g. master branch, 0.9): 1.1.5
The text was updated successfully, but these errors were encountered: