-
Notifications
You must be signed in to change notification settings - Fork 202
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
Exposing padding support in uds discovery. #100
base: master
Are you sure you want to change the base?
Conversation
Exposing padding support in uds discovery. This also adds opts --no-pad and --padding to uds discovery subcommand.
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.
Hi there and thanks for the PR! There are some issues which need to be addressed before it can be accepted, please see the comments in this review.
@@ -169,7 +169,7 @@ def is_valid_response(message): | |||
|
|||
found_arbitration_ids = [] | |||
|
|||
with IsoTp(None, None) as tp: | |||
with IsoTp(None, None, padding_value=None) as tp: |
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.
If possible the ISO-TP support for padding (implemented in 3713cec) should be used here, rather than turning it off and reinventing the ISO-TP padding on a higher protocol level inside the UDS module. This might however be more applicable for a future rewrite of the module which does not fiddle with ISO-TP internals 🙂 Any thoughts/opinions on this are welcome!
@@ -110,7 +110,7 @@ | |||
|
|||
|
|||
def uds_discovery(min_id, max_id, blacklist_args, auto_blacklist_duration, | |||
delay, verify, print_results=True): | |||
delay, verify, padding, print_results=True): |
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.
Adding a required positional argument to uds_discovery
without a default value will break all existing code using it, including (but not necessarily limited to) two tests in the CC test suite:
$ cc.py -i vcan0 test
-------------------
CARING CARIBOU v0.4
-------------------
Loading module 'test'
Running tests using CAN interface 'vcan0'
test_create_iso_14229_1 (test_iso_14229_1.DiagnosticsOverIsoTpTestCase) ... ok
test_ecu_reset_failure_on_invalid_reset_type (test_iso_14229_1.DiagnosticsOverIsoTpTestCase) ... ok
test_ecu_reset_failure_suppress_positive_response (test_iso_14229_1.DiagnosticsOverIsoTpTestCase) ... ok
test_ecu_reset_success (test_iso_14229_1.DiagnosticsOverIsoTpTestCase) ... ok
test_ecu_reset_success_suppress_positive_response (test_iso_14229_1.DiagnosticsOverIsoTpTestCase) ... ok
test_read_data_by_identifier_failure (test_iso_14229_1.DiagnosticsOverIsoTpTestCase) ... ok
test_read_data_by_identifier_success (test_iso_14229_1.DiagnosticsOverIsoTpTestCase) ... ok
test_read_memory_by_address_failure_on_invalid_length (test_iso_14229_1.DiagnosticsOverIsoTpTestCase) ... ok
test_read_memory_by_address_success (test_iso_14229_1.DiagnosticsOverIsoTpTestCase) ... ok
test_write_data_by_identifier_failure (test_iso_14229_1.DiagnosticsOverIsoTpTestCase) ... ok
test_write_data_by_identifier_success (test_iso_14229_1.DiagnosticsOverIsoTpTestCase) ... ok
test_create_iso_15765_2 (test_iso_15765_2.IsoTpTestCase) ... ok
test_fail_too_long_message (test_iso_15765_2.IsoTpTestCase) ... ok
test_multi_frame_long_message (test_iso_15765_2.IsoTpTestCase) ... ok
test_multi_frame_two_frames (test_iso_15765_2.IsoTpTestCase) ... ok
test_single_frame (test_iso_15765_2.IsoTpTestCase) ... ok
ok0101ump_dids (test_module_uds.UdsModuleTestCase) ... 0x0000
test_ecu_reset_hard_reset_success (test_module_uds.UdsModuleTestCase) ... ok
test_ecu_reset_unsupported_reset_type_failure (test_module_uds.UdsModuleTestCase) ... ok
test_security_access_request_seed_invalid_level (test_module_uds.UdsModuleTestCase) ... ok
test_security_access_request_seed_send_key_success (test_module_uds.UdsModuleTestCase) ... ok
test_service_discovery (test_module_uds.UdsModuleTestCase) ... ok
test_service_discovery_empty_range (test_module_uds.UdsModuleTestCase) ... ok
test_uds_discovery (test_module_uds.UdsModuleTestCase) ... ERROR
test_uds_discovery_blacklist (test_module_uds.UdsModuleTestCase) ... ERROR
test_parse_candump_line (test_send.SendFileParserTestCase) ... ok
test_parse_pythoncan_line_v_20 (test_send.SendFileParserTestCase) ... ok
test_parse_pythoncan_line_v_21 (test_send.SendFileParserTestCase) ... ok
test_parse_pythoncan_line_v_21_flags (test_send.SendFileParserTestCase) ... ok
test_parse_pythoncan_line_v_30_channel (test_send.SendFileParserTestCase) ... ok
test_parse_pythoncan_line_v_30_flags (test_send.SendFileParserTestCase) ... ok
======================================================================
ERROR: test_uds_discovery (test_module_uds.UdsModuleTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/caringcaribou-0.4-py3.10.egg/caringcaribou/tests/test_module_uds.py", line 36, in test_uds_discovery
result = uds.uds_discovery(min_id=start_arb_id,
TypeError: uds_discovery() missing 1 required positional argument: 'padding'
======================================================================
ERROR: test_uds_discovery_blacklist (test_module_uds.UdsModuleTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/caringcaribou-0.4-py3.10.egg/caringcaribou/tests/test_module_uds.py", line 58, in test_uds_discovery_blacklist
result = uds.uds_discovery(min_id=start_arb_id,
TypeError: uds_discovery() missing 1 required positional argument: 'padding'
----------------------------------------------------------------------
Ran 31 tests in 0.899s
FAILED (errors=2)
It also seems to be missing in the docstring.
@@ -287,11 +287,16 @@ def __uds_discovery_wrapper(args): | |||
delay = args.delay | |||
verify = not args.skipverify | |||
print_results = True | |||
padding=args.padding |
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.
The formatting of this block does not adhere to PEP 8, both in terms of spacing and the double newlines at the end
@@ -837,7 +842,7 @@ def __auto_wrapper(args): | |||
try: | |||
arb_id_pairs = uds_discovery(min_id, max_id, blacklist, | |||
auto_blacklist_duration, | |||
delay, verify, print_results) | |||
delay, verify, padding, print_results) |
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.
padding
is undefined here, causing the whole __auto_wrapper
function to break:
$ cc.py -i vcan0 uds auto
-------------------
CARING CARIBOU v0.4
-------------------
Loading module 'uds'
Traceback (most recent call last):
File "/usr/local/bin/cc.py", line 33, in <module>
sys.exit(load_entry_point('caringcaribou==0.4', 'console_scripts', 'cc.py')())
File "/usr/local/lib/python3.10/dist-packages/caringcaribou-0.4-py3.10.egg/caringcaribou/caringcaribou.py", line 125, in main
cc_mod.module_main(args.module_args)
File "/usr/local/lib/python3.10/dist-packages/caringcaribou-0.4-py3.10.egg/caringcaribou/modules/uds.py", line 1347, in module_main
args.func(args)
File "/usr/local/lib/python3.10/dist-packages/caringcaribou-0.4-py3.10.egg/caringcaribou/modules/uds.py", line 845, in __auto_wrapper
delay, verify, padding, print_results)
NameError: name 'padding' is not defined
Many thanks for the review! |
Exposing padding support in uds discovery. This also adds opts --no-pad and --padding to uds discovery subcommand.