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, timing_param_record=None)[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
- Return type:
- classmethod AccessTimingParameter.interpret_response(response)[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- Return type:
InterpretedResponse
- class AccessTimingParameter.ResponseData(access_type_echo, timing_param_record)[source]
- Parameters:
access_type_echo (int) –
timing_param_record (bytes) –
- 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
- readExtendedTimingParameterSet = 1
- setTimingParametersToDefaultValues = 2
- readCurrentlyActiveTimingParameters = 3
- setTimingParametersToGivenValues = 4
ClearDiagnosticInformation (0x14)
- classmethod ClearDiagnosticInformation.make_request(group=16777215, memory_selection=None, standard_version=2020)[source]
Generates a request for ClearDiagnosticInformation
- Parameters:
group (int) – DTC mask ranging from 0 to 0xFFFFFF. 0xFFFFFF means all DTCs
memory_selection (int | None) –
standard_version (int) –
- Raises:
ValueError – If parameters are out of range, missing or wrong type
- Return type:
- classmethod ClearDiagnosticInformation.interpret_response(response)[source]
Populates the response
service_data
property with an instance ofClearDiagnosticInformation.ResponseData
- Parameters:
response (Response) – The received response to interpret
- Return type:
InterpretedResponse
Note
This service have empty response data
Note
This service does not have subfunctions
CommunicationControl (0x28)
- classmethod CommunicationControl.make_request(control_type, communication_type)[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
- Return type:
- classmethod CommunicationControl.interpret_response(response)[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- Return type:
InterpretedResponse
- class CommunicationControl.ResponseData(control_type_echo)[source]
- Parameters:
control_type_echo (int) –
- control_type_echo
Request subfunction echoed back by the server
- class CommunicationControl.ControlType[source]
CommunicationControl defined subfunctions
- enableRxAndTx = 0
- enableRxAndDisableTx = 1
- disableRxAndEnableTx = 2
- disableRxAndTx = 3
ControlDTCSetting (0x85)
- classmethod ControlDTCSetting.make_request(setting_type, data=None)[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
- Return type:
- classmethod ControlDTCSetting.interpret_response(response)[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- Return type:
InterpretedResponse
- class ControlDTCSetting.ResponseData(setting_type_echo)[source]
- Parameters:
setting_type_echo (int) –
- setting_type_echo
Request subfunction echoed back by the server
- class ControlDTCSetting.SettingType[source]
ControlDTCSetting defined subfunctions
- on = 1
- off = 2
DiagnosticSessionControl (0x10)
- classmethod DiagnosticSessionControl.make_request(session)[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
- Return type:
- classmethod DiagnosticSessionControl.interpret_response(response, standard_version=2020)[source]
Populates the response
service_data
property with an instance ofDiagnosticSessionControl.ResponseData
- Parameters:
response (Response) – The received response to interpret
standard_version (int) –
- Raises:
InvalidResponseException – If length of
response.data
is too short- Return type:
InterpretedResponse
- class DiagnosticSessionControl.ResponseData(session_echo, session_param_records, p2_server_max=None, p2_star_server_max=None)[source]
- Parameters:
session_echo (int) –
session_param_records (bytes) –
p2_server_max (float | None) –
p2_star_server_max (float | None) –
- 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
- programmingSession = 2
- extendedDiagnosticSession = 3
- safetySystemDiagnosticSession = 4
ECUReset (0x11)
- classmethod ECUReset.make_request(reset_type)[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
- Return type:
- classmethod ECUReset.interpret_response(response)[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- Return type:
InterpretedResponse
- class ECUReset.ResponseData(reset_type_echo, powerdown_time=None)[source]
- Parameters:
reset_type_echo (int) –
powerdown_time (int | None) –
- 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
- hardReset = 1
- keyOffOnReset = 2
- softReset = 3
- enableRapidPowerShutDown = 4
- disableRapidPowerShutDown = 5
InputOutputControlByIdentifier (0x2F)
- classmethod InputOutputControlByIdentifier.make_request(did, control_param=None, values=None, masks=None, ioconfig=None)[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
- Return type:
- classmethod InputOutputControlByIdentifier.interpret_response(response, control_param=None, tolerate_zero_padding=True, ioconfig=None)[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
definitionInvalidResponseException – If response data is incomplete or if DID data does not match codec length.
- Return type:
InterpretedResponse
- class InputOutputControlByIdentifier.ResponseData(did_echo, control_param_echo=None, decoded_data=None)[source]
- Parameters:
did_echo (int) –
control_param_echo (int | None) –
decoded_data (Any | None) –
- 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, baudrate=None)[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
- Return type:
- classmethod LinkControl.interpret_response(response)[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- Return type:
InterpretedResponse
- class LinkControl.ResponseData(control_type_echo)[source]
- Parameters:
control_type_echo (int) –
- control_type_echo
Request subfunction echoed back by the server
- class LinkControl.ControlType[source]
LinkControl defined subfunctions
- verifyBaudrateTransitionWithFixedBaudrate = 1
- verifyBaudrateTransitionWithSpecificBaudrate = 2
- transitionBaudrate = 3
ReadDataByIdentifier (0x22)
- classmethod ReadDataByIdentifier.make_request(didlist, didconfig)[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
- Return type:
- classmethod ReadDataByIdentifier.interpret_response(response, didlist, didconfig, tolerate_zero_padding=True)[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.
- Return type:
InterpretedResponse
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, path, dfi=None, filesize=None)[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
- Return type:
- classmethod RequestFileTransfer.interpret_response(response, tolerate_zero_padding=True)[source]
Populates the response
service_data
property with an instance ofRequestFileTransfer.ResponseData
- Parameters:
response (Response) – The received response to interpret
tolerate_zero_padding (bool) –
- Raises:
InvalidResponseException – If length of
response.data
is too short or payload does not respect ISO-14229 specificationsNotImplementedError – If the MaxNumberOfBlock or fileSizeUncompressedOrDirInfoLength value is encoded over more than 8 bytes.
- Return type:
InterpretedResponse
- class RequestFileTransfer.ResponseData(moop_echo, max_length=None, dfi=None, filesize=None, dirinfo_length=None, fileposition=None)[source]
- Parameters:
moop_echo (int) –
max_length (int | None) –
dfi (DataFormatIdentifier | None) –
filesize (Filesize | None) –
dirinfo_length (int | None) –
fileposition (int | None) –
- 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, status_mask=None, severity_mask=None, dtc=None, snapshot_record_number=None, extended_data_record_number=None, memory_selection=None, standard_version=2020)[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
standard_version (int) –
- Raises:
ValueError – If parameters are out of range, missing or wrong type
- Return type:
- classmethod ReadDTCInformation.interpret_response(response, subfunction, extended_data_size=None, tolerate_zero_padding=True, ignore_all_zero_dtc=True, dtc_snapshot_did_size=2, didconfig=None, standard_version=2020)[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
standard_version (int) –
- 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
- Return type:
InterpretedResponse
- class ReadDTCInformation.ResponseData(subfunction_echo, dtcs=None, dtc_count=None, dtc_format=None, status_availability=None, extended_data=[], memory_selection_echo=None)[source]
- Parameters:
- 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]
- reportNumberOfDTCByStatusMask = 1
- reportDTCByStatusMask = 2
- reportDTCSnapshotIdentification = 3
- reportDTCSnapshotRecordByDTCNumber = 4
- reportDTCSnapshotRecordByRecordNumber = 5
- reportDTCExtendedDataRecordByDTCNumber = 6
- reportNumberOfDTCBySeverityMaskRecord = 7
- reportDTCBySeverityMaskRecord = 8
- reportSeverityInformationOfDTC = 9
- reportSupportedDTCs = 10
- reportFirstTestFailedDTC = 11
- reportFirstConfirmedDTC = 12
- reportMostRecentTestFailedDTC = 13
- reportMostRecentConfirmedDTC = 14
- reportMirrorMemoryDTCByStatusMask = 15
- reportMirrorMemoryDTCExtendedDataRecordByDTCNumber = 16
- reportNumberOfMirrorMemoryDTCByStatusMask = 17
- reportNumberOfEmissionsRelatedOBDDTCByStatusMask = 18
- reportEmissionsRelatedOBDDTCByStatusMask = 19
- reportDTCFaultDetectionCounter = 20
- reportDTCWithPermanentStatus = 21
- reportDTCExtDataRecordByRecordNumber = 22
- reportUserDefMemoryDTCByStatusMask = 23
- reportUserDefMemoryDTCSnapshotRecordByDTCNumber = 24
- reportUserDefMemoryDTCExtDataRecordByDTCNumber = 25
- reportSupportedDTCExtDataRecord = 26
- reportWWHOBDDTCByMaskRecord = 66
- reportWWHOBDDTCWithPermanentStatus = 85
- reportDTCInformationByDTCReadinessGroupIdentifier = 86
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)[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
- Return type:
- classmethod ReadMemoryByAddress.interpret_response(response)[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- Return type:
InterpretedResponse
- class ReadMemoryByAddress.ResponseData(memory_block)[source]
- Parameters:
memory_block (bytes) –
- 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, dfi=None)[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
- Return type:
- classmethod RequestDownload.interpret_response(response)[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 shortNotImplementedError – If the
maxNumberOfBlockLength
value is encoded over more than 8 bytes.
- Return type:
InterpretedResponse
- class RequestDownload.ResponseData(max_length)[source]
- Parameters:
max_length (int) –
- max_length
(int) Maximum number of data blocks to write
Note
This service does not have subfunctions
RequestTransferExit (0x37)
- classmethod RequestTransferExit.make_request(data=None)[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
- Return type:
- classmethod RequestTransferExit.interpret_response(response)[source]
Populates the response
service_data
property with an instance ofRequestTransferExit.ResponseData
- Parameters:
response (Response) – The received response to interpret
- Return type:
InterpretedResponse
- class RequestTransferExit.ResponseData(parameter_records)[source]
- Parameters:
parameter_records (bytes) –
- 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, dfi=None)[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
- Return type:
- classmethod RequestUpload.interpret_response(response)[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 shortNotImplementedError – If the maxNumberOfBlockLength value is encoded over more than 8 bytes.
- Return type:
InterpretedResponse
- class RequestUpload.ResponseData(max_length)[source]
- Parameters:
max_length (int) –
- 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, control_type, data=None)[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
- Return type:
- classmethod RoutineControl.interpret_response(response)[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- Return type:
InterpretedResponse
- class RoutineControl.ResponseData(control_type_echo, routine_id_echo, routine_status_record)[source]
- Parameters:
control_type_echo (int) –
routine_id_echo (int) –
routine_status_record (bytes) –
- 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
- startRoutine = 1
- stopRoutine = 2
- requestRoutineResults = 3
SecurityAccess (0x27)
- classmethod SecurityAccess.make_request(level, mode, data=b'')[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
- Return type:
- classmethod SecurityAccess.interpret_response(response, mode)[source]
Populates the response
service_data
property with an instance ofSecurityAccess.ResponseData
- Parameters:
response (Response) – The received response to interpret
mode (int) –
- Raises:
InvalidResponseException – If length of
response.data
is too shortValueError – If mode is not
RequestSeed
orSendKey
- Return type:
InterpretedResponse
- class SecurityAccess.ResponseData(security_level_echo, seed=None)[source]
- Parameters:
security_level_echo (int) –
seed (bytes | None) –
- 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()[source]
Generates a request for TesterPresent
- Return type:
- classmethod TesterPresent.interpret_response(response)[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- Return type:
InterpretedResponse
- class TesterPresent.ResponseData(subfunction_echo)[source]
- Parameters:
subfunction_echo (int) –
- 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, data=None)[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
- Return type:
- classmethod TransferData.interpret_response(response)[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- Return type:
InterpretedResponse
- class TransferData.ResponseData(sequence_number_echo, parameter_records)[source]
- Parameters:
sequence_number_echo (int) –
parameter_records (bytes) –
- 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, value, didconfig)[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
- Return type:
- classmethod WriteDataByIdentifier.interpret_response(response)[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- Return type:
InterpretedResponse
- class WriteDataByIdentifier.ResponseData(did_echo)[source]
- Parameters:
did_echo (int) –
- did_echo
The DID echoed back by the server
Note
This service does not have subfunctions
WriteMemoryByAddress (0x3D)
- classmethod WriteMemoryByAddress.make_request(memory_location, data)[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
- Return type:
- classmethod WriteMemoryByAddress.interpret_response(response, memory_location)[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- Return type:
InterpretedResponse
- class WriteMemoryByAddress.ResponseData(alfid_echo, memory_location_echo)[source]
- Parameters:
alfid_echo (int) –
memory_location_echo (MemoryLocation) –
- 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, did=None, diddef=None)[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
- Return type:
- classmethod DynamicallyDefineDataIdentifier.interpret_response(response)[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- Return type:
InterpretedResponse
- class DynamicallyDefineDataIdentifier.ResponseData(subfunction_echo, did_echo=None)[source]
- Parameters:
subfunction_echo (int) –
did_echo (int | None) –
SecuredDataTransmission (0x84)
Warning
Not implemented
ResponseOnEvent (0x86)
Warning
Not implemented
ReadScalingDataByIdentifier (0x24)
Warning
Not implemented
ReadDataByPeriodicIdentifier (0x2A)
Warning
Not implemented