Services¶
Each service is represented by a class that extends the BaseService
class. They all implement 2 methods : make_request
and interpret_response
.
make_request
will return aRequest
instance ready to be sent to theConnection
interpret_response
will parse thedata
property inside aResponse
instance and populate another property namedservice_data
. Thisservice_data
property will be an instance of theResponseData
class that is nested within the service class.
Crafting a request
req = SomeService.make_request(param1, param2)
my_connection.send(req.get_payload())
Parsing a response
payload = my_connection.wait_frame(timeout=1)
response = Response.from_payload(payload)
print('Raw data : %s' % response.data)
SomeService.interpret_response(response, param1, param2)
print('Interpreted data : field1 : %s, field2 : %s' % (response.service_data.field1, response.service_data.field2))
AccessTimingParameter (0x83)¶
-
classmethod
AccessTimingParameter.
make_request
(access_type: int, timing_param_record: typing.Union[bytes, NoneType] = None) → udsoncan.Request.Request[source]¶ Generates a request for AccessTimingParameter
Parameters: - access_type (int) – Service subfunction. Allowed values are from 0 to 0x7F
- timing_param_record (bytes) – Data associated with request. Must be present only when access_type=``AccessType.setTimingParametersToGivenValues`` (4)
Raises: ValueError – If parameters are out of range, missing or wrong type
-
classmethod
AccessTimingParameter.
interpret_response
(response: udsoncan.Response.Response) → udsoncan.services.AccessTimingParameter.AccessTimingParameter.InterpretedResponse[source]¶ Populates the response
service_data
property with an instance ofAccessTimingParameter.ResponseData
Parameters: response (Response) – The received response to interpret Raises: InvalidResponseException – If length of response.data
is too short
-
class
AccessTimingParameter.
ResponseData
(access_type_echo: int, timing_param_record: bytes)[source]¶ -
access_type_echo
¶ Request subfunction echoed back by the server
-
timing_param_record
¶ Additional data associated with the response.
-
-
class
AccessTimingParameter.
AccessType
[source]¶ AccessTimingParameter defined subfunctions
-
readCurrentlyActiveTimingParameters
= 3¶
-
readExtendedTimingParameterSet
= 1¶
-
setTimingParametersToDefaultValues
= 2¶
-
setTimingParametersToGivenValues
= 4¶
-
ClearDiagnosticInformation (0x14)¶
-
classmethod
ClearDiagnosticInformation.
make_request
(group: int = 16777215, memory_selection: typing.Union[int, NoneType] = None, standard_version: int = 2020) → udsoncan.Request.Request[source]¶ Generates a request for ClearDiagnosticInformation
Parameters: group (int) – DTC mask ranging from 0 to 0xFFFFFF. 0xFFFFFF means all DTCs Raises: ValueError – If parameters are out of range, missing or wrong type
-
classmethod
ClearDiagnosticInformation.
interpret_response
(response: udsoncan.Response.Response) → udsoncan.services.ClearDiagnosticInformation.ClearDiagnosticInformation.InterpretedResponse[source]¶ Populates the response
service_data
property with an instance ofClearDiagnosticInformation.ResponseData
Parameters: response (Response) – The received response to interpret
Note
This service have empty response data
Note
This service does not have subfunctions
CommunicationControl (0x28)¶
-
classmethod
CommunicationControl.
make_request
(control_type: int, communication_type: udsoncan.common.CommunicationType.CommunicationType) → udsoncan.Request.Request[source]¶ Generates a request for CommunicationControl
Parameters: - control_type (int) – Service subfunction. Allowed values are from 0 to 0x7F
- communication_type (CommunicationType, int, bytes) – The communication type requested.
Raises: ValueError – If parameters are out of range, missing or wrong type
-
classmethod
CommunicationControl.
interpret_response
(response: udsoncan.Response.Response) → udsoncan.services.CommunicationControl.CommunicationControl.InterpretedResponse[source]¶ Populates the response
service_data
property with an instance ofCommunicationControl.ResponseData
Parameters: response (Response) – The received response to interpret Raises: InvalidResponseException – If length of response.data
is too short
-
class
CommunicationControl.
ResponseData
(control_type_echo: int)[source]¶ -
control_type_echo
¶ Request subfunction echoed back by the server
-
-
class
CommunicationControl.
ControlType
[source]¶ CommunicationControl defined subfunctions
-
disableRxAndEnableTx
= 2¶
-
disableRxAndTx
= 3¶
-
enableRxAndDisableTx
= 1¶
-
enableRxAndTx
= 0¶
-
ControlDTCSetting (0x85)¶
-
classmethod
ControlDTCSetting.
make_request
(setting_type: int, data: typing.Union[bytes, NoneType] = None) → udsoncan.Request.Request[source]¶ Generates a request for ControlDTCSetting
Parameters: - setting_type (int) – Service subfunction. Allowed values are from 0 to 0x7F
- data (bytes) – Optional additional data sent with the request called DTCSettingControlOptionRecord
Raises: ValueError – If parameters are out of range, missing or wrong type
-
classmethod
ControlDTCSetting.
interpret_response
(response: udsoncan.Response.Response) → udsoncan.services.ControlDTCSetting.ControlDTCSetting.InterpretedResponse[source]¶ Populates the response
service_data
property with an instance ofControlDTCSetting.ResponseData
Parameters: response (Response) – The received response to interpret Raises: InvalidResponseException – If length of response.data
is too short
-
class
ControlDTCSetting.
ResponseData
(setting_type_echo: int)[source]¶ -
setting_type_echo
¶ Request subfunction echoed back by the server
-
-
class
ControlDTCSetting.
SettingType
[source]¶ ControlDTCSetting defined subfunctions
-
off
= 2¶
-
on
= 1¶
-
DiagnosticSessionControl (0x10)¶
-
classmethod
DiagnosticSessionControl.
make_request
(session: int) → udsoncan.Request.Request[source]¶ Generates a request for DiagnosticSessionControl service
Parameters: session (int) – Service subfunction. Allowed values are from 0 to 0x7F Raises: ValueError – If parameters are out of range, missing or wrong type
-
classmethod
DiagnosticSessionControl.
interpret_response
(response: udsoncan.Response.Response, standard_version: int = 2020) → udsoncan.services.DiagnosticSessionControl.DiagnosticSessionControl.InterpretedResponse[source]¶ Populates the response
service_data
property with an instance ofDiagnosticSessionControl.ResponseData
Parameters: response (Response) – The received response to interpret Raises: InvalidResponseException – If length of response.data
is too short
-
class
DiagnosticSessionControl.
ResponseData
(session_echo: int, session_param_records: bytes, p2_server_max: typing.Union[float, NoneType] = None, p2_star_server_max: typing.Union[float, NoneType] = None)[source]¶ -
session_echo
¶ Request subfunction echoed back by the server
-
session_param_records
¶ Raw session parameter records. Data given by the server. For 2006 configurations, this data can is manufacturer specific. For 2013 version and above, this data correspond to P2 and P2* timing requirement.
-
p2_server_max
¶ Default P2 max timing supported by the server for the activated diagnostic session. Applicable for 2013 version and above. Value in seconds.
-
p2_star_server_max
¶ Default P2* (NRC 0x78) max timing supported by the server for the activated diagnostic session. Applicable for 2013 version and above. Value in seconds
-
-
class
DiagnosticSessionControl.
Session
[source]¶ DiagnosticSessionControl defined subfunctions
-
defaultSession
= 1¶
-
extendedDiagnosticSession
= 3¶
-
programmingSession
= 2¶
-
safetySystemDiagnosticSession
= 4¶
-
ECUReset (0x11)¶
-
classmethod
ECUReset.
make_request
(reset_type: int) → udsoncan.Request.Request[source]¶ Generates a request for ECUReset
Parameters: reset_type (int) – Service subfunction. Allowed values are from 0 to 0x7F Raises: ValueError – If parameters are out of range, missing or wrong type
-
classmethod
ECUReset.
interpret_response
(response: udsoncan.Response.Response) → udsoncan.services.ECUReset.ECUReset.InterpretedResponse[source]¶ Populates the response
service_data
property with an instance ofECUReset.ResponseData
Parameters: response (Response) – The received response to interpret Raises: InvalidResponseException – If length of response.data
is too short
-
class
ECUReset.
ResponseData
(reset_type_echo: int, powerdown_time: typing.Union[int, NoneType] = None)[source]¶ -
reset_type_echo
¶ Request subfunction echoed back by the server
-
powerdown_time
¶ Amount of time, in seconds, before the power down sequence is executed. Should be provided only when reset type is enableRapidPowerShutDown
-
-
class
ECUReset.
ResetType
[source]¶ ECUReset defined subfunctions
-
disableRapidPowerShutDown
= 5¶
-
enableRapidPowerShutDown
= 4¶
-
hardReset
= 1¶
-
keyOffOnReset
= 2¶
-
softReset
= 3¶
-
InputOutputControlByIdentifier (0x2F)¶
-
classmethod
InputOutputControlByIdentifier.
make_request
(did: int, control_param: typing.Union[int, NoneType] = None, values: typing.Union[typing.List[typing.Any], typing.Dict[str, typing.Any], udsoncan.common.IOControls.IOValues, NoneType] = None, masks: typing.Union[typing.List[str], typing.Dict[str, bool], udsoncan.common.IOControls.IOMasks, bool, NoneType] = None, ioconfig: typing.Union[typing.Dict[int, typing.Union[udsoncan.typing.IOConfigEntry, str, udsoncan.common.DidCodec.DidCodec, typing.Type[udsoncan.common.DidCodec.DidCodec]]], NoneType] = None) → udsoncan.Request.Request[source]¶ Generates a request for InputOutputControlByIdentifier
Parameters: - did (int) – Data identifier to represent the IO
- control_param (int) – Optional parameter that can be a value defined in
InputOutputControlByIdentifier.ControlParam
- values (list, dict, IOValues) –
Optional values to send to the server. This parameter will be given to DidCodec.encode() method. It can be:
- A list for positional arguments
- A dict for named arguments
- An instance of IOValues for mixed arguments
- masks (list, dict, IOMask, bool) –
Optional mask record for composite values. The mask definition must be included in
ioconfig
It can be:- A list naming the bit mask to set
- A dict with the mask name as a key and a boolean as the value (True to set the mask, False to clear it)
- An instance of IOMask
- A boolean value to set all masks to the same value.
- ioconfig (dict[int] = DidCodec, dict) – Definition of DID codecs. Dictionary mapping a DID (int) to a valid DidCodec class or pack/unpack string. It is possible to use composite DidCodec by specifying a dict with entries : codec, mask, mask_size.
Raises: - ValueError – If parameters are out of range, missing or wrong type
- ConfigError – If given DID is not defined within ioconfig
-
classmethod
InputOutputControlByIdentifier.
interpret_response
(response: udsoncan.Response.Response, control_param: typing.Union[int, NoneType] = None, tolerate_zero_padding: bool = True, ioconfig: typing.Union[typing.Dict[int, typing.Union[udsoncan.typing.IOConfigEntry, str, udsoncan.common.DidCodec.DidCodec, typing.Type[udsoncan.common.DidCodec.DidCodec]]], NoneType] = None) → udsoncan.services.InputOutputControlByIdentifier.InputOutputControlByIdentifier.InterpretedResponse[source]¶ Populates the response
service_data
property with an instance ofInputOutputControlByIdentifier.ResponseData
Parameters: - response (Response) – The received response to interpret
- control_param (int) – Same optional control parameter value given to make_request()
- tolerate_zero_padding (bool) – Ignore trailing zeros in the response data avoiding raising false
InvalidResponseException
. - ioconfig (dict[int] = DidCodec, dict) – Definition of DID codecs. Dictionary mapping a DID (int) to a valid DidCodec class or pack/unpack string. It is possible to use composite DidCodec by specifying a dict with entries : codec, mask, mask_size.
Raises: - ValueError – If parameters are out of range, missing or wrong type
- ConfigError – If DID echoed back by the server is not in the
ioconfig
definition - InvalidResponseException – If response data is incomplete or if DID data does not match codec length.
-
class
InputOutputControlByIdentifier.
ResponseData
(did_echo: int, control_param_echo: typing.Union[int, NoneType] = None, decoded_data: typing.Union[typing.Any, NoneType] = None)[source]¶ -
did_echo
¶ DID echoed back by the server
-
control_param_echo
¶ control_param echoed back by the server
-
Note
This service does not have subfunctions
LinkControl (0x87)¶
-
classmethod
LinkControl.
make_request
(control_type: int, baudrate: typing.Union[udsoncan.common.Baudrate.Baudrate, NoneType] = None) → udsoncan.Request.Request[source]¶ Generates a request for LinkControl
Parameters: - control_type (int) – Service subfunction. Allowed values are from 0 to 0x7F
- baudrate (Baudrate) – Required baudrate value when
control_type
is eitherverifyBaudrateTransitionWithFixedBaudrate
(1) orverifyBaudrateTransitionWithSpecificBaudrate
(2)
Raises: ValueError – If parameters are out of range, missing or wrong type
-
classmethod
LinkControl.
interpret_response
(response: udsoncan.Response.Response) → udsoncan.services.LinkControl.LinkControl.InterpretedResponse[source]¶ Populates the response
service_data
property with an instance ofLinkControl.ResponseData
Parameters: response (Response) – The received response to interpret Raises: InvalidResponseException – If length of response.data
is too short
-
class
LinkControl.
ResponseData
(control_type_echo: int)[source]¶ -
control_type_echo
¶ Request subfunction echoed back by the server
-
-
class
LinkControl.
ControlType
[source]¶ LinkControl defined subfunctions
-
transitionBaudrate
= 3¶
-
verifyBaudrateTransitionWithFixedBaudrate
= 1¶
-
verifyBaudrateTransitionWithSpecificBaudrate
= 2¶
-
ReadDataByIdentifier (0x22)¶
-
classmethod
ReadDataByIdentifier.
make_request
(didlist: typing.Union[int, typing.List[int]], didconfig: typing.Dict[int, typing.Union[str, udsoncan.common.DidCodec.DidCodec, typing.Type[udsoncan.common.DidCodec.DidCodec]]]) → udsoncan.Request.Request[source]¶ Generates a request for ReadDataByIdentifier
Parameters: Raises: - ValueError – If parameters are out of range, missing or wrong type
- ConfigError – If didlist contains a DID not defined in didconfig
-
classmethod
ReadDataByIdentifier.
interpret_response
(response: udsoncan.Response.Response, didlist: typing.Union[int, typing.List[int]], didconfig: typing.Dict[int, typing.Union[str, udsoncan.common.DidCodec.DidCodec, typing.Type[udsoncan.common.DidCodec.DidCodec]]], tolerate_zero_padding: bool = True) → udsoncan.services.ReadDataByIdentifier.ReadDataByIdentifier.InterpretedResponse[source]¶ Populates the response
service_data
property with an instance ofReadDataByIdentifier.ResponseData
Parameters: - response (Response) – The received response to interpret
- didlist (list[int]) – List of data identifiers used for the request.
- didconfig (dict[int] = DidCodec) – Definition of DID codecs. Dictionary mapping a DID (int) to a valid DidCodec class or pack/unpack string
- tolerate_zero_padding (bool) – Ignore trailing zeros in the response data avoiding raising false
InvalidResponseException
.
Raises: - ValueError – If parameters are out of range, missing or wrong type
- ConfigError – If
didlist
parameter or response contains a DID not defined indidconfig
. - InvalidResponseException – If response data is incomplete or if DID data does not match codec length.
Note
This service does not have subfunctions
Example of DidConfig
didconfig = {
0x1111 : '<H', # Strings are processed by struct.unpack
0x2222 : MyCustomDidCodec, # Inherits the udsoncan.DidCodec,
0x3333 : MyCustomDidCodec(param1='hello') # Instance can also be provided
0x4444 : dict(key1='val1', key2='val2', codec=MyCustomDidCodec} # If dict is given, a key named "codec" will be searched for
}
RequestFileTransfer (0x38)¶
-
classmethod
RequestFileTransfer.
make_request
(moop: int, path: str, dfi: typing.Union[udsoncan.common.DataFormatIdentifier.DataFormatIdentifier, NoneType] = None, filesize: typing.Union[udsoncan.common.Filesize.Filesize, int, NoneType] = None) → udsoncan.Request.Request[source]¶ Generates a request for RequestFileTransfer
Parameters: - moop (int) – Mode of operation. Can be AddFile(1), DeleteFile(2), ReplaceFile(3), ReadFile(4), ReadDir(5), ResumeFile(6). See
RequestFileTransfer.ModeOfOperation
- path (string) – String representing the path to the target file or directory.
- dfi (DataFormatIdentifier) – DataFormatIdentifier defining the compression and encryption scheme of the data.
If not specified, the default value of 00 will be used, specifying no encryption and no compression.
This value is only used when ModeOfOperation is :
AddFile
,ReplaceFile
,ReadFile
,ResumeFile
- filesize (Filesize or int) – The filesize of the file to write when ModeOfOperation is
AddFile
,ReplaceFile
orResumeFile
. If filesize is an object of type Filesize, the uncompressed size and compressed size will be encoded on the minimum amount of bytes necessary, unless awidth
is explicitly defined. If no compressed size is given or filesize is anint
, then the compressed size will be set equal to the uncompressed size or the integer value given as specified by ISO-14229
Raises: ValueError – If parameters are out of range, missing or wrong type
- moop (int) – Mode of operation. Can be AddFile(1), DeleteFile(2), ReplaceFile(3), ReadFile(4), ReadDir(5), ResumeFile(6). See
-
classmethod
RequestFileTransfer.
interpret_response
(response: udsoncan.Response.Response, tolerate_zero_padding: bool = True) → udsoncan.services.RequestFileTransfer.RequestFileTransfer.InterpretedResponse[source]¶ Populates the response
service_data
property with an instance ofRequestFileTransfer.ResponseData
Parameters: response (Response) – The received response to interpret
Raises: - InvalidResponseException – If length of
response.data
is too short or payload does not respect ISO-14229 specifications - NotImplementedError – If the MaxNumberOfBlock or fileSizeUncompressedOrDirInfoLength value is encoded over more than 8 bytes.
- InvalidResponseException – If length of
-
class
RequestFileTransfer.
ResponseData
(moop_echo: int, max_length: typing.Union[int, NoneType] = None, dfi: typing.Union[udsoncan.common.DataFormatIdentifier.DataFormatIdentifier, NoneType] = None, filesize: typing.Union[udsoncan.common.Filesize.Filesize, NoneType] = None, dirinfo_length: typing.Union[int, NoneType] = None, fileposition: typing.Union[int, NoneType] = None)[source]¶ -
moop_echo
(int)¶ Request ModeOfOperation echoed back by the server
-
max_length
(int)¶ The MaxNumberOfBlockLength returned by the server. Represent the number of data bytes that should be included in each subsequent TransferData request excepted the last one that might be smaller.
Not set for a response to
DeleteFile
.
-
dfi
(DataFormatIdentifier)¶ Request DataFormatIdentifier echoed back by the server.
Not set for a response to
DeleteFile
. Set to Compression=0, Encryption=0, when getting a response forReadDir
as specified by ISO-14229.
-
filesize
(Filesize)¶ Defines the size fo the file to be read in bytes, including its uncompressed and compressed size.
Only set when performing a
ReadFile
request
-
dirinfo_length
(int)¶ Defines the size of the directory information to be read in bytes.
Only set when performing a
ReadDir
request
-
fileposition
(int)¶ Defines the position of the at which the tester will resume downloading after an initial download is suspended.
Only set when performing a
ResumeFile
request
-
Note
This service does not have subfunctions
ReadDTCInformation (0x19)¶
-
classmethod
ReadDTCInformation.
make_request
(subfunction: int, status_mask: typing.Union[int, udsoncan.common.dtc.Dtc.Status, NoneType] = None, severity_mask: typing.Union[int, udsoncan.common.dtc.Dtc.Severity, NoneType] = None, dtc: typing.Union[int, udsoncan.common.dtc.Dtc, NoneType] = None, snapshot_record_number: typing.Union[int, NoneType] = None, extended_data_record_number: typing.Union[int, NoneType] = None, memory_selection: typing.Union[int, NoneType] = None, standard_version: int = 2020) → udsoncan.Request.Request[source]¶ Generates a request for ReadDTCInformation. Each subfunction uses a subset of parameters.
Parameters: - subfunction (int) – The service subfunction. Values are defined in
ReadDTCInformation.Subfunction
- status_mask (int or Dtc.Status) – A DTC status mask used to filter DTC
- severity_mask (int or Dtc.Severity) – A severity mask used to filter DTC
- dtc (int or Dtc) – A DTC mask used to filter DTC
- snapshot_record_number (int) – Snapshot record number
- extended_data_record_number (int) – Extended data record number
- memory_selection (int) – Memory selection for user defined memory DTC
Raises: ValueError – If parameters are out of range, missing or wrong type
- subfunction (int) – The service subfunction. Values are defined in
-
classmethod
ReadDTCInformation.
interpret_response
(response: udsoncan.Response.Response, subfunction: int, extended_data_size: typing.Union[int, typing.Dict[int, int], NoneType] = None, tolerate_zero_padding: bool = True, ignore_all_zero_dtc: bool = True, dtc_snapshot_did_size: int = 2, didconfig: typing.Union[typing.Dict[int, typing.Union[str, udsoncan.common.DidCodec.DidCodec, typing.Type[udsoncan.common.DidCodec.DidCodec]]], NoneType] = None, standard_version: int = 2020) → udsoncan.services.ReadDTCInformation.ReadDTCInformation.InterpretedResponse[source]¶ Populates the response
service_data
property with an instance ofReadDTCInformation.ResponseData
Parameters: - response (Response) – The received response to interpret
- subfunction (int) – The service subfunction. Values are defined in
ReadDTCInformation.Subfunction
- extended_data_size (int or dict[int, int] to specify a size per extended data ID) – Extended data size to expect. Extended data is implementation specific, therefore, size is not standardized
- tolerate_zero_padding (bool) – Ignore trailing zeros in the response data avoiding raising false
InvalidResponseException
. - ignore_all_zero_dtc (bool) – Discard any DTC entries that have an ID of 0. Avoid reading extra DTCs when using a transport protocol using zero padding.
- dtc_snapshot_did_size (int) – Number of bytes to encode the data identifier number. Other services such as ReadDataByIdentifier encode DID over 2 bytes. UDS standard does not define the size of the snapshot DID, therefore, it must be supplied.
- didconfig (dict[int] = DidCodec) – Definition of DID codecs. Dictionary mapping a DID (int) to a valid DidCodec class or pack/unpack string
Raises: - InvalidResponseException – If response length is wrong or does not match DID configuration
- ValueError – If parameters are out of range, missing or wrong types
- ConfigError – If the server returns a snapshot DID not defined in
didconfig
-
class
ReadDTCInformation.
ResponseData
(subfunction_echo: int, dtcs: typing.Union[typing.List[udsoncan.common.dtc.Dtc], NoneType] = None, dtc_count: typing.Union[int, NoneType] = None, dtc_format: typing.Union[int, NoneType] = None, status_availability: typing.Union[udsoncan.common.dtc.Dtc.Status, NoneType] = None, extended_data: typing.Union[typing.List[bytes], NoneType] = [], memory_selection_echo: typing.Union[int, NoneType] = None)[source]¶ -
subfunction_echo
¶ Subfunction echoed back by the server
-
dtc_count
¶ Number of DTC read or available
-
dtc_format
¶ Integer indicating the format of the DTC. See DTC.Format
-
status_availability
¶ Dtc.Status indicating which status the server supports
-
extended_data
¶ List of bytes containing the DTC extended data
-
memory_selection_echo
¶ Echo of the memory selection byte
-
-
class
ReadDTCInformation.
Subfunction
[source]¶ -
reportDTCBySeverityMaskRecord
= 8¶
-
reportDTCByStatusMask
= 2¶
-
reportDTCExtDataRecordByRecordNumber
= 22¶
-
reportDTCExtendedDataRecordByDTCNumber
= 6¶
-
reportDTCFaultDetectionCounter
= 20¶
-
reportDTCInformationByDTCReadinessGroupIdentifier
= 86¶
-
reportDTCSnapshotIdentification
= 3¶
-
reportDTCSnapshotRecordByDTCNumber
= 4¶
-
reportDTCSnapshotRecordByRecordNumber
= 5¶
-
reportDTCWithPermanentStatus
= 21¶
-
reportEmissionsRelatedOBDDTCByStatusMask
= 19¶
-
reportFirstConfirmedDTC
= 12¶
-
reportFirstTestFailedDTC
= 11¶
-
reportMirrorMemoryDTCByStatusMask
= 15¶
-
reportMirrorMemoryDTCExtendedDataRecordByDTCNumber
= 16¶
-
reportMostRecentConfirmedDTC
= 14¶
-
reportMostRecentTestFailedDTC
= 13¶
-
reportNumberOfDTCBySeverityMaskRecord
= 7¶
-
reportNumberOfDTCByStatusMask
= 1¶
-
reportNumberOfEmissionsRelatedOBDDTCByStatusMask
= 18¶
-
reportNumberOfMirrorMemoryDTCByStatusMask
= 17¶
-
reportSeverityInformationOfDTC
= 9¶
-
reportSupportedDTCExtDataRecord
= 26¶
-
reportSupportedDTCs
= 10¶
-
reportUserDefMemoryDTCByStatusMask
= 23¶
-
reportUserDefMemoryDTCExtDataRecordByDTCNumber
= 25¶
-
reportUserDefMemoryDTCSnapshotRecordByDTCNumber
= 24¶
-
reportWWHOBDDTCByMaskRecord
= 66¶
-
reportWWHOBDDTCWithPermanentStatus
= 85¶
-
make_request() parameters per subfunction¶
subfunction | status_mask | severity_mask | dtc | snapshot_record_number | extended_data_record_number |
---|---|---|---|---|---|
reportNumberOfDTCByStatusMask | Yes | ||||
reportDTCByStatusMask | Yes | ||||
reportDTCSnapshotIdentification | |||||
reportDTCSnapshotRecordByDTCNumber | Yes | Yes | |||
reportDTCSnapshotRecordByRecordNumber | Yes | ||||
reportDTCExtendedDataRecordByDTCNumber | Yes | Yes | |||
reportNumberOfDTCBySeverityMaskRecord | Yes | Yes | |||
reportDTCBySeverityMaskRecord | Yes | Yes | |||
reportSeverityInformationOfDTC | Yes | Yes | |||
reportSupportedDTCs | |||||
reportFirstTestFailedDTC | |||||
reportFirstConfirmedDTC | |||||
reportMostRecentTestFailedDTC | |||||
reportMostRecentConfirmedDTC | |||||
reportMirrorMemoryDTCByStatusMask | Yes | ||||
reportMirrorMemoryDTCExtendedDataRecordByDTCNumber | Yes | Yes | |||
reportNumberOfMirrorMemoryDTCByStatusMask | Yes | ||||
reportNumberOfEmissionsRelatedOBDDTCByStatusMask | Yes | ||||
reportEmissionsRelatedOBDDTCByStatusMask | Yes | ||||
reportDTCFaultDetectionCounter | |||||
reportDTCWithPermanentStatus |
interpret_response() parameters per subfunction¶
subfunction | extended_data_size | tolerate_zero_padding | ignore_all_zero_dtc | dtc_snapshot_did_size | didconfig |
---|---|---|---|---|---|
reportNumberOfDTCByStatusMask | |||||
reportDTCByStatusMask | Yes | Yes | |||
reportDTCSnapshotIdentification | Yes | Yes | |||
reportDTCSnapshotRecordByDTCNumber | Yes | Yes | Yes | ||
reportDTCSnapshotRecordByRecordNumber | Yes | Yes | Yes | ||
reportDTCExtendedDataRecordByDTCNumber | Yes | Yes | |||
reportNumberOfDTCBySeverityMaskRecord | |||||
reportDTCBySeverityMaskRecord | Yes | Yes | |||
reportSeverityInformationOfDTC | Yes | Yes | |||
reportSupportedDTCs | Yes | Yes | |||
reportFirstTestFailedDTC | Yes | Yes | |||
reportFirstConfirmedDTC | Yes | Yes | |||
reportMostRecentTestFailedDTC | Yes | Yes | |||
reportMostRecentConfirmedDTC | Yes | Yes | |||
reportMirrorMemoryDTCByStatusMask | Yes | Yes | |||
reportMirrorMemoryDTCExtendedDataRecordByDTCNumber | Yes | Yes | |||
reportNumberOfMirrorMemoryDTCByStatusMask | |||||
reportNumberOfEmissionsRelatedOBDDTCByStatusMask | |||||
reportEmissionsRelatedOBDDTCByStatusMask | Yes | Yes | |||
reportDTCFaultDetectionCounter | Yes | Yes | |||
reportDTCWithPermanentStatus | Yes | Yes |
ReadMemoryByAddress (0x23)¶
-
classmethod
ReadMemoryByAddress.
make_request
(memory_location: udsoncan.common.MemoryLocation.MemoryLocation) → udsoncan.Request.Request[source]¶ Generates a request for ReadMemoryByAddress
Parameters: memory_location (MemoryLocation) – The address and the size of the memory block to read. Raises: ValueError – If parameters are out of range, missing or wrong type
-
classmethod
ReadMemoryByAddress.
interpret_response
(response: udsoncan.Response.Response) → udsoncan.services.ReadMemoryByAddress.ReadMemoryByAddress.InterpretedResponse[source]¶ Populates the response
service_data
property with an instance ofReadMemoryByAddress.ResponseData
Parameters: response (Response) – The received response to interpret Raises: InvalidResponseException – If length of response.data
is too short
-
class
ReadMemoryByAddress.
ResponseData
(memory_block: bytes)[source]¶ -
memory_block
¶ bytes object reflecting the content of the read memory
-
Note
This service does not have subfunctions
RequestDownload (0x34)¶
-
classmethod
RequestDownload.
make_request
(memory_location: udsoncan.common.MemoryLocation.MemoryLocation, dfi: typing.Union[udsoncan.common.DataFormatIdentifier.DataFormatIdentifier, NoneType] = None) → udsoncan.Request.Request[source]¶ Generates a request for RequestDownload
Parameters: - memory_location (MemoryLocation) – The address and the size of the memory block to be written.
- dfi (DataFormatIdentifier) – Optional DataFormatIdentifier defining the compression and encryption scheme of the data. If not specified, the default value of 00 will be used, specifying no encryption and no compression
Raises: ValueError – If parameters are out of range, missing or wrong type
-
classmethod
RequestDownload.
interpret_response
(response: udsoncan.Response.Response) → udsoncan.services.RequestDownload.RequestDownload.InterpretedResponse[source]¶ Populates the response
service_data
property with an instance ofRequestDownload.ResponseData
Parameters: response (Response) – The received response to interpret
Raises: - InvalidResponseException – If length of
response.data
is too short - NotImplementedError – If the
maxNumberOfBlockLength
value is encoded over more than 8 bytes.
- InvalidResponseException – If length of
-
class
RequestDownload.
ResponseData
(max_length)[source]¶ -
max_length
¶ (int) Maximum number of data blocks to write
-
Note
This service does not have subfunctions
RequestTransferExit (0x37)¶
-
classmethod
RequestTransferExit.
make_request
(data: typing.Union[bytes, NoneType] = None) → udsoncan.Request.Request[source]¶ Generates a request for RequestTransferExit
Parameters: data (bytes) – Additional optional data to send to the server Raises: ValueError – If parameters are out of range, missing or wrong type
-
classmethod
RequestTransferExit.
interpret_response
(response: udsoncan.Response.Response) → udsoncan.services.RequestTransferExit.RequestTransferExit.InterpretedResponse[source]¶ Populates the response
service_data
property with an instance ofRequestTransferExit.ResponseData
Parameters: response (Response) – The received response to interpret
-
class
RequestTransferExit.
ResponseData
(parameter_records: bytes)[source]¶ -
parameter_records
¶ bytes object containing optional data provided by the server
-
Note
This service does not have subfunctions
RequestUpload (0x35)¶
-
classmethod
RequestUpload.
make_request
(memory_location: udsoncan.common.MemoryLocation.MemoryLocation, dfi: typing.Union[udsoncan.common.DataFormatIdentifier.DataFormatIdentifier, NoneType] = None) → udsoncan.Request.Request[source]¶ Generates a request for RequestUpload
Parameters: - memory_location (MemoryLocation) – The address and the size of the memory block to be read.
- dfi (DataFormatIdentifier) – Optional dataFormatIdentifier defining the compression and encryption scheme of the data. If not specified, the default value of 00 will be used, specifying no encryption and no compression
Raises: ValueError – If parameters are out of range, missing or wrong type
-
classmethod
RequestUpload.
interpret_response
(response: udsoncan.Response.Response) → udsoncan.services.RequestUpload.RequestUpload.InterpretedResponse[source]¶ Populates the response
service_data
property with an instance ofRequestUpload.ResponseData
Parameters: response (Response) – The received response to interpret
Raises: - InvalidResponseException – If length of
response.data
is too short - NotImplementedError – If the maxNumberOfBlockLength value is encoded over more than 8 bytes.
- InvalidResponseException – If length of
-
class
RequestUpload.
ResponseData
(max_length)[source]¶ -
max_length
¶ (int) Maximum number of data blocks to read
-
Note
This service does not have subfunctions
RoutineControl (0x31)¶
-
classmethod
RoutineControl.
make_request
(routine_id: int, control_type: int, data: typing.Union[bytes, NoneType] = None) → udsoncan.Request.Request[source]¶ Generates a request for RoutineControl
Parameters: - routine_id (int) – The routine ID. Value should be between 0 and 0xFFFF
- control_type (int) – Service subfunction. Allowed values are from 0 to 0x7F
- data (bytes) – Optional additional data to provide to the server
Raises: ValueError – If parameters are out of range, missing or wrong type
-
classmethod
RoutineControl.
interpret_response
(response: udsoncan.Response.Response) → udsoncan.services.RoutineControl.RoutineControl.InterpretedResponse[source]¶ Populates the response
service_data
property with an instance ofRoutineControl.ResponseData
Parameters: response (Response) – The received response to interpret Raises: InvalidResponseException – If length of response.data
is too short
-
class
RoutineControl.
ResponseData
(control_type_echo: int, routine_id_echo: int, routine_status_record: bytes)[source]¶ -
control_type_echo
¶ Requests subfunction echoed back by the server
-
routine_id_echo
¶ Requests routine ID echoed back by the server.
-
routine_status_record
¶ Additional data associated with the response.
-
-
class
RoutineControl.
ControlType
[source]¶ RoutineControl defined subfunctions
-
requestRoutineResults
= 3¶
-
startRoutine
= 1¶
-
stopRoutine
= 2¶
-
SecurityAccess (0x27)¶
-
classmethod
SecurityAccess.
make_request
(level: int, mode: int, data=b'') → udsoncan.Request.Request[source]¶ Generates a request for SecurityAccess
Parameters: - level (int) – Service subfunction. The security level to unlock. Value ranging from 0 to 7F For mode=``RequestSeed`` (0), level must be an even value. For mode=``SendKey`` (1), level must be an odd value. If the even/odd constraint is not respected, the level value will be corrected to properly set the LSB.
- mode (SecurityAccess.Mode, int) – Type of request to perform.
SecurityAccess.Mode.RequestSeed
orSecurityAccess.Mode.SendKey
- data (bytes) – securityAccessDataRecord (optional) for the get seed, securityKey (required) for the send key
Raises: ValueError – If parameters are out of range, missing or wrong type
-
classmethod
SecurityAccess.
interpret_response
(response: udsoncan.Response.Response, mode: int) → udsoncan.services.SecurityAccess.SecurityAccess.InterpretedResponse[source]¶ Populates the response
service_data
property with an instance ofSecurityAccess.ResponseData
Parameters: response (Response) – The received response to interpret
Raises: - InvalidResponseException – If length of
response.data
is too short - ValueError – If mode is not
RequestSeed
orSendKey
- InvalidResponseException – If length of
-
class
SecurityAccess.
ResponseData
(security_level_echo: int, seed: typing.Union[bytes, NoneType] = None)[source]¶ -
security_level_echo
¶ Requests subfunction echoed back by the server
-
seed
¶ Seed value. Only present if request mode was
RequestSeed
(even subfunction)
-
Note
The level
that acts as the subfunction can range from 1 to 0x7E. The LSB is a flag indicating the type of request.
When the LSB is set to 1, the request is a RequestSeed message, when it is set to 0, the request is a SendKey message.
This leaves 6 effective bits allowing 63 security levels.
Example :
- 01: RequestSeed, 02 SendKey that goes with 01.
- 03: RequestSeed, 04 SendKey that goes with 03.
- etc
TesterPresent (0x3E)¶
-
classmethod
TesterPresent.
make_request
() → udsoncan.Request.Request[source]¶ Generates a request for TesterPresent
-
classmethod
TesterPresent.
interpret_response
(response: udsoncan.Response.Response) → udsoncan.services.TesterPresent.TesterPresent.InterpretedResponse[source]¶ Populates the response
service_data
property with an instance ofTesterPresent.ResponseData
Parameters: response (Response) – The received response to interpret Raises: InvalidResponseException – If length of response.data
is too short
-
class
TesterPresent.
ResponseData
(subfunction_echo: int)[source]¶ -
subfunction_echo
¶ Requests subfunction echoed back by the server. This value should always be 0
-
Note
TesterPresent subfunction is always 0
TransferData (0x36)¶
-
classmethod
TransferData.
make_request
(sequence_number: int, data: typing.Union[bytes, NoneType] = None) → udsoncan.Request.Request[source]¶ Generates a request for TransferData
Parameters: - sequence_number (int) – Corresponds to an 8bit counter that should increment for each new block transferred. Allowed values are from 0 to 0xFF
- data (bytes) – Optional additional data to send to the server
Raises: ValueError – If parameters are out of range, missing or wrong type
-
classmethod
TransferData.
interpret_response
(response: udsoncan.Response.Response) → udsoncan.services.TransferData.TransferData.InterpretedResponse[source]¶ Populates the response
service_data
property with an instance ofTransferData.ResponseData
Parameters: response (Response) – The received response to interpret Raises: InvalidResponseException – If length of response.data
is too short
-
class
TransferData.
ResponseData
(sequence_number_echo: int, parameter_records: bytes)[source]¶ -
sequence_number_echo
¶ Requests subfunction echoed back by the server
-
parameter_records
¶ Optional additional data associated with the response.
-
Note
This service does not have subfunctions
WriteDataByIdentifier (0x2E)¶
-
classmethod
WriteDataByIdentifier.
make_request
(did: int, value: typing.Any, didconfig: typing.Dict[int, typing.Union[str, udsoncan.common.DidCodec.DidCodec, typing.Type[udsoncan.common.DidCodec.DidCodec]]]) → udsoncan.Request.Request[source]¶ Generates a request for WriteDataByIdentifier
Parameters: - did (int) – The data identifier to write
- value (object) – Value given to the DidCodec.encode method. If involved codec is defined with a pack string (default codec), multiple values may be passed with a tuple.
- didconfig (dict[int] = DidCodec) – Definition of DID codecs. Dictionary mapping a DID (int) to a valid DidCodec class or pack/unpack string
Raises: - ValueError – If parameters are out of range, missing or wrong type
- ConfigError – If
didlist
contains a DID not defined indidconfig
-
classmethod
WriteDataByIdentifier.
interpret_response
(response: udsoncan.Response.Response) → udsoncan.services.WriteDataByIdentifier.WriteDataByIdentifier.InterpretedResponse[source]¶ Populates the response
service_data
property with an instance ofWriteDataByIdentifier.ResponseData
Parameters: response (Response) – The received response to interpret Raises: InvalidResponseException – If length of response.data
is too short
-
class
WriteDataByIdentifier.
ResponseData
(did_echo: int)[source]¶ -
did_echo
¶ The DID echoed back by the server
-
Note
This service does not have subfunctions
WriteMemoryByAddress (0x3D)¶
-
classmethod
WriteMemoryByAddress.
make_request
(memory_location: udsoncan.common.MemoryLocation.MemoryLocation, data: bytes) → udsoncan.Request.Request[source]¶ Generates a request for ReadMemoryByAddress
Parameters: - memory_location (MemoryLocation) – The address and the size of the memory block to write.
- data (bytes) – The data to write into memory.
Raises: ValueError – If parameters are out of range, missing or wrong type
-
classmethod
WriteMemoryByAddress.
interpret_response
(response: udsoncan.Response.Response, memory_location: udsoncan.common.MemoryLocation.MemoryLocation) → udsoncan.services.WriteMemoryByAddress.WriteMemoryByAddress.InterpretedResponse[source]¶ Populates the response
service_data
property with an instance ofWriteMemoryByAddress.ResponseData
Parameters: - response (Response) – The received response to interpret
- memory_location (MemoryLocation) – The memory location used for the request.
The bytes position varies depending on the
memory_location
format
Raises: InvalidResponseException – If length of
response.data
is too short
-
class
WriteMemoryByAddress.
ResponseData
(alfid_echo: int, memory_location_echo: udsoncan.common.MemoryLocation.MemoryLocation)[source]¶ -
alfid_echo
¶ AddressAndLengthFormatIdentifier used in the MemoryLocation object echoed back by the server as a single byte integer.
-
memory_location_echo
¶ An instance of MemoryLocation that includes the address, size and alfid that the server echoed back.
-
Note
This service does not have subfunctions
DynamicallyDefineDataIdentifier (0x2C)¶
-
classmethod
DynamicallyDefineDataIdentifier.
make_request
(subfunction: int, did: typing.Union[int, NoneType] = None, diddef: typing.Union[udsoncan.common.DynamicDidDefinition.DynamicDidDefinition, NoneType] = None) → udsoncan.Request.Request[source]¶ Generates a request for DynamicallyDefineDataIdentifier
Parameters: - subfunction (int) – Service subfunction. Allowed values are from 1 to 3
- did (int) – The Data Identifier to define. Values from 0x0000 to 0xFFFF
- diddef (DynamicDidDefinition) – Definition of the DID. Either by source DID or memory address. This parameter is only needed with subfunctions defineByIdentifie (1)` and defineByMemoryAddress (2)
Raises: ValueError – If parameters are out of range, missing or wrong type
-
classmethod
DynamicallyDefineDataIdentifier.
interpret_response
(response: udsoncan.Response.Response) → udsoncan.services.DynamicallyDefineDataIdentifier.DynamicallyDefineDataIdentifier.InterpretedResponse[source]¶ Populates the response
service_data
property with an instance ofDynamicallyDefineDataIdentifier.ResponseData
Parameters: response (Response) – The received response to interpret Raises: InvalidResponseException – If length of response.data
is too short
-
class
DynamicallyDefineDataIdentifier.
ResponseData
(subfunction_echo: int, did_echo: typing.Union[int, NoneType] = None)[source]¶
ReadDataByPeriodicIdentifier (0x2A)¶
Warning
Not implemented