Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
#
class ControlParam(BaseSubfunction):
"""
InputOutputControlByIdentifier defined control parameters as defined by ISO-14229:2006, Annex E
"""
__pretty_name__ = 'control parameter'
returnControlToECU = 0
resetToDefault = 1
freezeCurrentState = 2
shortTermAdjustment = 3
supported_negative_response = [ Response.Code.IncorrectMessageLegthOrInvalidFormat,
Response.Code.ConditionsNotCorrect,
Response.Code.RequestOutOfRange,
Response.Code.SecurityAccessDenied
]
@classmethod
def make_request(cls, did, control_param=None, values=None, masks=None, ioconfig=None):
"""
Generates a request for InputOutputControlByIdentifier
:param did: Data identifier to represent the IO
:type did: int
:param control_param: Optional parameter that can be a value defined in :class:`InputOutputControlByIdentifier.ControlParam`
:type control_param: int
:param values: Optional values to send to the server. This parameter will be given to :ref:`DidCodec`.encode() method.
It can be:
from . import *
from udsoncan.Response import Response
from udsoncan.exceptions import *
import struct
class TransferData(BaseService):
_sid = 0x36
_use_subfunction = False
supported_negative_response = [ Response.Code.IncorrectMessageLegthOrInvalidFormat,
Response.Code.RequestSequenceError,
Response.Code.RequestOutOfRange,
Response.Code.TransferDataSuspended,
Response.Code.GeneralProgrammingFailure,
Response.Code.WrongBlockSequenceCounter,
Response.Code.VoltageTooHigh,
Response.Code.VoltageTooLow
]
@classmethod
def make_request(cls, sequence_number, data=None):
"""
Generates a request for TransferData
:param sequence_number: Corresponds to an 8bit counter that should increment for each new block transferred.
Allowed values are from 0 to 0xFF
:type sequence_number: int
from . import *
from udsoncan.Response import Response
from udsoncan.exceptions import *
import struct
class WriteDataByIdentifier(BaseService):
_sid = 0x2E
_use_subfunction = False
supported_negative_response = [ Response.Code.IncorrectMessageLegthOrInvalidFormat,
Response.Code.ConditionsNotCorrect,
Response.Code.RequestOutOfRange,
Response.Code.SecurityAccessDenied,
Response.Code.GeneralProgrammingFailure
]
@classmethod
def make_request(cls, did, value, didconfig):
"""
Generates a request for WriteDataByIdentifier
:param did: The data identifier to write
:type did: int
:param value: Value given to the :ref:`DidCodec `.encode method. If involved codec is defined with a pack string (default codec), multiple values may be passed with a tuple.
:type value: object
:param didconfig: Definition of DID codecs. Dictionary mapping a DID (int) to a valid :ref:`DidCodec ` class or pack/unpack string
from . import *
from udsoncan.Response import Response
from udsoncan.exceptions import *
class SecurityAccess(BaseService):
_sid = 0x27
supported_negative_response = [ Response.Code.SubFunctionNotSupported,
Response.Code.IncorrectMessageLegthOrInvalidFormat,
Response.Code.ConditionsNotCorrect,
Response.Code.RequestSequenceError,
Response.Code.RequestOutOfRange,
Response.Code.InvalidKey,
Response.Code.ExceedNumberOfAttempts,
Response.Code.RequiredTimeDelayNotExpired
]
class Mode:
RequestSeed=0
SendKey=1
@classmethod
def normalize_level(cls, mode, level):
cls.validate_mode(mode)
ServiceHelper.validate_int(level, min=0, max=0x7F, name='Security level')
if mode == cls.Mode.RequestSeed:
return level if level % 2 == 1 else level-1
from . import *
from udsoncan.Response import Response
from udsoncan.exceptions import *
class ControlDTCSetting(BaseService):
_sid = 0x85
supported_negative_response = [ Response.Code.SubFunctionNotSupported,
Response.Code.IncorrectMessageLegthOrInvalidFormat,
Response.Code.ConditionsNotCorrect,
Response.Code.RequestOutOfRange
]
class SettingType(BaseSubfunction):
"""
ControlDTCSetting defined subfunctions
"""
__pretty_name__ = 'setting type'
on = 1
off = 2
vehicleManufacturerSpecific = (0x40, 0x5F) # To be able to print textual name for logging only.
systemSupplierSpecific = (0x60, 0x7E) # To be able to print textual name for logging only.
@classmethod
def make_request(cls, setting_type, data = None):
"""
class ControlType(BaseSubfunction):
"""
RoutineControl defined subfunctions
"""
__pretty_name__ = 'control type'
startRoutine = 1
stopRoutine = 2
requestRoutineResults = 3
supported_negative_response = [ Response.Code.SubFunctionNotSupported,
Response.Code.IncorrectMessageLegthOrInvalidFormat,
Response.Code.ConditionsNotCorrect,
Response.Code.RequestSequenceError,
Response.Code.RequestOutOfRange,
Response.Code.SecurityAccessDenied,
Response.Code.GeneralProgrammingFailure
]
@classmethod
def make_request(cls, routine_id, control_type, data=None):
"""
Generates a request for RoutineControl
:param routine_id: The routine ID. Value should be between 0 and 0xFFFF
:type routine_id: int
:param control_type: Service subfunction. Allowed values are from 0 to 0x7F
:type control_type: bytes
:param data: Optional additional data to provide to the server
from . import *
from udsoncan.Response import Response
from udsoncan.exceptions import *
class LinkControl(BaseService):
_sid = 0x87
supported_negative_response = [ Response.Code.SubFunctionNotSupported,
Response.Code.IncorrectMessageLegthOrInvalidFormat,
Response.Code.ConditionsNotCorrect,
Response.Code.RequestSequenceError,
Response.Code.RequestOutOfRange
]
class ControlType(BaseSubfunction):
"""
LinkControl defined subfunctions
"""
__pretty_name__ = 'control type'
verifyBaudrateTransitionWithFixedBaudrate = 1
verifyBaudrateTransitionWithSpecificBaudrate = 2
transitionBaudrate = 3
@classmethod
def make_request(cls, control_type, baudrate=None):
"""
Generates a request for LinkControl
class AccessType(BaseSubfunction):
"""
AccessTimingParameter defined subfunctions
"""
__pretty_name__ = 'access type'
readExtendedTimingParameterSet = 1
setTimingParametersToDefaultValues = 2
readCurrentlyActiveTimingParameters = 3
setTimingParametersToGivenValues = 4
supported_negative_response = [ Response.Code.SubFunctionNotSupported,
Response.Code.IncorrectMessageLegthOrInvalidFormat,
Response.Code.ConditionsNotCorrect,
Response.Code.RequestOutOfRange
]
@classmethod
def make_request(cls, access_type, timing_param_record=None):
"""
Generates a request for AccessTimingParameter
:param access_type: Service subfunction. Allowed values are from 0 to 0x7F
:type access_type: int
:param timing_param_record: Data associated with request. Must be present only when access_type=``AccessType.setTimingParametersToGivenValues`` (4)
:type timing_param_record: bytes
:raises ValueError: If parameters are out of range, missing or wrong type
"""
from udsoncan import Request
from . import *
from udsoncan.Response import Response
from udsoncan.exceptions import *
class ReadMemoryByAddress(BaseService):
_sid = 0x23
_use_subfunction = False
supported_negative_response = [ Response.Code.IncorrectMessageLegthOrInvalidFormat,
Response.Code.ConditionsNotCorrect,
Response.Code.RequestOutOfRange,
Response.Code.SecurityAccessDenied
]
@classmethod
def make_request(cls, memory_location):
"""
Generates a request for ReadMemoryByAddress
:param memory_location: The address and the size of the memory block to read.
:type memory_location: :ref:`MemoryLocation `
:raises ValueError: If parameters are out of range, missing or wrong type
"""
from udsoncan import Request, MemoryLocation
if not isinstance(memory_location, MemoryLocation):
from . import *
from udsoncan.Response import Response
from udsoncan.exceptions import *
class ReadScalingDataByIdentifier(BaseService):
_sid = 0x24
supported_negative_response = [ Response.Code.IncorrectMessageLegthOrInvalidFormat,
Response.Code.ConditionsNotCorrect,
Response.Code.RequestOutOfRange,
Response.Code.SecurityAccessDenied
]
@classmethod
def make_request(cls):
raise NotImplementedError('Service is not implemented')
@classmethod
def interpret_response(cls, response):
raise NotImplementedError('Service is not implemented')
class ResponseData(BaseResponseData):
def __init__(self):
super().__init__(ReadScalingDataByIdentifier)