Skip to content

Commit 2d8d5dc

Browse files
TedRiosebclrsn
andauthored
Feat/add response timing (#15)
* feat: add response timing * chore: fix typo in changelog * feat: modify last pending resp times to be the interval between each pending response * chore: fix typo Co-authored-by: Sebastian Clerson <58192998+sebclrsn@users.noreply.github.com> --------- Co-authored-by: Sebastian Clerson <58192998+sebclrsn@users.noreply.github.com>
1 parent 724ee2b commit 2d8d5dc

3 files changed

Lines changed: 23 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [3.1.0]
5+
6+
### Features
7+
- ``Uds``: add response time and list of response pending times as attribute
8+
49
## [3.0.3]
510

611
### Features

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
tests_require=["pytest", "pytest-mock"],
2929
extras_require={"test": ["pytest", "pytest-mock"]},
3030
# *strongly* suggested for sharing
31-
version="3.0.3",
31+
version="3.1.0",
3232
# The license can be anything you like
3333
license="MIT",
3434
description="Please use python-uds instead, this is a refactored version with breaking changes, only for pykiso",

uds/uds_communications/Uds/Uds.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ def __init__(self, odx=None, ihexFile=None, **kwargs):
3939
self.__transportProtocol, **kwargs
4040
)
4141

42+
self.last_resp_time = None
43+
self.last_pending_resp_times = []
44+
4245
# used as a semaphore for the tester present
4346
self.__transmissionActive_flag = False
4447

@@ -123,6 +126,7 @@ def send(self, msg, responseRequired=True, functionalReq=False, tpWaitTime=0.01)
123126
# sets a current transmission in progress - tester present (if running) will not send if this flag is set to true
124127
self.__transmissionActive_flag = True
125128

129+
before_send_time = time.perf_counter()
126130
# We're moving to threaded operation, so putting a lock around the send operation.
127131
with self.sendLock:
128132
self.tp.send(msg, functionalReq, tpWaitTime)
@@ -132,13 +136,24 @@ def send(self, msg, responseRequired=True, functionalReq=False, tpWaitTime=0.01)
132136

133137
# Note: in automated mode (unlikely to be used any other way), there is no response from tester present, so threading is not an issue here.
134138
response = None
135-
139+
previous_time = None
140+
self.last_resp_time = None
141+
self.last_pending_resp_times = []
142+
136143
if responseRequired:
137144
while True:
138145
response = self.tp.recv(self.__P2_CAN_Client)
146+
current_time = time.perf_counter() - before_send_time
147+
if response[2] == 0x78:
148+
if previous_time is None:
149+
self.last_pending_resp_times.append(current_time)
150+
previous_time = current_time
151+
else:
152+
self.last_pending_resp_times.append(current_time - previous_time)
139153
if not ((response[0] == 0x7F) and (response[2] == 0x78)):
154+
self.last_resp_time = current_time
140155
break
141-
156+
142157
# If the diagnostic session control service is supported, record the sending time for possible use by the tester present functionality (again, if present) ...
143158
if hasattr(self, "sessionSetLastSend"):
144159
self.sessionSetLastSend()

0 commit comments

Comments
 (0)