Struct ecu_diagnostics::kwp2000::Kwp2000DiagnosticServer
source · [−]pub struct Kwp2000DiagnosticServer { /* private fields */ }
Expand description
Kwp2000 Diagnostic server
Implementations
sourceimpl Kwp2000DiagnosticServer
impl Kwp2000DiagnosticServer
sourcepub fn clear_dtc_range(
&mut self,
dtc_range: ClearDTCRange
) -> DiagServerResult<()>
pub fn clear_dtc_range(
&mut self,
dtc_range: ClearDTCRange
) -> DiagServerResult<()>
Executes a DTC clear command on the ECU, given a range of DTCs to clear
sourceimpl Kwp2000DiagnosticServer
impl Kwp2000DiagnosticServer
sourcepub fn disable_normal_message_transmission(&mut self) -> DiagServerResult<()>
pub fn disable_normal_message_transmission(&mut self) -> DiagServerResult<()>
Tells the ECU to switch off its normal communication paths with other ECUs. Normally message transmission will be resumed if the ECU looses power, or if Kwp2000DiagnosticServer::enable_normal_message_transmission is called.
NOTE: Calling this function can make a car go wild as it can no longer talk to the ECU being sent this command. Use with CAUTION!
sourcepub fn enable_normal_message_transmission(&mut self) -> DiagServerResult<()>
pub fn enable_normal_message_transmission(&mut self) -> DiagServerResult<()>
Tells the ECU to re-enable its normal communication paths with other ECUs.
sourceimpl Kwp2000DiagnosticServer
impl Kwp2000DiagnosticServer
sourcepub fn read_data_by_identifier(
&mut self,
identifier: u16
) -> DiagServerResult<Vec<u8>>
pub fn read_data_by_identifier(
&mut self,
identifier: u16
) -> DiagServerResult<Vec<u8>>
Reads ECU data using a given identifier
Parameters
- identifier - A 16 bit identifier to recall data from on the ECU
Returns
If successful, this function returns the raw data stored at this identifier, without the identifier ID on the response itself.
sourceimpl Kwp2000DiagnosticServer
impl Kwp2000DiagnosticServer
sourcepub fn read_ecu_development_data(&mut self) -> DiagServerResult<DevelopmentData>
pub fn read_ecu_development_data(&mut self) -> DiagServerResult<DevelopmentData>
Reads development data from the ECU. NOT IMPLEMENTED YET (Will return DiagError::NotImplemented)
sourcepub fn read_ecu_serial_number(&mut self) -> DiagServerResult<Vec<u8>>
pub fn read_ecu_serial_number(&mut self) -> DiagServerResult<Vec<u8>>
Reads the ECU Serial number.
This function returns the bytes of just the serial number of the ECU, which can be interpreted as either ASCII (Daimler ECUs), or Model line specification (Varies from OEM to OEM)
sourcepub fn read_ecu_dbcom_data(&mut self) -> DiagServerResult<DBComData>
pub fn read_ecu_dbcom_data(&mut self) -> DiagServerResult<DBComData>
Reads DBCom data from the ECU. NOT IMPLEMENTED YET (Will return DiagError::NotImplemented)
sourcepub fn read_ecu_os_version(&mut self) -> DiagServerResult<String>
pub fn read_ecu_os_version(&mut self) -> DiagServerResult<String>
Reads the Operating system version on the ECU. NOT IMPLEMENTED YET (Will return DiagError::NotImplemented)
sourcepub fn read_ecu_reprogramming_fault_report(
&mut self
) -> DiagServerResult<Vec<u8>>
pub fn read_ecu_reprogramming_fault_report(
&mut self
) -> DiagServerResult<Vec<u8>>
Reads reprogramming fault report. The format is binary. This is to be interpreted by GSP/SDE.
sourcepub fn read_ecu_vehicle_info(&mut self) -> DiagServerResult<VehicleInfo>
pub fn read_ecu_vehicle_info(&mut self) -> DiagServerResult<VehicleInfo>
Reads vehicle information from the ECU. NOT IMPLEMENTED YET (Will return DiagError::NotImplemented)
sourcepub fn read_ecu_flash_info_1(&mut self) -> DiagServerResult<Vec<u8>>
pub fn read_ecu_flash_info_1(&mut self) -> DiagServerResult<Vec<u8>>
Reads flash data from block 1. NOT IMPLEMENTED YET (Will return DiagError::NotImplemented)
sourcepub fn read_ecu_flash_info_2(&mut self) -> DiagServerResult<Vec<u8>>
pub fn read_ecu_flash_info_2(&mut self) -> DiagServerResult<Vec<u8>>
Reads flash data from block 2. NOT IMPLEMENTED YET (Will return DiagError::NotImplemented)
sourcepub fn read_system_diag_general_param_data(
&mut self
) -> DiagServerResult<DiagGeneralParamData>
pub fn read_system_diag_general_param_data(
&mut self
) -> DiagServerResult<DiagGeneralParamData>
Reads general diagnostic parameter data from the ECU (SDCOM). NOT IMPLEMENTED YET (Will return DiagError::NotImplemented)
sourcepub fn read_system_diag_global_param_data(
&mut self
) -> DiagServerResult<DiagGlobalParamData>
pub fn read_system_diag_global_param_data(
&mut self
) -> DiagServerResult<DiagGlobalParamData>
Reads global diagnostic parameter data from the ECU. NOT IMPLEMENTED YET (Will return DiagError::NotImplemented)
sourcepub fn read_ecu_configuration(&mut self) -> DiagServerResult<Vec<u8>>
pub fn read_ecu_configuration(&mut self) -> DiagServerResult<Vec<u8>>
Reads the ECU’s current configuration status. NOT IMPLEMENTED YET (Will return DiagError::NotImplemented)
sourcepub fn read_diag_protocol_info(&mut self) -> DiagServerResult<DiagProtocolInfo>
pub fn read_diag_protocol_info(&mut self) -> DiagServerResult<DiagProtocolInfo>
Reads ECU protocol information. NOT IMPLEMENTED YET (Will return DiagError::NotImplemented)
sourcepub fn read_custom_local_identifier(
&mut self,
local_identifier: u8
) -> DiagServerResult<Vec<u8>>
pub fn read_custom_local_identifier(
&mut self,
local_identifier: u8
) -> DiagServerResult<Vec<u8>>
Reads data from a custom local identifier
Supported local identifier ranges
- 0x01-0x7F - Record local identifier
- 0xA0-0xDF - Record local identifier
- 0xF0-0xF9 - Dynamically defined local identifier
Important notes:
- If the ECU supports commands for identification purposes, then asking for an identifier in the range of 0x86-0x9F will return ECU ident data.
sourceimpl Kwp2000DiagnosticServer
impl Kwp2000DiagnosticServer
sourcepub fn read_stored_dtcs_iso15031(
&mut self,
range: DTCRange
) -> DiagServerResult<Vec<DTC>>
pub fn read_stored_dtcs_iso15031(
&mut self,
range: DTCRange
) -> DiagServerResult<Vec<DTC>>
Returns a list of stored DTCs on the ECU in ISO15031-6 format
sourcepub fn read_supported_dtcs_iso15031(
&mut self,
range: DTCRange
) -> DiagServerResult<Vec<DTC>>
pub fn read_supported_dtcs_iso15031(
&mut self,
range: DTCRange
) -> DiagServerResult<Vec<DTC>>
Returns a list of all supported DTCs on the ECU regardless of their status in ISO15031-6 format
sourcepub fn read_stored_dtcs(
&mut self,
range: DTCRange
) -> DiagServerResult<Vec<DTC>>
pub fn read_stored_dtcs(
&mut self,
range: DTCRange
) -> DiagServerResult<Vec<DTC>>
Returns a list of stored DTCs on the ECU in KWP2000 format
sourcepub fn read_supported_dtcs(
&mut self,
range: DTCRange
) -> DiagServerResult<Vec<DTC>>
pub fn read_supported_dtcs(
&mut self,
range: DTCRange
) -> DiagServerResult<Vec<DTC>>
Returns a list of all supported DTCs on the ECU regardless of their status, in KWP2000 format.
NOTE: Internally, this function will call Kwp2000DiagnosticServer::read_extended_supported_dtcs in a loop in order to read all DTCs regardless of transport layer limitations
sourcepub fn get_most_recent_dtc(
&mut self,
range: DTCRange
) -> DiagServerResult<Option<DTC>>
pub fn get_most_recent_dtc(
&mut self,
range: DTCRange
) -> DiagServerResult<Option<DTC>>
Asks the ECU to report its most recent DTCs that has been stored. Only one DTC is returned if stored, otherwise no DTC is returned.
sourcepub fn read_extended_supported_dtcs(
&mut self,
range: DTCRange
) -> DiagServerResult<u16>
pub fn read_extended_supported_dtcs(
&mut self,
range: DTCRange
) -> DiagServerResult<u16>
Upon execution of Kwp2000DiagnosticServer::read_supported_dtcs or Kwp2000DiagnosticServer::read_supported_dtcs_iso15031, if the transport layer restricts the number of DTCs that can be read, or the number of DTCs exceeds 255, then this function will return the number of remaining supported of DTCs to read. Kwp2000DiagnosticServer::read_supported_dtcs or Kwp2000DiagnosticServer::read_supported_dtcs_iso15031 should be executed to read the rest of the DTCs again within the ECUs P3-MAX time window
sourceimpl Kwp2000DiagnosticServer
impl Kwp2000DiagnosticServer
sourcepub fn read_daimler_identification(
&mut self
) -> DiagServerResult<DaimlerEcuIdent>
pub fn read_daimler_identification(
&mut self
) -> DiagServerResult<DaimlerEcuIdent>
Reads Daimler ECU identification from ECU
sourcepub fn read_daimler_mmc_identification(
&mut self
) -> DiagServerResult<DaimlerMmcEcuIdent>
pub fn read_daimler_mmc_identification(
&mut self
) -> DiagServerResult<DaimlerMmcEcuIdent>
Reads Daimler and MMC ECU identification from ECU
sourcepub fn read_original_vin(&mut self) -> DiagServerResult<String>
pub fn read_original_vin(&mut self) -> DiagServerResult<String>
Reads the original VIN programmed onto the ECU from the manufacturer
sourcepub fn read_diagnostic_variant_code(&mut self) -> DiagServerResult<u32>
pub fn read_diagnostic_variant_code(&mut self) -> DiagServerResult<u32>
Reads the unique diagnostic variant code of the ECU
sourcepub fn read_current_vin(&mut self) -> DiagServerResult<String>
pub fn read_current_vin(&mut self) -> DiagServerResult<String>
Reads the current VIN stored on the ECU
sourcepub fn read_calibration_id(&mut self) -> DiagServerResult<String>
pub fn read_calibration_id(&mut self) -> DiagServerResult<String>
Reads the OBD Calibration ID from the ECU.
sourcepub fn read_cvn(&mut self) -> DiagServerResult<[u8; 4]>
pub fn read_cvn(&mut self) -> DiagServerResult<[u8; 4]>
Reads the calibration verification number from the ECU
sourcepub fn read_ecu_code_fingerprint(
&mut self
) -> DiagServerResult<ModuleInformation>
pub fn read_ecu_code_fingerprint(
&mut self
) -> DiagServerResult<ModuleInformation>
Reads module information from the ECU’s code block
sourcepub fn read_ecu_data_fingerprint(
&mut self
) -> DiagServerResult<ModuleInformation>
pub fn read_ecu_data_fingerprint(
&mut self
) -> DiagServerResult<ModuleInformation>
Reads module information from the ECU’s data block
sourcepub fn read_ecu_code_software_id(
&mut self
) -> DiagServerResult<SoftwareBlockIdentification>
pub fn read_ecu_code_software_id(
&mut self
) -> DiagServerResult<SoftwareBlockIdentification>
Reads code identification information from the ECU’s code block
sourcepub fn read_ecu_data_software_id(
&mut self
) -> DiagServerResult<SoftwareBlockIdentification>
pub fn read_ecu_data_software_id(
&mut self
) -> DiagServerResult<SoftwareBlockIdentification>
Reads code identification information from the ECU’s data block
sourcepub fn read_ecu_boot_software_id(
&mut self
) -> DiagServerResult<SoftwareBlockIdentification>
pub fn read_ecu_boot_software_id(
&mut self
) -> DiagServerResult<SoftwareBlockIdentification>
Reads code identification information from the ECU’s boot block
sourcepub fn read_ecu_boot_fingerprint(
&mut self
) -> DiagServerResult<ModuleInformation>
pub fn read_ecu_boot_fingerprint(
&mut self
) -> DiagServerResult<ModuleInformation>
Reads code identification information from the ECU’s boot block
sourceimpl Kwp2000DiagnosticServer
impl Kwp2000DiagnosticServer
sourcepub fn read_memory(
&mut self,
address: u32,
size: u8
) -> DiagServerResult<Vec<u8>>
pub fn read_memory(
&mut self,
address: u32,
size: u8
) -> DiagServerResult<Vec<u8>>
Reads the contents of RAM memory on the ECU given a 3 byte address, and 1 byte size. The maximum value for address is 0xFFFFFF, any larger values will be clamped.
NOTE: This function is ONLY indented for ECU development. In production ECUs, use Kwp2000DiagnosticServer::read_custom_local_identifier instead
sourceimpl Kwp2000DiagnosticServer
impl Kwp2000DiagnosticServer
sourcepub fn read_status_of_dtc(&mut self, dtc: u16) -> DiagServerResult<Vec<u8>>
pub fn read_status_of_dtc(&mut self, dtc: u16) -> DiagServerResult<Vec<u8>>
Reads the status of a given DTC.
This function returns bytes rather than a processed result as the environmental data varies from DTC to DTC and from ECU to ECU, so it is impossible to know what the data returned actually means.
Returns
This function if successful will return the full ECUs response message without any additional processing.
The first 4 bytes of the response are as follows:
- DTC Number (Stored on ECU)
- DTC High byte
- DTC Low byte
- Status of DTC
sourceimpl Kwp2000DiagnosticServer
impl Kwp2000DiagnosticServer
sourcepub fn request_seed(&mut self, access_mode: u8) -> DiagServerResult<Vec<u8>>
pub fn request_seed(&mut self, access_mode: u8) -> DiagServerResult<Vec<u8>>
Requests a seed from the ECU
Parameters
- server - The KWP2000 server
- access_mode - The access mode. Only odd numbers between 0x01-0x7F are supported for the access level!
Returns
This function will return an error if the access_mode parameter is not a valid mode! If the function succeeds, then just the ECUs key response is returned
sourcepub fn unlock_ecu_with_key(
&mut self,
access_mode: u8,
key: &[u8]
) -> DiagServerResult<()>
pub fn unlock_ecu_with_key(
&mut self,
access_mode: u8,
key: &[u8]
) -> DiagServerResult<()>
Attempts to unlock the access mode to the ECU, using a computed key using the seed provided with Kwp2000DiagnosticServer::request_seed
Parameters
- server - The KWP2000 server
- access_mode - The access mode. Only odd numbers between 0x01-0x7F are supported for the access level!
Returns
This function will return an error if the access_mode parameter is not a valid mode! The access_mode should be THE SAME as what was provided to Kwp2000DiagnosticServer::request_seed
sourceimpl Kwp2000DiagnosticServer
impl Kwp2000DiagnosticServer
sourcepub fn set_diagnostic_session_mode(
&mut self,
mode: SessionType
) -> DiagServerResult<()>
pub fn set_diagnostic_session_mode(
&mut self,
mode: SessionType
) -> DiagServerResult<()>
Sets the ECU into a diagnostic mode
Parameters
- server - The KWP2000 Diagnostic server
- mode - The SessionType to put the ECU into
sourceimpl Kwp2000DiagnosticServer
impl Kwp2000DiagnosticServer
sourcepub fn new_over_iso_tp<C, E>(
settings: Kwp2000ServerOptions,
server_channel: C,
channel_cfg: IsoTPSettings,
event_handler: E
) -> DiagServerResult<Self> where
C: IsoTPChannel + 'static,
E: ServerEventHandler<SessionType> + 'static,
pub fn new_over_iso_tp<C, E>(
settings: Kwp2000ServerOptions,
server_channel: C,
channel_cfg: IsoTPSettings,
event_handler: E
) -> DiagServerResult<Self> where
C: IsoTPChannel + 'static,
E: ServerEventHandler<SessionType> + 'static,
Creates a new KWP2000 over an ISO-TP connection with the ECU
On startup, this server will configure the channel with the necessary settings provided in both settings and channel_cfg
Parameters
- settings - KWP2000 Server settings
- channel - ISO-TP communication channel with the ECU
- channel_cfg - The settings to use for the ISO-TP channel
- event_handler - Handler for logging events happening within the server. If you don’t want to create your own handler, use Kwp2000VoidHandler
sourcepub fn get_settings(&self) -> Kwp2000ServerOptions
pub fn get_settings(&self) -> Kwp2000ServerOptions
Returns the current settings used by the KWP2000 Server
Trait Implementations
sourceimpl Debug for Kwp2000DiagnosticServer
impl Debug for Kwp2000DiagnosticServer
sourceimpl DiagnosticServer<KWP2000Command> for Kwp2000DiagnosticServer
impl DiagnosticServer<KWP2000Command> for Kwp2000DiagnosticServer
sourcefn execute_command_with_response(
&mut self,
sid: KWP2000Command,
args: &[u8]
) -> DiagServerResult<Vec<u8>>
fn execute_command_with_response(
&mut self,
sid: KWP2000Command,
args: &[u8]
) -> DiagServerResult<Vec<u8>>
Send a command to the ECU, and receive its response
Parameters
- sid - The Service ID of the command
- args - The arguments for the service
Returns
If the function is successful, and the ECU responds with an OK response (Containing data), then the full ECU response is returned. The response will begin with the sid + 0x40
sourcefn execute_command(
&mut self,
sid: KWP2000Command,
args: &[u8]
) -> DiagServerResult<()>
fn execute_command(
&mut self,
sid: KWP2000Command,
args: &[u8]
) -> DiagServerResult<()>
Send a command to the ECU, but don’t receive a response
Parameters
- sid - The Service ID of the command
- args - The arguments for the service
sourcefn send_byte_array(&mut self, arr: &[u8]) -> DiagServerResult<()>
fn send_byte_array(&mut self, arr: &[u8]) -> DiagServerResult<()>
Sends an arbitrary byte array to the ECU, and does not query response from the ECU
sourcefn send_byte_array_with_response(
&mut self,
arr: &[u8]
) -> DiagServerResult<Vec<u8>>
fn send_byte_array_with_response(
&mut self,
arr: &[u8]
) -> DiagServerResult<Vec<u8>>
Sends an arbitrary byte array to the ECU, and polls for the ECU’s response
sourcefn set_repeat_count(&mut self, count: u32)
fn set_repeat_count(&mut self, count: u32)
Sets the command retry counter
sourcefn set_repeat_interval_count(&mut self, interval_ms: u32)
fn set_repeat_interval_count(&mut self, interval_ms: u32)
Sets the command retry interval
sourcefn is_server_running(&self) -> bool
fn is_server_running(&self) -> bool
Returns true if the internal KWP2000 Server is running
sourceimpl Drop for Kwp2000DiagnosticServer
impl Drop for Kwp2000DiagnosticServer
sourceimpl From<Kwp2000DiagnosticServer> for DynamicDiagSession
impl From<Kwp2000DiagnosticServer> for DynamicDiagSession
sourcefn from(s: Kwp2000DiagnosticServer) -> Self
fn from(s: Kwp2000DiagnosticServer) -> Self
Converts to this type from the input type.
Auto Trait Implementations
impl !RefUnwindSafe for Kwp2000DiagnosticServer
impl Send for Kwp2000DiagnosticServer
impl !Sync for Kwp2000DiagnosticServer
impl Unpin for Kwp2000DiagnosticServer
impl !UnwindSafe for Kwp2000DiagnosticServer
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more