@@ -900,6 +900,7 @@ def send_key(arb_id_request, arb_id_response, level, key, timeout):
900
900
901
901
def __dump_dids_wrapper (args ):
902
902
"""Wrapper used to initiate data identifier dump"""
903
+ diagnostic = args .dsc
903
904
arb_id_request = args .src
904
905
arb_id_response = args .dst
905
906
timeout = args .timeout
@@ -920,7 +921,7 @@ def __dump_dids_wrapper(args):
920
921
921
922
padding_set (padding , no_padding )
922
923
923
- dump_dids (arb_id_request , arb_id_response , timeout , reporting , min_did , max_did ,
924
+ dump_dids (arb_id_request , arb_id_response , timeout , reporting , diagnostic , min_did , max_did ,
924
925
print_results )
925
926
926
927
def report_print (text ):
@@ -1236,7 +1237,7 @@ def __auto_wrapper(args):
1236
1237
report_print ("\n Discovery failed: {0}" .format (e ))
1237
1238
1238
1239
1239
- def dump_dids (arb_id_request , arb_id_response , timeout , reporting ,
1240
+ def dump_dids (arb_id_request , arb_id_response , timeout , reporting , diagnostic ,
1240
1241
min_did = DUMP_DID_MIN , max_did = DUMP_DID_MAX , print_results = True ):
1241
1242
"""
1242
1243
Sends read data by identifier (DID) messages to 'arb_id_request'.
@@ -1275,6 +1276,10 @@ def dump_dids(arb_id_request, arb_id_response, timeout, reporting,
1275
1276
global REPORT
1276
1277
REPORT = 1
1277
1278
1279
+ response_diag = extended_session (arb_id_request , arb_id_response , diagnostic )
1280
+ if not Iso14229_1 .is_positive_response (response_diag ):
1281
+ raise ValueError ("Supplied Diagnostic Session Control subservice results in Negative Response" )
1282
+
1278
1283
responses = []
1279
1284
with IsoTp (arb_id_request = arb_id_request ,
1280
1285
arb_id_response = arb_id_response ) as tp :
@@ -1561,7 +1566,7 @@ def __routine_control_dump_wrapper(args):
1561
1566
"""Wrapper used to initiate routine dump"""
1562
1567
arb_id_request = args .src
1563
1568
arb_id_response = args .dst
1564
- dsc = args .dsc
1569
+ diagnostic = args .dsc
1565
1570
subfunction = args .subfunction
1566
1571
timeout = args .timeout
1567
1572
min_routine = args .min_routine
@@ -1571,14 +1576,14 @@ def __routine_control_dump_wrapper(args):
1571
1576
1572
1577
padding_set (padding , no_padding )
1573
1578
1574
- found_routines = routine_control_dump (arb_id_request , arb_id_response , timeout , dsc , subfunction , min_routine , max_routine )
1579
+ found_routines = routine_control_dump (arb_id_request , arb_id_response , timeout , diagnostic , subfunction , min_routine , max_routine )
1575
1580
1576
1581
print ("\n Discovered Routines:" )
1577
1582
# Print results
1578
1583
for routine_id in found_routines :
1579
1584
print (routine_id )
1580
1585
1581
- def routine_control_dump (arb_id_request , arb_id_response , timeout , dsc , subfunction ,
1586
+ def routine_control_dump (arb_id_request , arb_id_response , timeout , diagnostic , subfunction ,
1582
1587
min_routine = DUMP_ROUTINE_MIN , max_routine = DUMP_ROUTINE_MAX ):
1583
1588
"""
1584
1589
Sends start routine messages to 'arb_id_request'.
@@ -1630,12 +1635,14 @@ def routine_control_dump(arb_id_request, arb_id_response, timeout, dsc, subfunct
1630
1635
1631
1636
print ('Enumerating Routines with attributes:' )
1632
1637
1633
- print ('Diagnostic Session Control: 0x{0:02x}' .format (dsc ))
1638
+ print ('Diagnostic Session Control: 0x{0:02x}' .format (diagnostic ))
1634
1639
print ('Routine Control Sub Function: 0x{0:02x}' .format (subfunction ))
1635
1640
print ('Minimum Routine: 0x{:04x}' .format (min_routine ))
1636
1641
print ('Maximum Routine: 0x{:04x}' .format (max_routine ))
1637
1642
1638
- raw_send (arb_id_request , arb_id_response , ServiceID .DIAGNOSTIC_SESSION_CONTROL , dsc )
1643
+ response_diag = extended_session (arb_id_request , arb_id_response , diagnostic )
1644
+ if not Iso14229_1 .is_positive_response (response_diag ):
1645
+ raise ValueError ("Supplied Diagnostic Session Control subservice results in Negative Response" )
1639
1646
1640
1647
for routine in range (min_routine , max_routine + 1 ):
1641
1648
response = uds .routine_control (subfunction , routine = [routine ])
@@ -1645,7 +1652,7 @@ def routine_control_dump(arb_id_request, arb_id_response, timeout, dsc, subfunct
1645
1652
if len (response ) >= 2 :
1646
1653
if Iso14229_1 .is_positive_response (response ):
1647
1654
found_routines .append ('0x{:04x}' .format (routine ))
1648
- if len (response ) < 2 :
1655
+ if response is None or len (response ) == 0 :
1649
1656
continue
1650
1657
1651
1658
print ("\033 [K" , file = stderr )
@@ -1875,6 +1882,9 @@ def __parse_args(args):
1875
1882
default = DUMP_DID_TIMEOUT ,
1876
1883
help = "wait T seconds for response before "
1877
1884
"timeout" )
1885
+ parser_did .add_argument ("--dsc" , metavar = "dtype" ,
1886
+ type = parse_int_dec_or_hex , default = "0x01" ,
1887
+ help = "Diagnostic Session Control Subsession Byte" )
1878
1888
parser_did .add_argument ("--min_did" ,
1879
1889
type = parse_int_dec_or_hex ,
1880
1890
default = DUMP_DID_MIN ,
@@ -1995,15 +2005,15 @@ def __parse_args(args):
1995
2005
1996
2006
# Parser for write_did
1997
2007
parser_wdid = subparsers .add_parser ("write_dids" )
1998
- parser_wdid .add_argument ("dsc" , metavar = "dtype" ,
1999
- type = parse_int_dec_or_hex , default = "0x03" ,
2000
- help = "Diagnostic Session Control Subsession Byte" )
2001
2008
parser_wdid .add_argument ("src" ,
2002
2009
type = parse_int_dec_or_hex ,
2003
2010
help = "arbitration ID to transmit to" )
2004
2011
parser_wdid .add_argument ("dst" ,
2005
2012
type = parse_int_dec_or_hex ,
2006
2013
help = "arbitration ID to listen to" )
2014
+ parser_wdid .add_argument ("--dsc" , metavar = "dtype" ,
2015
+ type = parse_int_dec_or_hex , default = "0x03" ,
2016
+ help = "Diagnostic Session Control Subsession Byte" )
2007
2017
parser_wdid .add_argument ("-t" , "--timeout" ,
2008
2018
type = float , metavar = "T" ,
2009
2019
default = DUMP_DID_TIMEOUT ,
0 commit comments