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
feat: com aux able to receive timestamps #466
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ | |
import queue | ||
import threading | ||
from contextlib import ContextDecorator | ||
from typing import Any, Optional | ||
from typing import Any, Optional, Tuple | ||
|
||
from pykiso import CChannel, Message | ||
from pykiso.auxiliary import AuxiliaryInterface, close_connector, open_connector | ||
|
@@ -136,11 +136,13 @@ def receive_message( | |
self, | ||
blocking: bool = True, | ||
timeout_in_s: float = None, | ||
) -> Optional[bytes]: | ||
receive_timestamp: bool = False, | ||
) -> Optional[bytes | Tuple[bytes, int] | Tuple[bytes, int, float]]: | ||
"""Receive a raw message. | ||
|
||
:param blocking: wait for message till timeout elapses? | ||
:param timeout_in_s: maximum time in second to wait for a response | ||
:param receive_timestamp: True if timestamp should be returned, False otherwise | ||
|
||
:returns: raw message | ||
""" | ||
|
@@ -167,9 +169,12 @@ def receive_message( | |
|
||
msg = response.get("msg") | ||
remote_id = response.get("remote_id") | ||
timestamp = response.get("timestamp") | ||
|
||
# stay with the old return type to not making a breaking change | ||
if remote_id is not None: | ||
if receive_timestamp: | ||
return (msg, remote_id, timestamp) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's still a breaking change, or am I missing something? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add an additional keyword argument |
||
elif remote_id and not receive_timestamp: | ||
return (msg, remote_id) | ||
return msg | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parameter docstring is missing 🙈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouuups, sorry I was trying to be quick so it can be merge before 0.28.0 🚑