Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ReadDTCInformation.Subfunction.reportDTCByStatusMask,
ReadDTCInformation.Subfunction.reportSupportedDTCs,
ReadDTCInformation.Subfunction.reportFirstTestFailedDTC,
ReadDTCInformation.Subfunction.reportFirstConfirmedDTC,
ReadDTCInformation.Subfunction.reportMostRecentTestFailedDTC,
ReadDTCInformation.Subfunction.reportMostRecentConfirmedDTC,
ReadDTCInformation.Subfunction.reportMirrorMemoryDTCByStatusMask,
ReadDTCInformation.Subfunction.reportEmissionsRelatedOBDDTCByStatusMask,
ReadDTCInformation.Subfunction.reportDTCWithPermanentStatus
]
response_subfn_number_of_dtc = [
ReadDTCInformation.Subfunction.reportNumberOfDTCByStatusMask,
ReadDTCInformation.Subfunction.reportNumberOfDTCBySeverityMaskRecord,
ReadDTCInformation.Subfunction.reportNumberOfMirrorMemoryDTCByStatusMask,
ReadDTCInformation.Subfunction.reportNumberOfEmissionsRelatedOBDDTCByStatusMask,
]
response_subfn_dtc_availability_mask_plus_dtc_record_with_severity = [
ReadDTCInformation.Subfunction.reportDTCBySeverityMaskRecord,
ReadDTCInformation.Subfunction.reportSeverityInformationOfDTC
]
response_subfn_dtc_plus_fault_counter = [
ReadDTCInformation.Subfunction.reportDTCFaultDetectionCounter
]
response_subfn_dtc_plus_sapshot_record = [
ReadDTCInformation.Subfunction.reportDTCSnapshotIdentification
]
response_sbfn_dtc_status_snapshots_records = [
ReadDTCInformation.Subfunction.reportFirstConfirmedDTC,
ReadDTCInformation.Subfunction.reportMostRecentTestFailedDTC,
ReadDTCInformation.Subfunction.reportMostRecentConfirmedDTC,
ReadDTCInformation.Subfunction.reportDTCFaultDetectionCounter,
ReadDTCInformation.Subfunction.reportDTCWithPermanentStatus,
# Documentation is confusing about reportDTCSnapshotIdentification subfunction.
# It is presented with reportDTCSnapshotRecordByDTCNumber (2 params) but a footnote says that these 2 parameters
# are not to be provided for reportDTCSnapshotIdentification. Therefore, it is the same as other no-params subfn
ReadDTCInformation.Subfunction.reportDTCSnapshotIdentification
]
request_subfn_status_mask = [
ReadDTCInformation.Subfunction.reportNumberOfDTCByStatusMask,
ReadDTCInformation.Subfunction.reportDTCByStatusMask,
ReadDTCInformation.Subfunction.reportMirrorMemoryDTCByStatusMask,
ReadDTCInformation.Subfunction.reportNumberOfMirrorMemoryDTCByStatusMask,
ReadDTCInformation.Subfunction.reportNumberOfEmissionsRelatedOBDDTCByStatusMask,
ReadDTCInformation.Subfunction.reportEmissionsRelatedOBDDTCByStatusMask
]
request_subfn_mask_record_plus_snapshot_record_number = [
ReadDTCInformation.Subfunction.reportDTCSnapshotRecordByDTCNumber
]
request_subfn_snapshot_record_number = [
ReadDTCInformation.Subfunction.reportDTCSnapshotRecordByRecordNumber
]
request_subfn_mask_record_plus_extdata_record_number = [
ReadDTCInformation.Subfunction.reportDTCExtendedDataRecordByDTCNumber,
:param snapshot_record_number: Snapshot record number
:type snapshot_record_number: int
:param extended_data_record_number: Extended data record number
:type extended_data_record_number: int
:raises ValueError: If parameters are out of range, missing or wrong type
"""
from udsoncan import Request, Dtc
# Request grouping for subfunctions that have the same request format
request_subfn_no_param = [
ReadDTCInformation.Subfunction.reportSupportedDTCs,
ReadDTCInformation.Subfunction.reportFirstTestFailedDTC,
ReadDTCInformation.Subfunction.reportFirstConfirmedDTC,
ReadDTCInformation.Subfunction.reportMostRecentTestFailedDTC,
ReadDTCInformation.Subfunction.reportMostRecentConfirmedDTC,
ReadDTCInformation.Subfunction.reportDTCFaultDetectionCounter,
ReadDTCInformation.Subfunction.reportDTCWithPermanentStatus,
# Documentation is confusing about reportDTCSnapshotIdentification subfunction.
# It is presented with reportDTCSnapshotRecordByDTCNumber (2 params) but a footnote says that these 2 parameters
# are not to be provided for reportDTCSnapshotIdentification. Therefore, it is the same as other no-params subfn
ReadDTCInformation.Subfunction.reportDTCSnapshotIdentification
]
request_subfn_status_mask = [
ReadDTCInformation.Subfunction.reportNumberOfDTCByStatusMask,
ReadDTCInformation.Subfunction.reportDTCByStatusMask,
:param snapshot_record_number: Snapshot record number
:type snapshot_record_number: int
:param extended_data_record_number: Extended data record number
:type extended_data_record_number: int
:raises ValueError: If parameters are out of range, missing or wrong type
"""
from udsoncan import Request, Dtc
# Request grouping for subfunctions that have the same request format
request_subfn_no_param = [
ReadDTCInformation.Subfunction.reportSupportedDTCs,
ReadDTCInformation.Subfunction.reportFirstTestFailedDTC,
ReadDTCInformation.Subfunction.reportFirstConfirmedDTC,
ReadDTCInformation.Subfunction.reportMostRecentTestFailedDTC,
ReadDTCInformation.Subfunction.reportMostRecentConfirmedDTC,
ReadDTCInformation.Subfunction.reportDTCFaultDetectionCounter,
ReadDTCInformation.Subfunction.reportDTCWithPermanentStatus,
# Documentation is confusing about reportDTCSnapshotIdentification subfunction.
# It is presented with reportDTCSnapshotRecordByDTCNumber (2 params) but a footnote says that these 2 parameters
# are not to be provided for reportDTCSnapshotIdentification. Therefore, it is the same as other no-params subfn
ReadDTCInformation.Subfunction.reportDTCSnapshotIdentification
]
request_subfn_status_mask = [
ReadDTCInformation.Subfunction.reportNumberOfDTCByStatusMask,
ReadDTCInformation.Subfunction.reportDTCByStatusMask,
ReadDTCInformation.Subfunction.reportMirrorMemoryDTCByStatusMask,
request_subfn_mask_record_plus_snapshot_record_number = [
ReadDTCInformation.Subfunction.reportDTCSnapshotRecordByDTCNumber
]
request_subfn_snapshot_record_number = [
ReadDTCInformation.Subfunction.reportDTCSnapshotRecordByRecordNumber
]
request_subfn_mask_record_plus_extdata_record_number = [
ReadDTCInformation.Subfunction.reportDTCExtendedDataRecordByDTCNumber,
ReadDTCInformation.Subfunction.reportMirrorMemoryDTCExtendedDataRecordByDTCNumber
]
request_subfn_severity_plus_status_mask = [
ReadDTCInformation.Subfunction.reportNumberOfDTCBySeverityMaskRecord,
ReadDTCInformation.Subfunction.reportDTCBySeverityMaskRecord
]
request_subfn_mask_record = [
ReadDTCInformation.Subfunction.reportSeverityInformationOfDTC
]
ServiceHelper.validate_int(subfunction, min=1, max=0x15, name='Subfunction')
if status_mask is not None and isinstance(status_mask, Dtc.Status):
status_mask = status_mask.get_byte_as_int()
if severity_mask is not None and isinstance(severity_mask, Dtc.Severity):
severity_mask = severity_mask.get_byte_as_int()
ReadDTCInformation.Subfunction.reportNumberOfMirrorMemoryDTCByStatusMask,
ReadDTCInformation.Subfunction.reportNumberOfEmissionsRelatedOBDDTCByStatusMask,
ReadDTCInformation.Subfunction.reportEmissionsRelatedOBDDTCByStatusMask
]
request_subfn_mask_record_plus_snapshot_record_number = [
ReadDTCInformation.Subfunction.reportDTCSnapshotRecordByDTCNumber
]
request_subfn_snapshot_record_number = [
ReadDTCInformation.Subfunction.reportDTCSnapshotRecordByRecordNumber
]
request_subfn_mask_record_plus_extdata_record_number = [
ReadDTCInformation.Subfunction.reportDTCExtendedDataRecordByDTCNumber,
ReadDTCInformation.Subfunction.reportMirrorMemoryDTCExtendedDataRecordByDTCNumber
]
request_subfn_severity_plus_status_mask = [
ReadDTCInformation.Subfunction.reportNumberOfDTCBySeverityMaskRecord,
ReadDTCInformation.Subfunction.reportDTCBySeverityMaskRecord
]
request_subfn_mask_record = [
ReadDTCInformation.Subfunction.reportSeverityInformationOfDTC
]
ServiceHelper.validate_int(subfunction, min=1, max=0x15, name='Subfunction')
if status_mask is not None and isinstance(status_mask, Dtc.Status):
status_mask = status_mask.get_byte_as_int()
request_subfn_mask_record_plus_snapshot_record_number = [
ReadDTCInformation.Subfunction.reportDTCSnapshotRecordByDTCNumber
]
request_subfn_snapshot_record_number = [
ReadDTCInformation.Subfunction.reportDTCSnapshotRecordByRecordNumber
]
request_subfn_mask_record_plus_extdata_record_number = [
ReadDTCInformation.Subfunction.reportDTCExtendedDataRecordByDTCNumber,
ReadDTCInformation.Subfunction.reportMirrorMemoryDTCExtendedDataRecordByDTCNumber
]
request_subfn_severity_plus_status_mask = [
ReadDTCInformation.Subfunction.reportNumberOfDTCBySeverityMaskRecord,
ReadDTCInformation.Subfunction.reportDTCBySeverityMaskRecord
]
request_subfn_mask_record = [
ReadDTCInformation.Subfunction.reportSeverityInformationOfDTC
]
ServiceHelper.validate_int(subfunction, min=1, max=0x15, name='Subfunction')
if status_mask is not None and isinstance(status_mask, Dtc.Status):
status_mask = status_mask.get_byte_as_int()
if severity_mask is not None and isinstance(severity_mask, Dtc.Severity):
severity_mask = severity_mask.get_byte_as_int()
if dtc is not None and isinstance(dtc, Dtc):
"""
from udsoncan import Dtc, DidCodec
ServiceHelper.validate_int(subfunction, min=1, max=0x15, name='Subfunction')
# Response grouping for responses that are encoded the same way
response_subfn_dtc_availability_mask_plus_dtc_record = [
ReadDTCInformation.Subfunction.reportDTCByStatusMask,
ReadDTCInformation.Subfunction.reportSupportedDTCs,
ReadDTCInformation.Subfunction.reportFirstTestFailedDTC,
ReadDTCInformation.Subfunction.reportFirstConfirmedDTC,
ReadDTCInformation.Subfunction.reportMostRecentTestFailedDTC,
ReadDTCInformation.Subfunction.reportMostRecentConfirmedDTC,
ReadDTCInformation.Subfunction.reportMirrorMemoryDTCByStatusMask,
ReadDTCInformation.Subfunction.reportEmissionsRelatedOBDDTCByStatusMask,
ReadDTCInformation.Subfunction.reportDTCWithPermanentStatus
]
response_subfn_number_of_dtc = [
ReadDTCInformation.Subfunction.reportNumberOfDTCByStatusMask,
ReadDTCInformation.Subfunction.reportNumberOfDTCBySeverityMaskRecord,
ReadDTCInformation.Subfunction.reportNumberOfMirrorMemoryDTCByStatusMask,
ReadDTCInformation.Subfunction.reportNumberOfEmissionsRelatedOBDDTCByStatusMask,
]
response_subfn_dtc_availability_mask_plus_dtc_record_with_severity = [
ReadDTCInformation.Subfunction.reportDTCBySeverityMaskRecord,
ReadDTCInformation.Subfunction.reportSeverityInformationOfDTC
]
response_subfn_dtc_plus_fault_counter = [
ReadDTCInformation.Subfunction.reportDTCFaultDetectionCounter
]
response_subfn_dtc_plus_fault_counter = [
ReadDTCInformation.Subfunction.reportDTCFaultDetectionCounter
]
response_subfn_dtc_plus_sapshot_record = [
ReadDTCInformation.Subfunction.reportDTCSnapshotIdentification
]
response_sbfn_dtc_status_snapshots_records = [
ReadDTCInformation.Subfunction.reportDTCSnapshotRecordByDTCNumber
]
response_sbfn_dtc_status_snapshots_records_record_first = [
ReadDTCInformation.Subfunction.reportDTCSnapshotRecordByRecordNumber
]
response_subfn_mask_record_plus_extdata = [
ReadDTCInformation.Subfunction.reportDTCExtendedDataRecordByDTCNumber,
ReadDTCInformation.Subfunction.reportMirrorMemoryDTCExtendedDataRecordByDTCNumber
]
response.service_data = cls.ResponseData() # what will be returned
if len(response.data) < 1:
raise InvalidResponseException(response, 'Response must be at least 1 byte long (echo of subfunction)')
response.service_data.subfunction_echo = response.data[0] # First byte is subfunction
# Now for each response group, we have a different decoding algorithm
]
response_subfn_number_of_dtc = [
ReadDTCInformation.Subfunction.reportNumberOfDTCByStatusMask,
ReadDTCInformation.Subfunction.reportNumberOfDTCBySeverityMaskRecord,
ReadDTCInformation.Subfunction.reportNumberOfMirrorMemoryDTCByStatusMask,
ReadDTCInformation.Subfunction.reportNumberOfEmissionsRelatedOBDDTCByStatusMask,
]
response_subfn_dtc_availability_mask_plus_dtc_record_with_severity = [
ReadDTCInformation.Subfunction.reportDTCBySeverityMaskRecord,
ReadDTCInformation.Subfunction.reportSeverityInformationOfDTC
]
response_subfn_dtc_plus_fault_counter = [
ReadDTCInformation.Subfunction.reportDTCFaultDetectionCounter
]
response_subfn_dtc_plus_sapshot_record = [
ReadDTCInformation.Subfunction.reportDTCSnapshotIdentification
]
response_sbfn_dtc_status_snapshots_records = [
ReadDTCInformation.Subfunction.reportDTCSnapshotRecordByDTCNumber
]
response_sbfn_dtc_status_snapshots_records_record_first = [
ReadDTCInformation.Subfunction.reportDTCSnapshotRecordByRecordNumber
]
response_subfn_mask_record_plus_extdata = [
ReadDTCInformation.Subfunction.reportDTCExtendedDataRecordByDTCNumber,