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
19
+ FieldLenField , XStrFixedLenField , XStrLenField
20
20
from scapy .packet import Packet , bind_layers , NoPayload
21
21
from scapy .config import conf
22
22
from scapy .error import log_loading
@@ -491,7 +491,8 @@ class UDS_ATPPR(Packet):
491
491
492
492
def answers (self , other ):
493
493
return isinstance (other , UDS_ATP ) \
494
- and other .timingParameterAccessType == self .timingParameterAccessType
494
+ and other .timingParameterAccessType == \
495
+ self .timingParameterAccessType
495
496
496
497
497
498
bind_layers (UDS , UDS_ATPPR , service = 0xC3 )
@@ -955,39 +956,12 @@ class UDS_RDTCI(Packet):
955
956
20 : 'reportDTCFaultDetectionCounter' ,
956
957
21 : 'reportDTCWithPermanentStatus'
957
958
}
958
- dtcStatus = {
959
- 1 : 'TestFailed' ,
960
- 2 : 'TestFailedThisOperationCycle' ,
961
- 4 : 'PendingDTC' ,
962
- 8 : 'ConfirmedDTC' ,
963
- 16 : 'TestNotCompletedSinceLastClear' ,
964
- 32 : 'TestFailedSinceLastClear' ,
965
- 64 : 'TestNotCompletedThisOperationCycle' ,
966
- 128 : 'WarningIndicatorRequested'
967
- }
968
- dtcStatusMask = {
969
- 1 : 'ActiveDTCs' ,
970
- 4 : 'PendingDTCs' ,
971
- 8 : 'ConfirmedOrStoredDTCs' ,
972
- 255 : 'AllRecordDTCs'
973
- }
974
- dtcSeverityMask = {
975
- # 0: 'NoSeverityInformation',
976
- 1 : 'NoClassInformation' ,
977
- 2 : 'WWH-OBDClassA' ,
978
- 4 : 'WWH-OBDClassB1' ,
979
- 8 : 'WWH-OBDClassB2' ,
980
- 16 : 'WWH-OBDClassC' ,
981
- 32 : 'MaintenanceRequired' ,
982
- 64 : 'CheckAtNextHalt' ,
983
- 128 : 'CheckImmediately'
984
- }
985
959
name = 'ReadDTCInformation'
986
960
fields_desc = [
987
961
ByteEnumField ('reportType' , 0 , reportTypes ),
988
- ConditionalField (FlagsField ('DTCSeverityMask' , 0 , 8 , dtcSeverityMask ),
962
+ ConditionalField (ByteField ('DTCSeverityMask' , 0 ),
989
963
lambda pkt : pkt .reportType in [0x07 , 0x08 ]),
990
- ConditionalField (FlagsField ('DTCStatusMask' , 0 , 8 , dtcStatusMask ),
964
+ ConditionalField (XByteField ('DTCStatusMask' , 0 ),
991
965
lambda pkt : pkt .reportType in [
992
966
0x01 , 0x02 , 0x07 , 0x08 , 0x0f , 0x11 , 0x12 , 0x13 ]),
993
967
ConditionalField (ByteField ('DTCHighByte' , 0 ),
@@ -1009,28 +983,11 @@ class UDS_RDTCI(Packet):
1009
983
bind_layers (UDS , UDS_RDTCI , service = 0x19 )
1010
984
1011
985
1012
- class DTC (Packet ):
1013
- name = 'DTC and status record'
1014
- fields_desc = [
1015
- BitEnumField ("system" , 0 , 2 , {
1016
- 0 : "Powertrain" , 1 : "Chassis" , 2 : "Body" , 3 : "Network" }),
1017
- BitEnumField ("type" , 0 , 2 , {
1018
- 0 : "Generic" , 1 : "ManufacturerSpecific" , 2 : "Generic" , 3 : "Generic" }),
1019
- BitField ("numeric_value_code" , 0 , 12 ),
1020
- ByteField ("additional_information_code" , 0 ),
1021
- FlagsField ("status" , 0 , 8 , UDS_RDTCI .dtcStatus )
1022
- ]
1023
-
1024
- def extract_padding (self , s ):
1025
- return '' , s
1026
-
1027
-
1028
986
class UDS_RDTCIPR (Packet ):
1029
987
name = 'ReadDTCInformationPositiveResponse'
1030
988
fields_desc = [
1031
989
ByteEnumField ('reportType' , 0 , UDS_RDTCI .reportTypes ),
1032
- ConditionalField (FlagsField ('DTCStatusAvailabilityMask' , 0 , 8 ,
1033
- UDS_RDTCI .dtcStatus ),
990
+ ConditionalField (XByteField ('DTCStatusAvailabilityMask' , 0 ),
1034
991
lambda pkt : pkt .reportType in [0x01 , 0x07 , 0x11 ,
1035
992
0x12 , 0x02 , 0x0A ,
1036
993
0x0B , 0x0C , 0x0D ,
@@ -1046,7 +1003,7 @@ class UDS_RDTCIPR(Packet):
1046
1003
ConditionalField (ShortField ('DTCCount' , 0 ),
1047
1004
lambda pkt : pkt .reportType in [0x01 , 0x07 ,
1048
1005
0x11 , 0x12 ]),
1049
- ConditionalField (PacketListField ('DTCAndStatusRecord' , None , pkt_cls = DTC ),
1006
+ ConditionalField (StrField ('DTCAndStatusRecord' , b"" ),
1050
1007
lambda pkt : pkt .reportType in [0x02 , 0x0A , 0x0B ,
1051
1008
0x0C , 0x0D , 0x0E ,
1052
1009
0x0F , 0x13 , 0x15 ]),
@@ -1302,24 +1259,24 @@ def _contains_data_format_identifier(packet):
1302
1259
fmt = 'B' ),
1303
1260
lambda p : p .modeOfOperation != 2 ),
1304
1261
ConditionalField (StrLenField ('maxNumberOfBlockLength' , b"" ,
1305
- length_from = lambda p : p .lengthFormatIdentifier ),
1262
+ length_from = lambda p : p .lengthFormatIdentifier ),
1306
1263
lambda p : p .modeOfOperation != 2 ),
1307
1264
ConditionalField (BitField ('compressionMethod' , 0 , 4 ),
1308
1265
lambda p : p .modeOfOperation != 0x02 ),
1309
1266
ConditionalField (BitField ('encryptingMethod' , 0 , 4 ),
1310
1267
lambda p : p .modeOfOperation != 0x02 ),
1311
1268
ConditionalField (FieldLenField ('fileSizeOrDirInfoParameterLength' ,
1312
- None ,
1313
- length_of = 'fileSizeUncompressedOrDirInfoLength' ),
1269
+ None ,
1270
+ length_of = 'fileSizeUncompressedOrDirInfoLength' ),
1314
1271
lambda p : p .modeOfOperation not in [1 , 2 , 3 ]),
1315
1272
ConditionalField (StrLenField ('fileSizeUncompressedOrDirInfoLength' ,
1316
1273
b"" ,
1317
1274
length_from = lambda p :
1318
1275
p .fileSizeOrDirInfoParameterLength ),
1319
1276
lambda p : p .modeOfOperation not in [1 , 2 , 3 ]),
1320
1277
ConditionalField (StrLenField ('fileSizeCompressed' , b"" ,
1321
- length_from = lambda p :
1322
- p .fileSizeOrDirInfoParameterLength ),
1278
+ length_from = lambda p :
1279
+ p .fileSizeOrDirInfoParameterLength ),
1323
1280
lambda p : p .modeOfOperation not in [1 , 2 , 3 , 5 ]),
1324
1281
]
1325
1282
0 commit comments