Skip to content

Commit 23689ab

Browse files
committed
Updated doc to include new feature that fixes #37
1 parent 08bb81f commit 23689ab

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

doc/source/udsoncan/client.rst

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ Suppress positive response
220220
The UDS standard proposes a mechanism to avoid treating useless positive responses. For all services using a subfunction byte, the client can set bit 7 of the subfunction byte to signal that no response is necessary if the response is positive.
221221
This bit is called the ``suppressPosRspMsgIndicationBit``
222222

223-
The ``Client`` object lets you use that feature by using ``suppress_positive_response`` into a ``with`` statement. See following example:
223+
The ``Client`` object lets you use that feature by using ``suppress_positive_response`` into a ``with`` statement. See the following example:
224224

225225
.. code-block:: python
226226
@@ -233,6 +233,35 @@ If ``suppress_positive_response`` is asking for a service with no subfunction by
233233

234234
-----
235235

236+
Overriding the output
237+
---------------------
238+
239+
For mean of testing, it may be useful to send invalid payloads to the server and still want the ``Client`` object to parse the response of the server.
240+
241+
It is possible to do so by using the ``payload_override`` property into a ``with`` statement. See the following example:
242+
243+
.. code-block:: python
244+
245+
with client.payload_override(b'\x11\x22\x33'): # Client will send 112233 (hex) in every call within this "with" statement
246+
client.tester_present()
247+
248+
It is also possible to override with a function that modify the original output
249+
250+
.. code-block:: python
251+
252+
def my_func(payload):
253+
return payload + b'\x00' # Add extra 00 to the payload
254+
255+
with client.payload_override(my_func): # Client will append 00 to its output
256+
client.tester_present()
257+
258+
When using that feature, the client will process the response from the server just like if a valid request was sent. The response may be :ref:`Invalid<InvalidResponseException>`, :ref:`Unexpected<UnexpectedResponseException>` or :ref:`Negative<NegativeResponseException>`.
259+
260+
261+
.. note:: It is possible to change the behaviour of the client on failing requests. See the client parameters :ref:`exception_on_invalid_response<config_exception_on_invalid_response>`, :ref:`exception_on_unexpected_response<config_exception_on_unexpected_response>` and :ref:`exception_on_negative_response<config_exception_on_negative_response>`
262+
263+
-----
264+
236265
Methods by services
237266
-------------------
238267

0 commit comments

Comments
 (0)