Skip to content

Conversation

@jakubkrista
Copy link
Contributor

@jakubkrista jakubkrista commented Jul 24, 2025

Hello,

I add vm_specific parameter also to the DoIPClient initialization. The value is now stored as a static attr. of the instance so, whenever in request_activation is called, then value is used, when value is not overwrited by method's argument. This means I can set vm_specific in initialization, and it will be directly used in RouterActivationRequest, including during reconnection.

Value is handled by setter and getter - this allows it to be overridden and used as a hook.

It is fully backward compatible.

Feel free to suggest any modifications or refuse whole request.

Thanks,
Jakub

Jakub Krista added 4 commits July 24, 2025 13:52
…add 'vm_specific' as an init argument and store it as a static value for the entire instance. Add .idea/ to .gitignore
Copy link
Owner

@jacobschaer jacobschaer left a comment

Choose a reason for hiding this comment

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

Sorry for the delay I forgot to mark the review finished

Comment on lines 829 to 851

@property
def vm_specific(self):
"""Get the optional OEM specific field value if set.
:return: vm_specific value
:rtype: int, optional
"""
return self._vm_specific

@vm_specific.setter
def vm_specific(self, value):
"""Set the optional OEM specific field value. If you do not need to send this item, set it to None.
:param value: The vm_specific value (must be > 0 and <= 0xffffffff) or None.
:type value: int, optional
:raises ValueError: Value is invalid or out of range
"""
if not isinstance(value, int) and value is not None:
raise ValueError("Invalid vm_specific type must be int or None")
if isinstance(value, int) and (value < 0 or value > 0xffffffff):
raise ValueError("Invalid vm_specific value must be > 0 and <= 0xffffffff")
self._vm_specific = value
Copy link
Owner

Choose a reason for hiding this comment

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

Do we anticipate the user needing to change vm_specific over the life of the object? I don't mind the setter or getter though. What I am wondering though is if we can move the validation out of the setter and into a helper function like validate_vm_specific(value). Since you went to the trouble of validating here, but the user is allowed to pass an unvalidated vlaue to request_activation(). Might as well validate in both places. Otherwise this seems fine

…specific value also in request_activation; add tests
@jakubkrista
Copy link
Contributor Author

Thank you for the great catch. I moved the validation to a static method and added the validation to request_validation().
Actually, I do not need to change the value while the object exists. I just need to send a zero value. :-) However, such use cases may exist. I am not sure what the specification says about this.

@jacobschaer jacobschaer merged commit c82aaed into jacobschaer:main Aug 13, 2025
14 checks passed
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