Skip to content

py_uds_lib

Python package for creating UDS requests

**NOTE: this package not yet ready to use. implementation in progress.

source manual


Python package for creating UDS requests

Nrc()

This class holds all negative response codes name and its values respectively. Check ISO 14229 doc for more information.

Services()

This class holds all UDS services. Use class methods to create diagnostic request in string format.

access_timing_parameter(timing_parameter_access_type, timing_parameter_request_record=None)

service is used to read and change the default timing parameters of a communication link for the duration this communication link is active. Check ISO 14229 doc for more information about service.

Parameters:

Name Type Description Default
timing_parameter_access_type int

1 byte parameter is used by the service to select the specific behavior of the server.

required
timing_parameter_request_record Nlist[int]

parameter record contains the timing parameter values to be set in the server. Defaults to None.

None

Returns:

Name Type Description
str str

complete request in string of bytes with space between each byte.

clear_diagnostic_information(group_of_dtc)

service is used by the client to clear diagnostic information in one or multiple servers memory. Check ISO 14229 doc for more information about service.

Parameters:

Name Type Description Default
group_of_dtc int

parameter contains a 3-byte value indicating the group of DTCs (e.g., Powertrain, Body, Chassis) or the particular DTC to be cleared.

required

Returns:

Name Type Description
str str

complete request in string of bytes with space between each byte.

communication_control(control_type, communication_type, node_identification_number=None)

service used to switch on/off the transmission and/or the reception of certain messages. Check ISO 14229 doc for more information about service.

Parameters:

Name Type Description Default
control_type int

1 byte parameter contains information on how the server shall modify the communication type.

required
communication_type int

1 byte parameter is used to reference the kind of communication to be controlled.

required
node_identification_number int

2 byte parameter is used to identify a node on a sub-network somewhere in the vehicle. Defaults to None.

None

Returns:

Name Type Description
str str

complete request in string of bytes with space between each byte.

control_dtc_setting(dtc_setting_type, dtc_setting_control_option_record=None)

service used by a client to stop or resume the updating of DTC status bits in the server. Check ISO 14229 doc for more information about service.

Parameters:

Name Type Description Default
dtc_setting_type int

1 byte parameter used by the service to indicate to the server(s) whether diagnostic trouble code status bit updating shall stop or start again.

required
dtc_setting_control_option_record list[int]

parameter record is user optional to transmit data to a server when controlling the updating of DTC status bits. Defaults to None.

None

Returns:

Name Type Description
str str

complete request in string of bytes with space between each byte.

diagnostic_session_control(diagnostic_session_type)

service is used to enable different diagnostic sessions in the server(s). Check ISO 14229 doc for more information about service.

Parameters:

Name Type Description Default
diagnostic_session_type int

1 byte parameter is used by the service to select the specific behavior of the server

required

Returns:

Name Type Description
str str

complete request in string of bytes with space between each byte.

dynamically_define_data_identifier(definition_type, supporting_params)

service allows the client to dynamically define in a server a data identifier that can be read via the ReadDataByIdentifier service at a later time. Check ISO 14229 doc for more information about service.

Parameters:

Name Type Description Default
definition_type int

1 byte parameter to mention definition type. check UDS ISO document for values.

required
supporting_params list[list[int]] | int

check UDS ISO document for different possible values.

required

Returns:

Name Type Description
str str

complete request in string of bytes with space between each byte.

ecu_reset(reset_type)

The ECUReset service is used by the client to request a server reset. Check ISO 14229 doc for more information about service.

Parameters:

Name Type Description Default
reset_type int

1 byte parameter is used by the service to describe how the server has to perform the reset.

required

Returns:

Name Type Description
str str

complete request in string of bytes with space between each byte.

input_output_control_by_identifier(data_identifier, control_option_record, control_enable_mask_record=None)

service is used by the client to substitute a value for an input signal, internal server function and/or force control to a value for an output (actuator) of an electronic system. Check ISO 14229 doc for more information about service.

Parameters:

Name Type Description Default
data_identifier int

parameter identifies an server local input signal(s), internal parameter(s) and/or output signal(s).

required
control_option_record list[int]

one or multiple bytes (inputOutputControlParameter and controlState 1 to controlState m).

required
control_enable_mask_record list[int]

one or multiple bytes (controlMask 1 to controlMask r). Defaults to None.

None

Returns:

Name Type Description
str str

complete request in string of bytes with space between each byte.

service is used to control the communication between the client and the server in order to gain bus bandwidth for diagnostic purposes. Check ISO 14229 doc for more information about service.

Parameters:

Name Type Description Default
link_control_type int

1 byte parameter is used by the service to describe the action to be performed in the server.

required
link_control_mode_identifier int

This conditional 1 byte parameter references a fixed defined mode parameter. Defaults to None.

None
link_record int

This conditional 3 byte parameter record contains a specific mode parameter in case the sub-function parameter indicates that a specific parameter is used. Defaults to None.

None

Returns:

Name Type Description
str str

complete request in string of bytes with space between each byte.

read_data_by_identifier(data_identifier)

service allows the client to request data record values from the server identified by one or more dataIdentifiers. Check ISO 14229 doc for more information about service.

Parameters:

Name Type Description Default
data_identifier list[int]

parameter identifies the server data record(s) that are being requested by the client.

required

Returns:

Name Type Description
str str

complete request in string of bytes with space between each byte.

read_data_by_periodic_identifier(transmission_mode, periodic_data_identifier)

service allows the client to request the periodic transmission of data record values from the server identified by one or more periodicDataIdentifiers. Check ISO 14229 doc for more information about service.

Parameters:

Name Type Description Default
transmission_mode int

1 byte parameter identifies the transmission rate of the requested periodicDataIdentifiers to be used by the server.

required
periodic_data_identifier list[int]

parameter identifies the server data record(s) that are being requested by the client.

required

Returns:

Name Type Description
str str

complete request in string of bytes with space between each byte.

read_dtc_information(report_type, remaining_arguments_list)

service allows a client to read the status of server resident Diagnostic Trouble Code (DTC) information from any server, or group of servers within a vehicle. Check ISO 14229 doc for more information about service.

Parameters:

Name Type Description Default
report_type int

type of DTC's that we need to retrieve from ECU.

required
remaining_arguments_list list[int]

list of remaining arguments needed for type of DTC's to be fetched.

required

Returns:

Name Type Description
str str

complete request in string of bytes with space between each byte.

read_memory_by_address(address_and_length_format_identifier, memory_address, memory_size)

service allows the client to request memory data from the server via provided starting address and size of memory to be read. Check ISO 14229 doc for more information about service.

Parameters:

Name Type Description Default
address_and_length_format_identifier int

parameter is a one byte value with each nibble encoded separately. bit 7 - 4: Length (number of bytes) of the memorySize parameter. bit 3 - 0: Length (number of bytes) of the memoryAddress parameter.

required
memory_address int

parameter is the starting address of server memory from which data is to be retrieved.

required
memory_size int

parameter in the service specifies the number of bytes to be read starting at the address specified by memoryAddress in the server's memory.

required

Returns:

Name Type Description
str str

complete request in string of bytes with space between each byte.

read_scaling_data_by_identifier(data_identifier)

service allows the client to request scaling data record information from the server identified by a dataIdentifier. Check ISO 14229 doc for more information about service.

Parameters:

Name Type Description Default
data_identifier int

2 byte parameter identifies the server data record that is being requested by the client.

required

Returns:

Name Type Description
str str

complete request in string of bytes with space between each byte.

request_download(data_format_identifier, address_and_length_format_identifier, memory_address, memory_size)

service is used by the client to initiate a data transfer from the client to the server. Check ISO 14229 doc for more information about service.

Parameters:

Name Type Description Default
data_format_identifier int

one byte value with each nibble encoded separately. The high nibble specifies the "compressionMethod", and the low nibble specifies the "encryptingMethod".

required
address_and_length_format_identifier int

parameter is a one byte value with each nibble encoded separately. bit 7 - 4: Length of the memorySize parameter. bit 3 - 0: Length of the memoryAddress parameter.

required
memory_address int

starting address of the server memory where the data is to be written to.

required
memory_size int

parameter shall be used by the server to compare the memory size with the total amount of data transferred during the TransferData service.

required

Returns:

Name Type Description
str str

complete request in string of bytes with space between each byte.

request_file_transfer(mode_of_operation, file_path_and_name_length, file_path_and_name, data_format_identifier=None, file_size_parameter_length=None, file_size_uncompressed=None, file_size_compressed=None)

service is used by the client to initiate a file data transfer from either the client to the server or from the server to the client (download or upload). Check ISO 14229 doc for more information about service.

Parameters:

Name Type Description Default
mode_of_operation int

This data-parameter defines the type of operation to be applied to the file or directory indicated in the filePathAndName parameter.

required
file_path_and_name_length int

length in byte for the parameter filePath.

required
file_path_and_name list[int]

Defines the file system location of the server where the file which shall be added, deleted, replaced or read from depending on the parameter modeOfOperation parameter.

required
data_format_identifier int

This data-parameter is a one byte value with each nibble encoded separately.. Defaults to None.

None
file_size_parameter_length int

Defines the length in bytes for both parameters fileSizeUncompressed and fileSizeCompressed. Defaults to None.

None
file_size_uncompressed list[int]

Defines the size of the uncompressed file in bytes. Defaults to None.

None
file_size_compressed list[int]

Defines the size of the compressed file in bytes. Defaults to None.

None

Returns:

Name Type Description
str str

complete request in string of bytes with space between each byte.

request_transfer_exit(transfer_request_parameter_record=None)

service is used by the client to terminate a data transfer between client and server (upload or download). Check ISO 14229 doc for more information about service.

Parameters:

Name Type Description Default
transfer_request_parameter_record list[int]

parameter record contains parameter(s), which are required by the server to support the transfer of data. Defaults to None.

None

Returns:

Name Type Description
str str

complete request in string of bytes with space between each byte.

request_upload(data_format_identifier, address_and_length_format_identifier, memory_address, memory_size)

service is used by the client to initiate a data transfer from the server to the client. Check ISO 14229 doc for more information about service.

Parameters:

Name Type Description Default
data_format_identifier int

one byte value with each nibble encoded separately. The high nibble specifies the "compressionMethod", and the low nibble specifies the "encryptingMethod".

required
address_and_length_format_identifier int

parameter is a one byte value with each nibble encoded separately. bit 7 - 4: Length of the memorySize parameter. bit 3 - 0: Length of the memoryAddress parameter.

required
memory_address int

starting address of server memory from which data is to be retrieved.

required
memory_size int

parameter shall be used by the server to compare the memory size with the total amount of data transferred during the TransferData service.

required

Returns:

Name Type Description
str str

complete request in string of bytes with space between each byte.

response_on_event(event_type, event_window_time, event_type_record=None, service_to_respond_to_record=None)

service requests a server to start or stop transmission of responses on a specified event. Check ISO 14229 doc for more information about service.

Parameters:

Name Type Description Default
event_type int

1 byte parameter is used by the service to specify the event to be configured in the server and to control the service set up.

required
event_window_time int

1 byte parameter is used to specify a window for the event logic to be active in the server.

required
event_type_record list[int]

parameter record contains additional parameters for the specified eventType. Defaults to None.

None
service_to_respond_to_record list[int]

parameter record contains the service parameters of the service to be executed in the server each time the specified event defined in the eventTypeRecord occurs. Defaults to None.

None

Returns:

Name Type Description
str str

complete request in string of bytes with space between each byte.

routine_control(routine_control_type, routine_identifier, routine_control_option_record=None)

service is used by the client to execute a defined sequence of steps and obtain any relevant results. Check ISO 14229 doc for more information about service.

Parameters:

Name Type Description Default
routine_control_type int

1 byte parameter used by this service to select the control of the routine.

required
routine_identifier int

parameter identifies a server local routine and is out of the range of defined dataIdentifiers.

required
routine_control_option_record list[int]

Routine entry/exit option parameters. Defaults to None.

None

Returns:

Name Type Description
str str

complete request in string of bytes with space between each byte.

secured_data_transmission(security_data_request_record)

service to transmit data that is protected against attacks from third parties - which could endanger data security. Check ISO 14229 doc for more information about service.

Parameters:

Name Type Description Default
security_data_request_record list[int]

parameter contains the data as processed by the Security Sub-Layer.

required

Returns:

Name Type Description
str str

complete request in string of bytes with space between each byte.

security_access(security_access_type, security_access_data_record=None)

this service provide a means to access data and/or diagnostic services, which have restricted access for security, emissions, or safety reasons. Check ISO 14229 doc for more information about service.

Parameters:

Name Type Description Default
security_access_type int

1 byte parameter indicates to the server the step in progress for this service, the level of security the client wants to access.

required
security_access_data_record list[int]

parameter is user optional to transmit data to a server when requesting the seed information. Defaults to None.

None

Returns:

Name Type Description
str str

complete request in string of bytes with space between each byte.

tester_present(zero_sub_functions)

This service is used to indicate to a server (or servers) that a client is still connected to the vehicle and that certain diagnostic services and/or communication that have been previously activated are to remain active. Check ISO 14229 doc for more information about service.

Parameters:

Name Type Description Default
zero_sub_functions int

1 byte parameter is used to indicate that no sub-function beside the suppressPosRspMsgIndicationBit is supported by this service.

required

Returns:

Name Type Description
str str

complete request in string of bytes with space between each byte.

transfer_data(block_sequence_counter, transfer_request_parameter_record)

service is used by the client to transfer data either from the client to the server (download) or from the server to the client (upload). Check ISO 14229 doc for more information about service.

Parameters:

Name Type Description Default
block_sequence_counter int

parameter value starts at 0x01 with the first TransferData request that follows the RequestDownload (0x34) or RequestUpload (0x35) service.

required
transfer_request_parameter_record list[int]

parameter record contains parameter(s) which are required by the server to support the transfer of data. Defaults to None.

required

Returns:

Name Type Description
str str

complete request in string of bytes with space between each byte.

write_data_by_identifier(data_identifier, data_record)

service allows the client to write information into the server at an internal location specified by the provided data identifier. Check ISO 14229 doc for more information about service.

Parameters:

Name Type Description Default
data_identifier int

2 byte parameter identifies the server data record that the client is requesting to write to.

required
data_record list[int]

parameter provides the data record associated with the dataIdentifier that the client is requesting to write to.

required

Returns:

Name Type Description
str str

complete request in string of bytes with space between each byte.

write_memory_by_address(address_and_length_format_identifier, memory_address, memory_size, data_record)

service allows the client to write information into the server at one or more contiguous memory locations. Check ISO 14229 doc for more information about service.

Parameters:

Name Type Description Default
address_and_length_format_identifier int

parameter is a one byte value with each nibble encoded separately. check UDS ISO for more info.

required
memory_address int

parameter is the starting address of server memory to which data is to be written.

required
memory_size int

parameter in the service specifies the number of bytes to be written starting at the address specified by memoryAddress in the server's memory.

required
data_record list[int]

parameter provides the data that the client is actually attempting to write into the server memory addresses within the interval.

required

Returns:

Name Type Description
str str

complete request in string of bytes with space between each byte.

Sfid()

This class holds all service identifier sub-functions name and its value respectively. Check ISO 14229 doc for more information.

Sid()

This class holds all service identifiers name and its value respectively. Check ISO 14229 doc for more information.