16
16
BitEnumField , BitField , XByteField , FieldListField , \
17
17
XShortField , X3BytesField , XIntField , ByteField , \
18
18
ShortField , ObservableDict , XShortEnumField , XByteEnumField , StrLenField , \
19
- FieldLenField , XStrFixedLenField , XStrLenField , FlagsField , PacketListField , \
20
- PacketField
19
+ FieldLenField , XStrFixedLenField , XStrLenField , FlagsField , PacketListField
21
20
from scapy .packet import Packet , bind_layers , NoPayload
22
21
from scapy .config import conf
23
22
from scapy .error import log_loading
@@ -153,7 +152,7 @@ class UDS_DSCPR(Packet):
153
152
154
153
def answers (self , other ):
155
154
return isinstance (other , UDS_DSC ) and \
156
- other .diagnosticSessionType == self .diagnosticSessionType
155
+ other .diagnosticSessionType == self .diagnosticSessionType
157
156
158
157
159
158
bind_layers (UDS , UDS_DSCPR , service = 0x50 )
@@ -219,7 +218,7 @@ class UDS_SAPR(Packet):
219
218
220
219
def answers (self , other ):
221
220
return isinstance (other , UDS_SA ) \
222
- and other .securityAccessType == self .securityAccessType
221
+ and other .securityAccessType == self .securityAccessType
223
222
224
223
225
224
bind_layers (UDS , UDS_SAPR , service = 0x67 )
@@ -274,7 +273,7 @@ class UDS_CCPR(Packet):
274
273
275
274
def answers (self , other ):
276
275
return isinstance (other , UDS_CC ) \
277
- and other .controlType == self .controlType
276
+ and other .controlType == self .controlType
278
277
279
278
280
279
bind_layers (UDS , UDS_CCPR , service = 0x68 )
@@ -430,7 +429,7 @@ class UDS_AUTHPR(Packet):
430
429
431
430
def answers (self , other ):
432
431
return isinstance (other , UDS_AUTH ) \
433
- and other .subFunction == self .subFunction
432
+ and other .subFunction == self .subFunction
434
433
435
434
436
435
bind_layers (UDS , UDS_AUTHPR , service = 0x69 )
@@ -492,8 +491,8 @@ class UDS_ATPPR(Packet):
492
491
493
492
def answers (self , other ):
494
493
return isinstance (other , UDS_ATP ) \
495
- and other .timingParameterAccessType == \
496
- self .timingParameterAccessType
494
+ and other .timingParameterAccessType == \
495
+ self .timingParameterAccessType
497
496
498
497
499
498
bind_layers (UDS , UDS_ATPPR , service = 0xC3 )
@@ -606,7 +605,7 @@ class UDS_ROEPR(Packet):
606
605
607
606
def answers (self , other ):
608
607
return isinstance (other , UDS_ROE ) \
609
- and other .eventType == self .eventType
608
+ and other .eventType == self .eventType
610
609
611
610
612
611
bind_layers (UDS , UDS_ROEPR , service = 0xC6 )
@@ -645,7 +644,7 @@ class UDS_LCPR(Packet):
645
644
646
645
def answers (self , other ):
647
646
return isinstance (other , UDS_LC ) \
648
- and other .linkControlType == self .linkControlType
647
+ and other .linkControlType == self .linkControlType
649
648
650
649
651
650
bind_layers (UDS , UDS_LCPR , service = 0xC7 )
@@ -674,7 +673,7 @@ class UDS_RDBIPR(Packet):
674
673
675
674
def answers (self , other ):
676
675
return isinstance (other , UDS_RDBI ) \
677
- and self .dataIdentifier in other .identifiers
676
+ and self .dataIdentifier in other .identifiers
678
677
679
678
680
679
bind_layers (UDS , UDS_RDBIPR , service = 0x62 )
@@ -744,7 +743,7 @@ class UDS_RSDBIPR(Packet):
744
743
745
744
def answers (self , other ):
746
745
return isinstance (other , UDS_RSDBI ) \
747
- and other .dataIdentifier == self .dataIdentifier
746
+ and other .dataIdentifier == self .dataIdentifier
748
747
749
748
750
749
bind_layers (UDS , UDS_RSDBIPR , service = 0x64 )
@@ -781,7 +780,7 @@ class UDS_RDBPIPR(Packet):
781
780
782
781
def answers (self , other ):
783
782
return isinstance (other , UDS_RDBPI ) \
784
- and other .periodicDataIdentifier == self .periodicDataIdentifier
783
+ and other .periodicDataIdentifier == self .periodicDataIdentifier
785
784
786
785
787
786
bind_layers (UDS , UDS_RDBPIPR , service = 0x6A )
@@ -813,7 +812,7 @@ class UDS_DDDIPR(Packet):
813
812
814
813
def answers (self , other ):
815
814
return isinstance (other , UDS_DDDI ) \
816
- and other .subFunction == self .subFunction
815
+ and other .subFunction == self .subFunction
817
816
818
817
819
818
bind_layers (UDS , UDS_DDDIPR , service = 0x6C )
@@ -840,7 +839,7 @@ class UDS_WDBIPR(Packet):
840
839
841
840
def answers (self , other ):
842
841
return isinstance (other , UDS_WDBI ) \
843
- and other .dataIdentifier == self .dataIdentifier
842
+ and other .dataIdentifier == self .dataIdentifier
844
843
845
844
846
845
bind_layers (UDS , UDS_WDBIPR , service = 0x6E )
@@ -901,8 +900,8 @@ class UDS_WMBAPR(Packet):
901
900
902
901
def answers (self , other ):
903
902
return isinstance (other , UDS_WMBA ) \
904
- and other .memorySizeLen == self .memorySizeLen \
905
- and other .memoryAddressLen == self .memoryAddressLen
903
+ and other .memorySizeLen == self .memorySizeLen \
904
+ and other .memoryAddressLen == self .memoryAddressLen
906
905
907
906
908
907
bind_layers (UDS , UDS_WMBAPR , service = 0x7D )
@@ -1012,30 +1011,12 @@ class UDS_RDTCI(Packet):
1012
1011
1013
1012
1014
1013
class DTC (Packet ):
1015
- name = 'Diagnostic Trouble Code '
1014
+ name = 'DTC and status record '
1016
1015
fields_desc = [
1017
- BitEnumField ("system" , 0 , 2 , {
1018
- 0 : "Powertrain" ,
1019
- 1 : "Chassis" ,
1020
- 2 : "Body" ,
1021
- 3 : "Network" }),
1022
- BitEnumField ("type" , 0 , 2 , {
1023
- 0 : "Generic" ,
1024
- 1 : "ManufacturerSpecific" ,
1025
- 2 : "Generic" ,
1026
- 3 : "Generic" }),
1016
+ BitEnumField ("system" , 0 , 2 , {0 : "Powertrain" , 1 : "Chassis" , 2 : "Body" , 3 : "Network" }),
1017
+ BitEnumField ("type" , 0 , 2 , {0 : "Generic" , 1 : "ManufacturerSpecific" , 2 : "Generic" , 3 : "Generic" }),
1027
1018
BitField ("numeric_value_code" , 0 , 12 ),
1028
1019
ByteField ("additional_information_code" , 0 ),
1029
- ]
1030
-
1031
- def extract_padding (self , s ):
1032
- return '' , s
1033
-
1034
-
1035
- class DTC_Status (Packet ):
1036
- name = 'DTC and status record'
1037
- fields_desc = [
1038
- PacketField ("dtc" , None , pkt_cls = DTC ),
1039
1020
FlagsField ("status" , 0 , 8 , UDS_RDTCI .dtcStatus )
1040
1021
]
1041
1022
@@ -1047,11 +1028,12 @@ class UDS_RDTCIPR(Packet):
1047
1028
name = 'ReadDTCInformationPositiveResponse'
1048
1029
fields_desc = [
1049
1030
ByteEnumField ('reportType' , 0 , UDS_RDTCI .reportTypes ),
1050
- ConditionalField (
1051
- FlagsField ('DTCStatusAvailabilityMask' , 0 , 8 , UDS_RDTCI .dtcStatus ),
1052
- lambda pkt : pkt .reportType in [0x01 , 0x07 , 0x11 , 0x12 , 0x02 , 0x0A ,
1053
- 0x0B , 0x0C , 0x0D , 0x0E , 0x0F , 0x13 ,
1054
- 0x15 ]),
1031
+ ConditionalField (FlagsField ('DTCStatusAvailabilityMask' , 0 , 8 , UDS_RDTCI .dtcStatus ),
1032
+ lambda pkt : pkt .reportType in [0x01 , 0x07 , 0x11 ,
1033
+ 0x12 , 0x02 , 0x0A ,
1034
+ 0x0B , 0x0C , 0x0D ,
1035
+ 0x0E , 0x0F , 0x13 ,
1036
+ 0x15 ]),
1055
1037
ConditionalField (ByteEnumField ('DTCFormatIdentifier' , 0 ,
1056
1038
{0 : 'ISO15031-6DTCFormat' ,
1057
1039
1 : 'UDS-1DTCFormat' ,
@@ -1062,8 +1044,7 @@ class UDS_RDTCIPR(Packet):
1062
1044
ConditionalField (ShortField ('DTCCount' , 0 ),
1063
1045
lambda pkt : pkt .reportType in [0x01 , 0x07 ,
1064
1046
0x11 , 0x12 ]),
1065
- ConditionalField (PacketListField ('DTCAndStatusRecord' , None ,
1066
- pkt_cls = DTC_Status ),
1047
+ ConditionalField (PacketListField ('DTCAndStatusRecord' , None , pkt_cls = DTC ),
1067
1048
lambda pkt : pkt .reportType in [0x02 , 0x0A , 0x0B ,
1068
1049
0x0C , 0x0D , 0x0E ,
1069
1050
0x0F , 0x13 , 0x15 ]),
@@ -1075,7 +1056,7 @@ class UDS_RDTCIPR(Packet):
1075
1056
1076
1057
def answers (self , other ):
1077
1058
return isinstance (other , UDS_RDTCI ) \
1078
- and other .reportType == self .reportType
1059
+ and other .reportType == self .reportType
1079
1060
1080
1061
1081
1062
bind_layers (UDS , UDS_RDTCIPR , service = 0x59 )
@@ -1110,8 +1091,8 @@ class UDS_RCPR(Packet):
1110
1091
1111
1092
def answers (self , other ):
1112
1093
return isinstance (other , UDS_RC ) \
1113
- and other .routineControlType == self .routineControlType \
1114
- and other .routineIdentifier == self .routineIdentifier
1094
+ and other .routineControlType == self .routineControlType \
1095
+ and other .routineIdentifier == self .routineIdentifier
1115
1096
1116
1097
1117
1098
bind_layers (UDS , UDS_RCPR , service = 0x71 )
@@ -1230,7 +1211,7 @@ class UDS_TDPR(Packet):
1230
1211
1231
1212
def answers (self , other ):
1232
1213
return isinstance (other , UDS_TD ) \
1233
- and other .blockSequenceCounter == self .blockSequenceCounter
1214
+ and other .blockSequenceCounter == self .blockSequenceCounter
1234
1215
1235
1216
1236
1217
bind_layers (UDS , UDS_TDPR , service = 0x76 )
@@ -1370,7 +1351,7 @@ class UDS_IOCBIPR(Packet):
1370
1351
1371
1352
def answers (self , other ):
1372
1353
return isinstance (other , UDS_IOCBI ) \
1373
- and other .dataIdentifier == self .dataIdentifier
1354
+ and other .dataIdentifier == self .dataIdentifier
1374
1355
1375
1356
1376
1357
bind_layers (UDS , UDS_IOCBIPR , service = 0x6F )
@@ -1435,8 +1416,8 @@ class UDS_NR(Packet):
1435
1416
1436
1417
def answers (self , other ):
1437
1418
return self .requestServiceId == other .service and \
1438
- (self .negativeResponseCode != 0x78 or
1439
- conf .contribs ['UDS' ]['treat-response-pending-as-answer' ])
1419
+ (self .negativeResponseCode != 0x78 or
1420
+ conf .contribs ['UDS' ]['treat-response-pending-as-answer' ])
1440
1421
1441
1422
1442
1423
bind_layers (UDS , UDS_NR , service = 0x7f )
0 commit comments