def test_rdbiMultipleDIDMixedResponse(self, tp_send, tp_recv): tp_send.return_value = False tp_recv.return_value = [0x62, 0xF1, 0x8C, 0xF1, 0x80] # ECU Serial Number = "ABC0011223344556" (16 bytes as specified in "_Bootloader_87") # numberOfModules = 0x01 (1 bytes as specified in "_Bootloader_1") # Boot Software Identification = "SwId12345678901234567890" (24 bytes as specified in "_Bootloader_71") tp_recv.return_value = [ 0x62, 0xF1, 0x8C, 0x41, 0x42, 0x43, 0x30, 0x30, 0x31, 0x31, 0x32, 0x32, 0x33, 0x33, 0x34, 0x34, 0x35, 0x35, 0x36, 0xF1, 0x80, 0x01, 0x53, 0x77, 0x49, 0x64, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30 ] # Parameters: xml file (odx file), ecu name (not currently used) ... a = createUdsConnection('../Functional Tests/Bootloader.odx', 'bootloader', transportProtocol="TEST") # ... creates the uds object and returns it; also parses out the rdbi info and attaches the __readDataByIdentifier to readDataByIdentifier in the uds object, so can now call below b = a.readDataByIdentifier([ 'ECU Serial Number', 'Boot Software Identification' ]) # ... calls __readDataByIdentifier, which does the Uds.send tp_send.assert_called_with([0x22, 0xF1, 0x8C, 0xF1, 0x80], False) self.assertEqual(({ 'ECU Serial Number': 'ABC0011223344556' }, { 'Boot Software Identification': 'SwId12345678901234567890', 'numberOfModules': [0x01] }), b)
def test_reqUploadRequest02(self, canTp_send, canTp_recv): canTp_send.return_value = False canTp_recv.return_value = [0x74, 0x40, 0x01, 0x00, 0x05, 0x08] # Parameters: xml file (odx file), ecu name (not currently used) ... a = createUdsConnection('../Functional Tests/Bootloader.odx', 'bootloader') # ... creates the uds object and returns it; also parses out the rdbi info and attaches the __requestUpload to requestUpload in the uds object, so can now call below b = a.requestUpload( FormatIdentifier=[0x00], MemoryAddress=[0x01, 0xFF, 0x0A, 0x80], MemorySize=[ 0x03, 0xFF ]) # ... calls __requestUpload, which does the Uds.send canTp_send.assert_called_with([ 0x34, 0x00, 0x24, 0x01, 0xFF, 0x0A, 0x80, 0x03, 0xFF, ], False) self.assertEqual( { 'LengthFormatIdentifier': [0x40], 'MaxNumberOfBlockLength': [0x01, 0x00, 0x05, 0x08] }, b) # ... (returns a dict)
def test_wdbiNegResponse_0x13(self, tp_send, tp_recv): tp_send.return_value = False tp_recv.return_value = [0x7F, 0x13] # Parameters: xml file (odx file), ecu name (not currently used) ... a = createUdsConnection('../Functional Tests/Bootloader.odx', 'bootloader', transportProtocol="TEST") # ... creates the uds object and returns it; also parses out the rdbi info and attaches the __readDataByIdentifier to readDataByIdentifier in the uds object, so can now call below try: b = a.writeDataByIdentifier( 'ECU Serial Number', 'ABC0011223344556' ) # ... calls __readDataByIdentifier, which does the Uds.send except: b = traceback.format_exc().split("\n")[-2:-1][ 0] # ... extract the exception text tp_send.assert_called_with([ 0x2E, 0xF1, 0x8C, 0x41, 0x42, 0x43, 0x30, 0x30, 0x31, 0x31, 0x32, 0x32, 0x33, 0x33, 0x34, 0x34, 0x35, 0x35, 0x36 ], False) self.assertEqual( "Exception: Detected negative response: ['0x7f', '0x13']", b) # ... wdbi should not return a value
def test_testerPresentReqdUpdatedTO(self, canTp_send, canTp_recv): canTp_send.return_value = False canTp_recv.return_value = [ 0x50, 0x01, 0x00, 0x05, 0x00, 0x0A ] # ... can return 1 to N bytes in the sessionParameterRecord - looking into this one # Parameters: xml file (odx file), ecu name (not currently used) ... a = createUdsConnection('../Functional Tests/Bootloader.odx', 'bootloader') # ... creates the uds object and returns it; also parses out the testerPresent info and attaches the __diagnosticSessionControl to diagnosticSessionControl in the uds object, so can now call below b = a.diagnosticSessionControl( 'Default Session', testerPresent=True, tpTimeout=250 ) # ... calls __diagnosticSessionControl, which does the Uds.send canTp_send.assert_called_with([0x10, 0x01], False) self.assertEqual( { 'Type': [0x01], 'P3': [0x00, 0x05], 'P3Ex': [0x00, 0x0A] }, b) # ... diagnosticSessionControl should not return a value b = a.testerPresentSessionRecord() self.assertEqual({ 'reqd': True, 'timeout': 250 }, b) # ... diagnosticSessionControl should not return a value
def test_routineControlRequestNoSuppress(self, canTp_send, canTp_recv): canTp_send.return_value = False canTp_recv.return_value = [0x71, 0x01, 0xFF, 0x00, 0x30] # Parameters: xml file (odx file), ecu name (not currently used) ... a = createUdsConnection('../Functional Tests/Bootloader.odx', 'bootloader') # ... creates the uds object and returns it; also parses out the rdbi info and attaches the __routineControl to routineControl in the uds object, so can now call below b = a.routineControl( 'Erase Memory', IsoRoutineControlType.startRoutine, [('memoryAddress', [0x01]), ('memorySize', [0xF000])], suppressResponse=False ) # ... calls __routineControl, which does the Uds.send canTp_send.assert_called_with([ 0x31, 0x01, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0xF0, 0x00 ], False) self.assertEqual( { 'Erase Memory Status': [0x30], 'RoutineControlType': [0x01], 'Identifier': [0xFF, 0x00] }, b)
def test_reqUploadNegResponse_0x13(self, canTp_send, canTp_recv): canTp_send.return_value = False canTp_recv.return_value = [0x7F, 0x13] # Parameters: xml file (odx file), ecu name (not currently used) ... a = createUdsConnection('../Functional Tests/Bootloader.odx', 'bootloader') # ... creates the uds object and returns it; also parses out the rdbi info and attaches the __requestUpload to requestUpload in the uds object, so can now call below try: b = a.requestUpload( FormatIdentifier=[0x00], MemoryAddress=[0x40, 0x03, 0xE0, 0x00], MemorySize=[ 0x00, 0x00, 0x0E, 0x56 ]) # ... calls __requestUpload, which does the Uds.send except: b = traceback.format_exc().split("\n")[-2:-1][ 0] # ... extract the exception text canTp_send.assert_called_with( [0x34, 0x00, 0x44, 0x40, 0x03, 0xE0, 0x00, 0x00, 0x00, 0x0E, 0x56], False) self.assertEqual( "Exception: Detected negative response: ['0x7f', '0x13']", b) # ... requestUpload should not return a value
def test_securityAccessNegativeResponse(self, tp_send, tp_recv): tp_send.return_value = False tp_recv.return_value = [0x7F, 0x00, 0x00] # Parameters: xml file (odx file), ecu name (not currently used) ... a = createUdsConnection('../Functional Tests/Bootloader.odx', 'bootloader', transportProtocol="TEST") with self.assertRaises(Exception) as context: b = a.securityAccess('Programming Request') self.assertTrue("Found negative response" in str(context.exception))
def test_transExitRequest(self, canTp_send, canTp_recv): canTp_send.return_value = False canTp_recv.return_value = [0x77, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF] # Parameters: xml file (odx file), ecu name (not currently used) ... a = createUdsConnection('../Functional Tests/Bootloader.odx', 'bootloader') # ... creates the uds object and returns it; also parses out the rdbi info and attaches the __transferExit to transferExit in the uds object, so can now call below b = a.transferExit([0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF]) # ... calls __transferExit, which does the Uds.send - takes blockSequenceCounter and parameterRecord canTp_send.assert_called_with([0x37, 0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF],False) self.assertEqual({'transferResponseParameterRecord':[0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF]}, b) # ... (returns a dict)
def test_readDTC_reportSupportedDTC(self, tp_send, tp_recv): tp_send.return_value = False tp_recv.return_value = [0x59, 0x0A, 0x28, 0xF1, 0xC8, 0x55, 0x01, 0xF1, 0xD0, 0x56, 0x01, 0xF1, 0xD8, 0x57, 0x01] # Parameters: xml file (odx file), ecu name (not currently used) ... a = createUdsConnection('../Functional Tests/EBC-Diagnostics_old.odx', 'bootloader', transportProtocol="TEST") # ... creates the uds object and returns it; also parses out the rdbi info and attaches the __readDataByIdentifier to readDataByIdentifier in the uds object, so can now call below b = a.readDTC(IsoReadDTCSubfunction.reportSupportedDTC) # ... calls __readDataByIdentifier, which does the Uds.send tp_send.assert_called_with([0x19, 0x0A],False) self.assertEqual({'DTCStatusAvailabilityMask':[0x28],'DTCAndStatusRecord':[{'DTC':[0xF1, 0xC8, 0x55],'statusOfDTC':[0x01]},{'DTC':[0xF1, 0xD0, 0x56],'statusOfDTC':[0x01]},{'DTC':[0xF1, 0xD8, 0x57],'statusOfDTC':[0x01]}]}, b)
def test_ioControlRequest_returnControl(self, tp_send, tp_recv): tp_send.return_value = False tp_recv.return_value = [0x6F, 0xFE, 0x16, 0x00, 0x00, 0x00, 0x1F, 0x40] # Parameters: xml file (odx file), ecu name (not currently used) ... a = createUdsConnection('../Functional Tests/EBC-Diagnostics_old.odx', 'bootloader', transportProtocol="TEST") # ... creates the uds object and returns it; also parses out the rdbi info and attaches the __inputOutputControl to inputOutputControl in the uds object, so can now call below b = a.inputOutputControl('Booster Target Speed',IsoOptionRecord.returnControl,None) # ... calls __inputOutputControl, which does the Uds.send tp_send.assert_called_with([0x2F, 0xFE, 0x16, 0x00],False) self.assertEqual({'Identifier':[0xFE, 0x16],'ControlOptionRecord':[IsoOptionRecord.returnControl],'TargetSpeed':[0x00, 0x00, 0x1F, 0x40]}, b)
def test_ecuResetRequestSuppress(self, tp_send): tp_send.return_value = False # Parameters: xml file (odx file), ecu name (not currently used) ... a = createUdsConnection('../Functional Tests/Bootloader.odx', 'bootloader', transportProtocol="TEST") # ... creates the uds object and returns it; also parses out the rdbi info and attaches the __readDataByIdentifier to readDataByIdentifier in the uds object, so can now call below b = a.ecuReset('Hard Reset', suppressResponse=True ) # ... calls __ecuReset, which does the Uds.send tp_send.assert_called_with([0x11, 0x81], False) self.assertEqual(None, b) # ... wdbi should not return a value
def test_diagSessCtrlRequestSuppress(self, canTp_send): canTp_send.return_value = False # Parameters: xml file (odx file), ecu name (not currently used) ... a = createUdsConnection('../Functional Tests/Bootloader.odx', 'bootloader') # ... creates the uds object and returns it; also parses out the rdbi info and attaches the __diagnosticSessionControl to diagnosticSessionControl in the uds object, so can now call below b = a.diagnosticSessionControl( 'Default Session', suppressResponse=True ) # ... calls __diagnosticSessionControl, which does the Uds.send canTp_send.assert_called_with([0x10, 0x81], False) self.assertEqual( None, b) # ... diagnosticSessionControl should not return a value
def test_transDataRequest_ihex04(self, canTp_send, canTp_recv): canTp_send.return_value = False canTp_recv.return_value = [0x76, 0x01, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF] # Parameters: xml file (odx file), ecu name (not currently used) ... a = createUdsConnection('../Functional Tests/Bootloader.odx', 'bootloader',ihexFile="./unitTest01.hex") a.ihexFile.transmitChunksize = 1280 # ... creates the uds object and returns it; also parses out the rdbi info and attaches the __transferData to transferData in the uds object, so can now call below b = a.transferData(transferBlocks=a.ihexFile) # ... calls __transferData, which does the Uds.send - takes blockSequenceCounter and parameterRecord canTp_send.assert_called_with([0x36, 0x01, 0x00, 0x08, 0x00, 0x70, 0x00, 0x09, 0x4E, 0x80, 0x45, 0x34, 0x30, 0x30, 0x2D, 0x55, 0x44, 0x53],False) self.assertEqual({'blockSequenceCounter':[0x01],'transferResponseParameterRecord':[0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF]}, b) # ... (returns a dict)
def test_ioControlRequest_adjust(self, tp_send, tp_recv): tp_send.return_value = False tp_recv.return_value = [0x54] # Parameters: xml file (odx file), ecu name (not currently used) ... a = createUdsConnection('../Functional Tests/EBC-Diagnostics_old.odx', 'bootloader', transportProtocol="TEST") # ... creates the uds object and returns it; also parses out the rdbi info and attaches the __inputOutputControl to inputOutputControl in the uds object, so can now call below b = a.clearDTC([0xF1, 0xC8, 0x55]) # ... calls __clearDTC, which does the Uds.send tp_send.assert_called_with([0x14, 0xF1, 0xC8, 0x55], False) self.assertEqual(None, b)
def test_readDTC_reportNumberOfDTCByStatusMask(self, tp_send, tp_recv): tp_send.return_value = False tp_recv.return_value = [0x59, 0x01, 0x28, 0x00, 0x00, 0x03] # Parameters: xml file (odx file), ecu name (not currently used) ... a = createUdsConnection('../Functional Tests/EBC-Diagnostics_old.odx', 'bootloader', transportProtocol="TEST") # ... creates the uds object and returns it; also parses out the rdbi info and attaches the __readDataByIdentifier to readDataByIdentifier in the uds object, so can now call below b = a.readDTC(IsoReadDTCSubfunction.reportNumberOfDTCByStatusMask, DTCStatusMask=Mask.confirmedDtc + Mask.testFailedSinceLastClear) # ... calls __readDataByIdentifier, which does the Uds.send tp_send.assert_called_with([0x19, 0x01, 0x28],False) self.assertEqual({'DTCStatusAvailabilityMask':[0x28],'DTCFormatIdentifier':[0x00],'DTCCount':[3]}, b)
def test_testerPresentRequestSuppress(self, tp_send): tp_send.return_value = False # Parameters: xml file (odx file), ecu name (not currently used) ... a = createUdsConnection('../Functional Tests/Bootloader.odx', 'bootloader', transportProtocol="TEST") # ... creates the uds object and returns it; also parses out the testerPresent info and attaches the __testerPresent to testerPresent in the uds object, so can now call below b = a.testerPresent( suppressResponse=True ) # ... calls __testerPresent, which does the Uds.send tp_send.assert_called_with([0x3E, 0x80], False) self.assertEqual(None, b) # ... testerPresent should not return a value
def test_transExitNegResponse_0x24(self, canTp_send, canTp_recv): canTp_send.return_value = False canTp_recv.return_value = [0x7F, 0x24] # Parameters: xml file (odx file), ecu name (not currently used) ... a = createUdsConnection('../Functional Tests/Bootloader.odx', 'bootloader') # ... creates the uds object and returns it; also parses out the rdbi info and attaches the __transferExit to transferExit in the uds object, so can now call below try: b = a.transferExit([0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF]) # ... calls __transferExit, which does the Uds.send except: b = traceback.format_exc().split("\n")[-2:-1][0] # ... extract the exception text canTp_send.assert_called_with([0x37, 0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF],False) self.assertEqual("Exception: Detected negative response: ['0x7f', '0x24']", b) # ... transferExit should not return a value
def test_ecuResetNegResponse_0x22(self, tp_send, tp_recv): tp_send.return_value = False tp_recv.return_value = [0x7F, 0x22] # Parameters: xml file (odx file), ecu name (not currently used) ... a = createUdsConnection('../Functional Tests/EBC-Diagnostics_old.odx', 'bootloader', transportProtocol="TEST") # ... creates the uds object and returns it; also parses out the rdbi info and attaches the __inputOutputControl to inputOutputControl in the uds object, so can now call below try: b = a.inputOutputControl('Booster Target Speed',IsoOptionRecord.adjust,[8000]) # ... calls __inputOutputControl, which does the Uds.send except: b = traceback.format_exc().split("\n")[-2:-1][0] # ... extract the exception text tp_send.assert_called_with([0x2F, 0xFE, 0x16, 0x03, 0x00, 0x00, 0x1F, 0x40],False) self.assertEqual("Exception: Detected negative response: ['0x7f', '0x22']", b)
def test_readDTCNegResponse_0x31(self, tp_send, tp_recv): tp_send.return_value = False tp_recv.return_value = [0x7F, 0x31] # Parameters: xml file (odx file), ecu name (not currently used) ... a = createUdsConnection('../Functional Tests/EBC-Diagnostics_old.odx', 'bootloader', transportProtocol="TEST") # ... creates the uds object and returns it; also parses out the rdbi info and attaches the __readDTC to readDTC in the uds object, so can now call below try: b = a.readDTC(IsoReadDTCSubfunction.reportDTCByStatusMask, DTCStatusMask=Mask.confirmedDtc + Mask.testFailedSinceLastClear) # ... calls __readDTC, which does the Uds.send except: b = traceback.format_exc().split("\n")[-2:-1][0] # ... extract the exception text tp_send.assert_called_with([0x19, 0x02, 0x28],False) self.assertEqual("Exception: Detected negative response: ['0x7f', '0x31']", b)
def test_wdbiAsciiRequest(self, tp_send, tp_recv): tp_send.return_value = False tp_recv.return_value = [0x6E, 0xF1, 0x8C] # Parameters: xml file (odx file), ecu name (not currently used) ... a = createUdsConnection('../Functional Tests/Bootloader.odx', 'bootloader', transportProtocol="TEST") # ... creates the uds object and returns it; also parses out the rdbi info and attaches the __readDataByIdentifier to readDataByIdentifier in the uds object, so can now call below b = a.writeDataByIdentifier( 'ECU Serial Number', 'ABC0011223344556' ) # ... calls __readDataByIdentifier, which does the Uds.send tp_send.assert_called_with([ 0x2E, 0xF1, 0x8C, 0x41, 0x42, 0x43, 0x30, 0x30, 0x31, 0x31, 0x32, 0x32, 0x33, 0x33, 0x34, 0x34, 0x35, 0x35, 0x36 ], False) self.assertEqual(None, b) # ... wdbi should not return a value
def test_securityAccessKeyRequest(self, tp_send, tp_recv): tp_send.return_value = False tp_recv.return_value = [0x67, 0x02] # Parameters: xml file (odx file), ecu name (not currently used) ... a = createUdsConnection('../Functional Tests/Bootloader.odx', 'bootloader', transportProtocol="TEST") b = a.securityAccess('Programming Key', [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ]) tp_send.assert_called_with([ 0x27, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ], False) self.assertEqual(None, b) # ... wdbi should not return a value
def test_rdbiSingleDIDAsciiResponse(self, tp_send, tp_recv): tp_send.return_value = False # ECU Serial Number = "ABC0011223344556" (16 bytes as specified in "_Bootloader_87") tp_recv.return_value = [ 0x62, 0xF1, 0x8C, 0x41, 0x42, 0x43, 0x30, 0x30, 0x31, 0x31, 0x32, 0x32, 0x33, 0x33, 0x34, 0x34, 0x35, 0x35, 0x36 ] # Parameters: xml file (odx file), ecu name (not currently used) ... a = createUdsConnection('../Functional Tests/Bootloader.odx', 'bootloader', transportProtocol="TEST") # ... creates the uds object and returns it; also parses out the rdbi info and attaches the __readDataByIdentifier to readDataByIdentifier in the uds object, so can now call below b = a.readDataByIdentifier( 'ECU Serial Number' ) # ... calls __readDataByIdentifier, which does the Uds.send tp_send.assert_called_with([0x22, 0xF1, 0x8C], False) self.assertEqual({'ECU Serial Number': 'ABC0011223344556'}, b)
def test_ecuResetNegResponse_0x12(self, tp_send, tp_recv): tp_send.return_value = False tp_recv.return_value = [0x7F, 0x12] # Parameters: xml file (odx file), ecu name (not currently used) ... a = createUdsConnection('../Functional Tests/Bootloader.odx', 'bootloader', transportProtocol="TEST") # ... creates the uds object and returns it; also parses out the testerPresent info and attaches the __testerPresent to testerPresent in the uds object, so can now call below try: b = a.testerPresent( suppressResponse=False ) # ... calls __testerPresent, which does the Uds.send except: b = traceback.format_exc().split("\n")[-2:-1][ 0] # ... extract the exception text tp_send.assert_called_with([0x3E, 0x00], False) self.assertEqual( "Exception: Detected negative response: ['0x7f', '0x12']", b)
def test_diagSessCtrlNegResponse_0x22(self, canTp_send, canTp_recv): canTp_send.return_value = False canTp_recv.return_value = [0x7F, 0x22] # Parameters: xml file (odx file), ecu name (not currently used) ... a = createUdsConnection('../Functional Tests/Bootloader.odx', 'bootloader') # ... creates the uds object and returns it; also parses out the rdbi info and attaches the __diagnosticSessionControl to diagnosticSessionControl in the uds object, so can now call below try: b = a.diagnosticSessionControl( 'Default Session', suppressResponse=False ) # ... calls __diagnosticSessionControl, which does the Uds.send except: b = traceback.format_exc().split("\n")[-2:-1][ 0] # ... extract the exception text canTp_send.assert_called_with([0x10, 0x01], False) self.assertEqual( "Exception: Detected negative response: ['0x7f', '0x22']", b) # ... diagnosticSessionControl should not return a value
def test_routineControlRequestCheckAppStart(self, canTp_send, canTp_recv): canTp_send.return_value = False canTp_recv.return_value = [0x71, 0x01, 0x03, 0x04, 0x30, 0x02] # Parameters: xml file (odx file), ecu name (not currently used) ... a = createUdsConnection('../Functional Tests/Bootloader.odx', 'bootloader') # ... creates the uds object and returns it; also parses out the rdbi info and attaches the __routineControl to routineControl in the uds object, so can now call below b = a.routineControl( 'Check Valid Application', IsoRoutineControlType.startRoutine ) # ... calls __routineControl, which does the Uds.send canTp_send.assert_called_with([0x31, 0x01, 0x03, 0x04], False) self.assertEqual( { 'Valid Application Status': [0x30], 'Valid Application Present': [0x02], 'RoutineControlType': [0x01], 'Identifier': [0x03, 0x04] }, b)
def test_routineControlRequestSBLStart(self, canTp_send, canTp_recv): canTp_send.return_value = False canTp_recv.return_value = [0x71, 0x01, 0x03, 0x01, 0xA7] # Parameters: xml file (odx file), ecu name (not currently used) ... a = createUdsConnection('../Functional Tests/Bootloader.odx', 'bootloader') # ... creates the uds object and returns it; also parses out the rdbi info and attaches the __routineControl to routineControl in the uds object, so can now call below b = a.routineControl( 'Start Secondary Bootloader', IsoRoutineControlType.startRoutine, [0xFF]) # ... calls __routineControl, which does the Uds.send canTp_send.assert_called_with( [0x31, 0x01, 0x03, 0x01, 0x00, 0x00, 0x00, 0xFF], False) self.assertEqual( { 'strSBLRoutineInfo': [0xA7], 'RoutineControlType': [0x01], 'Identifier': [0x03, 0x01] }, b)
def test_diagSessCtrlRequestNoSuppress(self, canTp_send, canTp_recv): canTp_send.return_value = False canTp_recv.return_value = [ 0x50, 0x01, 0x00, 0x05, 0x00, 0x0A ] # ... can return 1 to N bytes in the sessionParameterRecord - looking into this one # Parameters: xml file (odx file), ecu name (not currently used) ... a = createUdsConnection('../Functional Tests/Bootloader.odx', 'bootloader') # ... creates the uds object and returns it; also parses out the rdbi info and attaches the __diagnosticSessionControl to diagnosticSessionControl in the uds object, so can now call below b = a.diagnosticSessionControl( 'Default Session', suppressResponse=False ) # ... calls __diagnosticSessionControl, which does the Uds.send canTp_send.assert_called_with([0x10, 0x01], False) self.assertEqual( { 'Type': [0x01], 'P3': [0x00, 0x05], 'P3Ex': [0x00, 0x0A] }, b) # ... diagnosticSessionControl should not return a value
def test_wdbiMixedRequestReverseOrder(self, tp_send, tp_recv): tp_send.return_value = False tp_recv.return_value = [0x6E, 0xF1, 0x80] # Parameters: xml file (odx file), ecu name (not currently used) ... a = createUdsConnection('../Functional Tests/Bootloader.odx', 'bootloader', transportProtocol="TEST") # ... creates the uds object and returns it; also parses out the rdbi info and attaches the __readDataByIdentifier to readDataByIdentifier in the uds object, so can now call below b = a.writeDataByIdentifier('Boot Software Identification', [ ('numberOfModules', [0x01]), ('Boot Software Identification', 'SwId12345678901234567890') ]) # ... calls __readDataByIdentifier, which does the Uds.send tp_send.assert_called_with([ 0x2E, 0xF1, 0x80, 0x00, 0x00, 0x00, 0x01, 0x53, 0x77, 0x49, 0x64, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30 ], False) self.assertEqual(None, b) # ... wdbi should not return a value
def test_routineControlRequestProgDepResult(self, canTp_send, canTp_recv): canTp_send.return_value = False canTp_recv.return_value = [0x71, 0x03, 0xFF, 0x01, 0x30, 0xB9, 0x2E] # Parameters: xml file (odx file), ecu name (not currently used) ... a = createUdsConnection('../Functional Tests/Bootloader.odx', 'bootloader') # ... creates the uds object and returns it; also parses out the rdbi info and attaches the __routineControl to routineControl in the uds object, so can now call below b = a.routineControl( 'Check Programming Dependencies', IsoRoutineControlType.requestRoutineResults ) # ... calls __routineControl, which does the Uds.send canTp_send.assert_called_with([0x31, 0x03, 0xFF, 0x01], False) self.assertEqual( { 'RoutineStatusInfo': [0x30], 'Check Sum Value': [0xB9, 0x2E], 'RoutineControlType': [0x03], 'Identifier': [0xFF, 0x01] }, b)
def test_ecuResetNegResponse_0x72(self, canTp_send, canTp_recv): canTp_send.return_value = False canTp_recv.return_value = [0x7F, 0x72] # Parameters: xml file (odx file), ecu name (not currently used) ... a = createUdsConnection('../Functional Tests/Bootloader.odx', 'bootloader') # ... creates the uds object and returns it; also parses out the rdbi info and attaches the __routineControl to routineControl in the uds object, so can now call below try: b = a.routineControl( 'Erase Memory', IsoRoutineControlType.startRoutine, [ ('memoryAddress', [0x01]), ('memorySize', [0xF000]) ]) # ... calls __routineControl, which does the Uds.send except: b = traceback.format_exc().split("\n")[-2:-1][ 0] # ... extract the exception text canTp_send.assert_called_with([ 0x31, 0x01, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0xF0, 0x00 ], False) self.assertEqual( "Exception: Detected negative response: ['0x7f', '0x72']", b)