How to use the udsoncan.Response.Response.Code.IncorrectMessageLegthOrInvalidFormat function in udsoncan

To help you get started, we’ve selected a few udsoncan examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pylessard / python-udsoncan / udsoncan / services / ResponseOnEvent.py View on Github external
from . import *
from udsoncan.Response import Response
from udsoncan.exceptions import *

class ResponseOnEvent(BaseService):
    _sid = 0x86

    supported_negative_response = [	Response.Code.SubFunctionNotSupported, 
                                                    Response.Code.IncorrectMessageLegthOrInvalidFormat,
                                                    Response.Code.ConditionsNotCorrect,
                                                    Response.Code.RequestOutOfRange
                                                    ]

    @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__(ResponseOnEvent)
github pylessard / python-udsoncan / udsoncan / services.py View on Github external
return self.subfunction

class InputOutputControlByIdentifier(BaseService):
	_sid = 0x2F
	_use_subfunction = False

	#As defined by ISO-14229:2006, Annex E
	class ControlParam(BaseSubfunction):
		__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
							]

	def __init__(self, did, control_param=None, values=None, masks=None):
		from udsoncan import IOValues, IOMasks
		if not isinstance(did, int):
			raise ValueError("did  must be a valid integer")

		if did < 0 or did > 0xFFFF:
			raise ValueError('did must either be an integer between 0 and 0xFFFF. %d given' % did)
	

		if control_param is not None:
			if not isinstance(control_param, int):
github pylessard / python-udsoncan / udsoncan / services / WriteMemoryByAddress.py View on Github external
from . import *
from udsoncan.Response import Response
from udsoncan.exceptions import *

class WriteMemoryByAddress(BaseService):
    _sid = 0x3D
    _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, memory_location, data):
        """
        Generates a request for ReadMemoryByAddress

        :param memory_location: The address and the size of the memory block to write.
        :type memory_location: :ref:`MemoryLocation `

        :param data: The data to write into memory.
        :type data: bytes
github pylessard / python-udsoncan / udsoncan / services / LinkControl.py View on Github external
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):
github pylessard / python-udsoncan / udsoncan / services / SecurityAccess.py View on Github external
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')
github pylessard / python-udsoncan / udsoncan / services / RequestFileTransfer.py View on Github external
from . import *
from udsoncan.Response import Response
from udsoncan.exceptions import *
import struct

class RequestFileTransfer(BaseService):
    _sid = 0x38
    _use_subfunction = False

    supported_negative_response = [	
                                        Response.Code.IncorrectMessageLegthOrInvalidFormat,
                                        Response.Code.ConditionsNotCorrect,
                                        Response.Code.RequestOutOfRange,
                                        Response.Code.UploadDownloadNotAccepted
                                        ]
    class ModeOfOperation(BaseSubfunction): # Not really a subfunction, but we wantto inherit the helpers in BaseSubfunction class
        """
        RequestFileTransfer Mode Of Operation (MOOP). Represent the action that can be done on the server filesystem.
        See ISO-14229:2013 Annex G
        """

        __pretty_name__ = 'mode of operation'

        AddFile = 1
        DeleteFile = 2
        ReplaceFile = 3
        ReadFile = 4
github pylessard / python-udsoncan / udsoncan / services / DiagnosticSessionControl.py View on Github external
from . import *
from udsoncan.Response import Response
from udsoncan.exceptions import *

class DiagnosticSessionControl(BaseService):
    _sid = 0x10

    supported_negative_response = [	Response.Code.SubFunctionNotSupported, 
                                                                    Response.Code.IncorrectMessageLegthOrInvalidFormat,
                                                                    Response.Code.ConditionsNotCorrect
                                                                    ]
    class Session(BaseSubfunction):
        """
        DiagnosticSessionControl defined subfunctions
        """		
        __pretty_name__ = 'session'	

        defaultSession = 1
        programmingSession = 2
        extendedDiagnosticSession = 3
        safetySystemDiagnosticSession = 4

    @classmethod
    def make_request(cls, session):
        """
github pylessard / python-udsoncan / udsoncan / services / WriteDataByIdentifier.py View on Github external
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
github pylessard / python-udsoncan / udsoncan / services / SecuredDataTransmission.py View on Github external
class SecuredDataTransmission(BaseService):
    _sid = 0x84

    class Code:
        GeneralSecurityViolation 			= Response.Code.GeneralSecurityViolation			- 0x38
        SecuredModeRequested 				= Response.Code.SecuredModeRequested				- 0x38
        InsufficientProtection 				= Response.Code.InsufficientProtection				- 0x38
        TerminationWithSignatureRequested 	= Response.Code.TerminationWithSignatureRequested	- 0x38
        AccessDenied 						= Response.Code.AccessDenied						- 0x38
        VersionNotSupported 				= Response.Code.VersionNotSupported					- 0x38
        SecuredLinkNotSupported 			= Response.Code.SecuredLinkNotSupported				- 0x38
        CertificateNotAvailable 			= Response.Code.CertificateNotAvailable				- 0x38
        AuditTrailInformationNotAvailable 	= Response.Code.AuditTrailInformationNotAvailable	- 0x38

    supported_negative_response = [	Response.Code.SubFunctionNotSupported, 
                                                    Response.Code.IncorrectMessageLegthOrInvalidFormat,
                                                    Response.Code.GeneralSecurityViolation,
                                                    Response.Code.SecuredModeRequested,
                                                    Response.Code.InsufficientProtection,
                                                    Response.Code.TerminationWithSignatureRequested,
                                                    Response.Code.AccessDenied,
                                                    Response.Code.VersionNotSupported,
                                                    Response.Code.SecuredLinkNotSupported,
                                                    Response.Code.CertificateNotAvailable,
                                                    Response.Code.AuditTrailInformationNotAvailable
                                                    ]

    @classmethod
    def make_request(cls):
        raise NotImplementedError('Service is not implemented')

    @classmethod
github pylessard / python-udsoncan / udsoncan / services / RoutineControl.py View on Github external
class RoutineControl(BaseService):
    _sid = 0x31

    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